Ruby
Official Ruby gem for the Zernio API. Install zernio-sdk and publish to 14+ social platforms with typed models.
The official Ruby gem for the Zernio API.
- Gem:
zernio-sdkon RubyGems - Source: github.com/zernio-dev/zernio-ruby
Install
gem install zernio-sdkOr add it to your Gemfile:
gem "zernio-sdk"Quick start
Configure your Bearer API key once, then instantiate the API class you need:
require 'zernio-sdk'
Zernio.configure do |config|
config.access_token = ENV['ZERNIO_API_KEY']
end
api = Zernio::PostsApi.new
request = Zernio::CreatePostRequest.new(
content: 'Hello world from Zernio!',
platforms: [
Zernio::CreatePostRequestPlatformsInner.new(platform: 'twitter', account_id: 'acc_xxx'),
Zernio::CreatePostRequestPlatformsInner.new(platform: 'linkedin', account_id: 'acc_yyy'),
],
publish_now: true
)
begin
result = api.create_post(request)
p result
rescue Zernio::ApiError => e
puts "Error when calling PostsApi->create_post: #{e}"
endGet your API key from the dashboard, or see Getting started for the full setup walkthrough.
For safe retries, create_post accepts an idempotency key: api.create_post(request, x_request_id: SecureRandom.uuid). Requests that reuse the same ID within ~5 minutes return the original post instead of double-posting.
List connected accounts
accounts_api = Zernio::AccountsApi.new
result = accounts_api.list_accounts
p resultResponse metadata
Every method has a _with_http_info variant that also returns the status code and headers:
data, status_code, headers = api.create_post_with_http_info(request)
p status_code # => 2xx
p data # => <PostCreateResponse>Error handling
API failures raise Zernio::ApiError, which carries the HTTP status and response body:
begin
api.create_post(request)
rescue Zernio::ApiError => e
puts "Status: #{e.code}"
puts "Body: #{e.response_body}"
endSee the error handling guide for the API's error codes and retry semantics.
Full reference
The gem exposes every API namespace as a class: Zernio::PostsApi, Zernio::AccountsApi, Zernio::ProfilesApi, Zernio::AnalyticsApi, Zernio::QueueApi, Zernio::MediaApi, Zernio::WebhooksApi, Zernio::AdsApi, Zernio::PhoneNumbersApi, Zernio::WhatsAppApi, Zernio::WorkflowsApi, and more. Each method maps 1:1 to an API Reference operation.