Ruby helper

The Plivo Ruby helper simplifies the process of making Plivo API Calls and generating Plivo XML.

Prerequisites

  1. Ruby >= 1.8
  2. Gem

Installation

Run the following command for a quick installation of the helper

gem install plivo

Manual Installation

Go to the Plivo-Ruby Github Repository to install the helper manually or run the following commands:

$ git clone git://github.com/plivo/plivo-ruby.git
$ rake gem
$ gem install pkg/plivo

Using the library

Getting started with the Plivo API couldn’t be easier.

Initializing PlivoRestApi

AUTH_ID = "Your_AUTH_ID"
AUTH_TOKEN = "Your_AUTH_TOKEN"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

Send an SMS

The snippet below shows how you can send an sms.

params = {
    'src' => '1111111111',
    'dst' => '2222222222',
    'text' => 'Hello, how are you?'
}
response = p.send_message(params)

Check out this Getting Started page or the full Message API documentation for more details.

Make an Outbound Phone Call

You can make outbound phone calls to landlines, mobiles, and SIP endpoints (e.g., softphones), in any of our 200+ coverage countries

params = {
    'to' => '2222222222',
    'from' => '1111111111',
    'answer_url' => 'https://s3.amazonaws.com/static.plivo.com/answer.xml',
    'answer_method' => 'GET'
}
response = p.make_call(params)

Check out this Getting Started page or the full Call API documentation for more details.

Methods

Below are all the methods that are present in RestApi class.

Account API

Method Description Mandatory Parameters
get_account() Get details of the account -
modify_account(parameters) Edit details of the account -
get_subaccounts(parameters) Get details of all subaccounts subauth_id
get_subaccount(parameters) Get details of a single subaccount -
create_subaccount(parameters) Create a new subaccount name
modify_subaccount(parameters) Edit details of a subaccount name
delete_subaccount(parameters) Delete a subaccount subauth_id

Application API

Method Description Mandatory Parameters
get_application() Get details of an application app_id
modify_application(parameters) Edit details of an application app_id
get_applications(parameters) Get details of all applications -
create_application(parameters) Create a new application app_name, answer_url
delete_application(parameters) Delete an application app_id

Call API

Method Description Mandatory Parameters
make_call(parameters) Make an outbound call from, to, answer_url
get_cdr(parameters) Get details of a single call record_id
get_cdrs(parameters) Get details of all calls -
get_live_call(parameters) Get details of a single live call call_uuid
get_live_calls() Get details of all live calls  
hangup_call(parameters) Hangup a single call call_uuid
hangup_all_calls() Hangup all calls -
transfer_call(parameters) Transfer a call call_uuid
record(parameters) Start recording a call call_uuid
stop_record(parameters) Stop recording a call call_uuid
play(parameters) Start playing music on a call call_uuid, urls
stop_play(parameters) Stop playing music on a call call_uuid
speak(parameters) Start playing a message on a call call_uuid, text
stop_speak(parameters) Stop playing a message on a call call_uuid
send_digits(parameters) Send digits on a call call_uuid, digits
hangup_request(parameters) Hangup a call request request_uuid

Conference API

Method Description Mandatory Parameters
get_live_conferences() Get details of all live conference -
hangup_all_conferences() Hangup all conferences -
get_live_conference(parameters) Get details of a single live conferenece conference_name
hangup_conference(parameters) Hangup a single conference conference_name
hangup_member(parameters) Hangup a single member in a conference member_id
play_member(parameters) Play music to a member in a conference member_id, url
stop_play_member(parameters) Stop playing music to a member in a conference member_id
speak_member(parameters) Play a message to a Member in a conference member_id, text
stop_speak_member(parameters) Stop playing message to a member in a conference member_id
deaf_member(parameters) Deaf a Member in a conference member_id
undeaf_member(parameters) Undeaf a Member in a conference member_id
mute_member(parameters) Mute a member in a conference -
unmute_member(parameters) Unmute a member in a conference -
kick_member(parameters) Kick a Member out of a conference member_id
record_conference(parameters) Start recording a conference conference_name
stop_record_conference(parameters) Stop recording a conference conference_name

Endpoint API

Method Description Mandatory Parameters
get_endpoint(parameters) Get details of an endpoint endpoint_id
modify_endpoint(parameters) Edit details of an endpoint endpoint_id
get_endpoints(parameters) Get details of all endpoints -
create_endpoint(parameters) Create a new endpoint username, password, alias
delete_endpoint(parameters) Delete an endpoint endpoint_id

Message API

Method Description Mandatory Parameters
send_message(parameters) Send an outbound SMS src, dst, text
get_message(parameters) Get details of a single message message_uuid
get_messages(parameters) Get details of all messages -

Number & PhoneNumber API

Method Description Mandatory Parameters
get_numbers(parameters) Get Details of all numbers -
get_number(parameters) Get Details of a sigle number number
modify_number(parameters) Edit details of a single number number
unrent_number(parameters) Unrent a number number
link_application_number(parameters) Link an application to a number number, app_id
unlink_application_number(parameters) Unlink an application from a number number
search_phone_numbers(parameters) Search for phone numbers country_iso
buy_phone_number(parameters) Rent a new number number

Pricing API

Method Description Mandatory Parameters
pricing(parameters) Get Pricing details for a specific country country_iso

Recording API

Method Description Mandatory Parameters
get_recordings(parameters) Get Details of all recordings -
get_recording(parameters) Get Details of a single recordings recording_id
delete_recording(parameters) Delete a sinlge recording recording_id

Examples

Take a look at the Ruby examples on GitHub.

API References

  1. Account API
  2. Application API
  3. Call API
  4. Conference API
  5. Endpoint API
  6. Message API
  7. Number API
  8. PhoneNumber API
  9. Pricing API
  10. Recording API

Reporting Issues

Please report issues or submit patches using the Github Issue Tracker or Customer Support.

License

The Plivo Ruby Helper Library is written by the Plivo Team and distributed under the MIT License.