0.0
No commit activity in last 3 years
No release in over 3 years
Ruby client library for the Asterisk REST Interface (ARI)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0
>= 0

Runtime

 Project Readme

ARI

Gem Version Build Status

ARI is a Ruby client library for the Asterisk REST Interface (ARI)

Installation

Add this line to your application's Gemfile:

gem 'asterisk-ari', :require => 'ari'

And then execute:

$ bundle

Or install it yourself as:

$ gem install asterisk-ari

Usage

require 'ari'
# setup
client = ARI::Client.new({ :host => "localhost", :port => 8088, :username => "username", :password => "password" })
# specify prefix
# client = ARI::Client.new({ :host => "localhost", :port => 8088, :username => "username", :password => "password", :prefix => "asterisk" })

result = client.bridges_create({type: "mixing", bridgeId: "bridge_id", name: "bridge_name"})
# => {"id"=>"bridge_id", "creator"=>"Stasis", "technology"=>"simple_bridge", "bridge_type"=>"mixing", "bridge_class"=>"stasis", "name"=>"bridge_name", "channels"=>[]}

result = client.bridges_get result["id"]
# => {"id"=>"bridge_id", "creator"=>"Stasis", "technology"=>"simple_bridge", "bridge_type"=>"mixing", "bridge_class"=>"stasis", "name"=>"bridge_name", "channels"=>[]}

Check http://www.rubydoc.info/github/t-k/asterisk-ari-ruby/master/ARI/Client for other APIs.

Error handling

begin
  result = client.asterisk_set_global_var
rescue ARI::ServerError => e # handle 5xx request
  puts e.response_body
  puts e.error_info
rescue ARI::APIError => e # handle 4xx request
  puts e.response_body
  # => {"message":"Variable name is required"}
  puts e.error_info
  # {:http_status=>400, :body=>"{\"message\":\"Variable name is required\"}", :data=>{"message"=>"Variable name is required"}}
rescue
end

TODO