From 477916a5e6487e60e30f6bf49562e7f15e644e03 Mon Sep 17 00:00:00 2001 From: bardonadam Date: Fri, 6 Feb 2026 21:18:50 +0100 Subject: [PATCH] docs: polish README examples and wrapping --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 051480e..e6b4e72 100644 --- a/README.md +++ b/README.md @@ -12,22 +12,41 @@ See [API reference](https://activitysmith.com/docs/api-reference/introduction). gem install activitysmith ``` -## Usage +## Setup ```ruby require "activitysmith" client = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) +``` + +You can also override the API host: + +```ruby +client = ActivitySmith::Client.new( + api_key: ENV.fetch("ACTIVITYSMITH_API_KEY"), + base_url: "https://activitysmith.com/api" +) +``` + +## Usage -client.notifications.send_push_notification( - push_notification_request: { +### Send a Push Notification + +```ruby +response = client.notifications.send_push_notification( + { title: "Build Failed", message: "CI pipeline failed on main branch" } ) +``` +### Start a Live Activity + +```ruby start = client.live_activities.start_live_activity( - live_activity_start_request: { + { content_state: { title: "Deploy", number_of_steps: 4, @@ -40,6 +59,47 @@ start = client.live_activities.start_live_activity( activity_id = start.activity_id ``` +### Update a Live Activity + +```ruby +update = client.live_activities.update_live_activity( + { + activity_id: activity_id, + content_state: { + title: "Deploy", + current_step: 3 + } + } +) +``` + +### End a Live Activity + +```ruby +finish = client.live_activities.end_live_activity( + { + activity_id: activity_id, + content_state: { + title: "Deploy Complete", + current_step: 4, + auto_dismiss_minutes: 3 + } + } +) +``` + +## Error Handling + +```ruby +begin + client.notifications.send_push_notification( + { title: "Build Failed" } + ) +rescue OpenapiClient::ApiError => e + puts "Request failed: #{e.code} #{e.message}" +end +``` + ## API Surface - `client.notifications`