API Alerts • Ruby Client

Gem License: MIT

RubyGemsGitHubAPI Alerts

Effortless project notifications. Send once, deliver everywhere.

Installation

gem 'apialerts'

Or install directly:

gem install apialerts

Quick Start

require 'apialerts'

ApiAlerts.configure('your-api-key')
ApiAlerts.send(ApiAlerts::Event.new(message: 'Deploy complete'))

Usage

Call configure once at startup, then use send / send_async anywhere.

require 'apialerts'

ApiAlerts.configure('your-api-key')

# Fire-and-forget - never raises
ApiAlerts.send(ApiAlerts::Event.new(message: 'Deploy complete'))

# Or get the result back
result = ApiAlerts.send_async(ApiAlerts::Event.new(message: 'Deploy complete'))
if result.success?
  puts "Sent to #{result.workspace} (#{result.channel})"
else
  puts "Error: #{result.error}"
end

Event fields

Only message is required. All other fields are optional.

Field Type Required Description
message String Yes Main notification message
channel String No Target channel name
event String No Event key for routing
title String No Short title
tags Array No Categorisation tags
link String No URL associated with the event (deeplink + CTA)
data Hash No Arbitrary key-value metadata
event = ApiAlerts::Event.new(
  message: 'Deploy complete',
  channel: 'releases',
  event:   'ci.deploy',
  title:   'Deployed',
  tags:    ['CI/CD', 'Ruby'],
  link:    'https://github.com/apialerts/apialerts-ruby/actions',
  data:    { commit: 'a1b2c3d' }
)

Send to a different workspace

Pass an optional api_key: to override the configured key for a single call.

ApiAlerts.send(event, api_key: 'other-workspace-key')

result = ApiAlerts.send_async(event, api_key: 'other-workspace-key')

Instance client

Construct ApiAlerts::Client directly when you need multiple clients (for example one per workspace) or prefer dependency injection over the global singleton. It exposes the same send / send_async methods.

client = ApiAlerts::Client.new('your-api-key')

client.send(ApiAlerts::Event.new(message: 'Deploy complete'))

result = client.send_async(ApiAlerts::Event.new(message: 'Deploy complete'))

SendResult fields

send_async always returns a SendResult - it never raises.

Field Type Description
success? Boolean Whether the event was delivered successfully
workspace String Workspace the event was delivered to
channel String Channel the event was delivered to
warnings Array Non-fatal warnings returned by the API
error String Error message when success? is false