The ActivitySmith Ruby SDK provides convenient access to the ActivitySmith API from Ruby applications.
See API reference.
gem install activitysmithrequire "activitysmith"
activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY"))response = activitysmith.notifications.send(
{
title: "Build Failed",
message: "CI pipeline failed on main branch"
}
)
puts response.success
puts response.devices_notifiedstart = activitysmith.live_activities.start(
{
content_state: {
title: "ActivitySmith API Deployment",
subtitle: "start",
number_of_steps: 4,
current_step: 1,
type: "segmented_progress",
color: "yellow"
}
}
)
activity_id = start.activity_idupdate = activitysmith.live_activities.update(
{
activity_id: activity_id,
content_state: {
title: "ActivitySmith API Deployment",
subtitle: "npm i & pm2",
current_step: 3
}
}
)
puts update.devices_notifiedfinish = activitysmith.live_activities.end(
{
activity_id: activity_id,
content_state: {
title: "ActivitySmith API Deployment",
subtitle: "done",
current_step: 4,
auto_dismiss_minutes: 3
}
}
)
puts finish.successbegin
activitysmith.notifications.send(
{ title: "Build Failed" }
)
rescue OpenapiClient::ApiError => err
puts "Request failed: #{err.code} #{err.message}"
endactivitysmith.notificationsactivitysmith.live_activities
- Ruby 3.0+
MIT