8000 GitHub - eb-gh-cr/unione-ruby: UniOne Email API Ruby gem
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

eb-gh-cr/unione-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unione-ruby

UniOne (unione.io) integration gem for Ruby

Examples of usage

Install

gem install unione-ruby

Working with API responses

This library using faraday gem for making HTTP queries along with mashify middleware for post-processing response body. So, you can use extended syntax for accessing response fields.

Example of work with responses:

require 'unione-ruby'
unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'])
response = unione.get_dns_records("example.com")
puts response.status
puts response.body.to_h
puts response.headers
# Access fields as hash or as methods
puts response.body['status']
puts response.body.status

By default authentication produced through X-API-KEY header. For passing API key in params use:

unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'], api_key_in_params: true)

Handling API errors

Library using `raise-error' middleware for handling error responses.

Example of work with errors:

require 'unione-ruby'
begin
  unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'])
  response = unione.get_dns_records("example.com")
  puts response.status
  puts response.body.to_h
  puts response.headers
rescue Faraday::Error => e
  # Note that exception response has internal format which is a little bit different and body field is not post-processed
  puts e.response[:status]
  puts e.response[:body]
  puts e.response[:headers]
end

About

UniOne Email API Ruby gem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%
0