Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 64 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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`
Expand Down