Ruby SDK
The official Zyphr SDK for Ruby, built with Faraday.
Installation
Gemfile
gem 'zyphr', '~> 0.1.0'
Manual
gem install zyphr
Quick Start
require 'zyphr'
Zyphr.configure do |config|
config.api_key['X-API-Key'] = 'zy_live_xxx'
end
emails_api = Zyphr::EmailsApi.new
result = emails_api.send_email(
Zyphr::SendEmailRequest.new(
to: 'user@example.com',
subject: 'Welcome!',
html: '<h1>Hello!</h1>'
)
)
puts "Email sent: #{result.id}"
Configuration
Zyphr.configure do |config|
config.api_key['X-API-Key'] = ENV['ZYPHR_API_KEY']
config.host = 'https://api.zyphr.dev/v1' # Optional custom endpoint
end
Send Push Notification
push_api = Zyphr::PushApi.new
push_api.send_push(
Zyphr::SendPushRequest.new(
user_id: 'user_123',
title: 'New Message',
body: 'You have a new message'
)
)
Send SMS
sms_api = Zyphr::SmsApi.new
result = sms_api.send_sms(
Zyphr::SendSmsRequest.new(
to: '+14155551234',
body: 'Your verification code is 123456'
)
)
Error Handling
begin
emails_api.send_email(request)
rescue Zyphr::ApiError => e
puts "API Error (#{e.code}): #{e.message}"
puts "Response: #{e.response_body}"
end
Requirements
- Ruby 3.0+
- Faraday 2.x