plivo 0.3.19 → 4.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/AUTHORS.md +4 -0
- data/CHANGELOG.md +158 -0
- data/Gemfile +10 -0
- data/Jenkinsfile +7 -0
- data/LICENSE.txt +19 -0
- data/README.md +155 -24
- data/Rakefile +9 -0
- data/ci/config.yml +7 -0
- data/examples/conference_bridge.rb +108 -0
- data/examples/jwt.rb +32 -0
- data/examples/lookup.rb +24 -0
- data/examples/multi_party_call.rb +295 -0
- data/examples/phlos.rb +55 -0
- data/examples/regulatory_compliance.rb +167 -0
- data/lib/plivo/base/resource.rb +148 -0
- data/lib/plivo/base/resource_interface.rb +108 -0
- data/lib/plivo/base/response.rb +38 -0
- data/lib/plivo/base.rb +17 -0
- data/lib/plivo/base_client.rb +393 -0
- data/lib/plivo/exceptions.rb +50 -0
- data/lib/plivo/jwt.rb +120 -0
- data/lib/plivo/phlo_client.rb +29 -0
- data/lib/plivo/resources/accounts.rb +181 -0
- data/lib/plivo/resources/addresses.rb +302 -0
- data/lib/plivo/resources/applications.rb +258 -0
- data/lib/plivo/resources/call_feedback.rb +55 -0
- data/lib/plivo/resources/calls.rb +559 -0
- data/lib/plivo/resources/conferences.rb +367 -0
- data/lib/plivo/resources/endpoints.rb +132 -0
- data/lib/plivo/resources/identities.rb +319 -0
- data/lib/plivo/resources/lookup.rb +88 -0
- data/lib/plivo/resources/media.rb +97 -0
- data/lib/plivo/resources/messages.rb +215 -0
- data/lib/plivo/resources/multipartycalls.rb +554 -0
- data/lib/plivo/resources/nodes.rb +83 -0
- data/lib/plivo/resources/numbers.rb +319 -0
- data/lib/plivo/resources/phlo_member.rb +64 -0
- data/lib/plivo/resources/phlos.rb +55 -0
- data/lib/plivo/resources/powerpacks.rb +717 -0
- data/lib/plivo/resources/pricings.rb +43 -0
- data/lib/plivo/resources/recordings.rb +116 -0
- data/lib/plivo/resources/regulatory_compliance.rb +610 -0
- data/lib/plivo/resources.rb +25 -0
- data/lib/plivo/rest_client.rb +63 -0
- data/lib/plivo/utils.rb +294 -0
- data/lib/plivo/version.rb +3 -0
- data/lib/plivo/xml/break.rb +31 -0
- data/lib/plivo/xml/conference.rb +20 -0
- data/lib/plivo/xml/cont.rb +13 -0
- data/lib/plivo/xml/dial.rb +16 -0
- data/lib/plivo/xml/dtmf.rb +13 -0
- data/lib/plivo/xml/element.rb +106 -0
- data/lib/plivo/xml/emphasis.rb +17 -0
- data/lib/plivo/xml/get_digits.rb +15 -0
- data/lib/plivo/xml/get_input.rb +16 -0
- data/lib/plivo/xml/hangup.rb +12 -0
- data/lib/plivo/xml/lang.rb +29 -0
- data/lib/plivo/xml/message.rb +13 -0
- data/lib/plivo/xml/multipartycall.rb +188 -0
- data/lib/plivo/xml/number.rb +13 -0
- data/lib/plivo/xml/p.rb +12 -0
- data/lib/plivo/xml/phoneme.rb +20 -0
- data/lib/plivo/xml/play.rb +13 -0
- data/lib/plivo/xml/plivo_xml.rb +19 -0
- data/lib/plivo/xml/pre_answer.rb +12 -0
- data/lib/plivo/xml/prosody.rb +28 -0
- data/lib/plivo/xml/record.rb +17 -0
- data/lib/plivo/xml/redirect.rb +13 -0
- data/lib/plivo/xml/response.rb +21 -0
- data/lib/plivo/xml/s.rb +12 -0
- data/lib/plivo/xml/say_as.rb +24 -0
- data/lib/plivo/xml/speak.rb +28 -0
- data/lib/plivo/xml/sub.rb +16 -0
- data/lib/plivo/xml/user.rb +13 -0
- data/lib/plivo/xml/w.rb +17 -0
- data/lib/plivo/xml/wait.rb +12 -0
- data/lib/plivo/xml.rb +39 -0
- data/lib/plivo.rb +12 -815
- data/plivo.gemspec +44 -0
- metadata +181 -41
- data/ext/mkrf_conf.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6472d23802b39086fb94ce313553e668bd3f210b
|
4
|
+
data.tar.gz: b620b7efeb18cbd2680d5701ba1054e23a0e3874
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5bbacc139403864cf9ee636063d8eb9717a9b8b175a4265d08cdaa85c3813f678a97573940a2c8d90c15d364c535578932331b817b7278f96c0ccdaa6c81f2b
|
7
|
+
data.tar.gz: a2ec84374d288f88cba292e667193810f51c6565be8c5457ee8deb952eb1c6f160f62205fb5d85532dc0d542c3880fe4552d79eb20c63bf0afa0e97bf3c648ac
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/AUTHORS.md
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [4.20.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.20.0) (2021-08-04)
|
4
|
+
- Added continue speak XML element support.
|
5
|
+
|
6
|
+
## [4.19.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.19.0) (2021-07-19)
|
7
|
+
- Add support for Voice MultiPartyCall APIs (includes retry) and XML, validate voice UTs
|
8
|
+
|
9
|
+
## [4.18.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.18.0) (2021-07-13)
|
10
|
+
- Power pack ID has been included to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message).
|
11
|
+
- Support for filtering messages by Power pack ID has been added to the [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages).
|
12
|
+
|
13
|
+
## [4.17.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.17.1) (2021-06-18)
|
14
|
+
- **WARNING**: Remove total_count field from meta data for list MDR response
|
15
|
+
|
16
|
+
## [4.17.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.17.0) (2021-06-15)
|
17
|
+
- Added stir verification param as part of Get CDR and live call APIs response.
|
18
|
+
|
19
|
+
## [4.16.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.16.0) (2021-02-08)
|
20
|
+
- Add support for Regulatory Compliance APIs.
|
21
|
+
|
22
|
+
## [4.15.2](https://github.com/plivo/plivo-ruby/releases/tag/v4.15.2) (2021-01-27)
|
23
|
+
- Fix Call API resource - Set answer_method as Optional param.
|
24
|
+
|
25
|
+
## [4.15.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.15.1) (2021-01-06)
|
26
|
+
- Fix Search Phone Numbers API using City Attribute.
|
27
|
+
|
28
|
+
## [4.15.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.15.0) (2020-11-17)
|
29
|
+
- Add number_priority support for Powerpack API.
|
30
|
+
|
31
|
+
## [4.14.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.14.0) (2020-10-30)
|
32
|
+
- Change lookup API endpoint and response.
|
33
|
+
|
34
|
+
## [4.13.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.13.0) (2020-09-30)
|
35
|
+
- Add support for Lookup API
|
36
|
+
|
37
|
+
## [4.12.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.12.0) (2020-09-24)
|
38
|
+
- Add "public_uri" optional param support for Application API.
|
39
|
+
|
40
|
+
## [4.11.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.11.0) (2020-08-25)
|
41
|
+
- Add Powerpack for mms
|
42
|
+
|
43
|
+
## [4.10.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.10.0) (2020-09-04)
|
44
|
+
- Add ConferenceUuid & CallState for Get Details of a Call API
|
45
|
+
- Upgrade faraday & faraday_middleware dependencies
|
46
|
+
|
47
|
+
## [4.9.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.1) (2020-08-19)
|
48
|
+
- Internal changes in Phlo for MultiPartyCall component
|
49
|
+
|
50
|
+
## [4.9.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.0) (2020-07-23)
|
51
|
+
- Add retries to multiple regions for voice requests.
|
52
|
+
|
53
|
+
## [4.8.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.8.1) (2020-06-05)
|
54
|
+
- Fix Record a Conference API response.
|
55
|
+
|
56
|
+
## [4.8.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.8.0) (2020-05-28)
|
57
|
+
- Add JWT helper functions.
|
58
|
+
|
59
|
+
## [4.7.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.7.1) (2020-05-06)
|
60
|
+
- Fix Send MMS with existing media_ids.
|
61
|
+
|
62
|
+
## [4.7.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.7.0) (2020-04-29)
|
63
|
+
- Add V3 signature helper functions.
|
64
|
+
|
65
|
+
## [4.6.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.6.1) (2020-04-02)
|
66
|
+
- Add nil check for API requests.
|
67
|
+
|
68
|
+
## [4.6.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.6.0) (2020-03-31)
|
69
|
+
- Add application cascade delete support.
|
70
|
+
|
71
|
+
## [4.5.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.5.0) (2020-03-30)
|
72
|
+
- Add Tollfree support for Powerpack
|
73
|
+
|
74
|
+
## [4.4.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.4.0) (2020-03-27)
|
75
|
+
- Add post call quality feedback API support.
|
76
|
+
|
77
|
+
## [4.3.5](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.5) (2019-12-28)
|
78
|
+
- Add Media support
|
79
|
+
|
80
|
+
## [4.3.4](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.4) (2019-12-20)
|
81
|
+
- Add Powerpack support
|
82
|
+
|
83
|
+
## [4.3.3](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.3) (2019-12-04)
|
84
|
+
- Add MMS support
|
85
|
+
|
86
|
+
## [4.3.2](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.2) (2019-11-13)
|
87
|
+
- Add GetInput XML support
|
88
|
+
|
89
|
+
## [4.3.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.1) (2019-10-16)
|
90
|
+
- Add SSML support
|
91
|
+
|
92
|
+
## [4.3.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.0) (2019-03-12)
|
93
|
+
- Add PHLO support
|
94
|
+
- Add Multi-Party Call triggers
|
95
|
+
|
96
|
+
## [4.2-beta1](https://github.com/plivo/plivo-ruby/releases/tag/v4.2-beta1) (2019-03-11)
|
97
|
+
- Add PHLO support
|
98
|
+
- Add Multi-Party Call triggers
|
99
|
+
|
100
|
+
## [4.1.8](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.8) (2019-02-27)
|
101
|
+
- Fix log_incoming_messages having no effect while application creation
|
102
|
+
|
103
|
+
## [4.1.7](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.7) (2019-02-20)
|
104
|
+
- Fix responses for all API resources(responses were returning a hash).
|
105
|
+
|
106
|
+
## [4.1.6](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.6) (2018-11-26)
|
107
|
+
- Fix bignum deprecated warning in Ruby 2.4+.
|
108
|
+
|
109
|
+
## [4.1.5](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.5) (2018-11-21)
|
110
|
+
- Add hangup party details to CDR. CDR filtering allowed by hangup_source and hangup_cause_code.
|
111
|
+
- Add sub-account cascade delete support.
|
112
|
+
|
113
|
+
## [4.1.4](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.4) (2018-10-29)
|
114
|
+
- Add live calls filtering by from, to numbers and call_direction.
|
115
|
+
|
116
|
+
## [4.1.3](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.3) (2018-10-01)
|
117
|
+
- Added Trackable parameter in messages.
|
118
|
+
|
119
|
+
## [4.1.2](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.2) (2018-09-18)
|
120
|
+
- Added parent_call_uuid parameter to filter calls.
|
121
|
+
- Queued status added for filtering calls in queued status.
|
122
|
+
- Added log_incoming_messages parameter to application create and update.
|
123
|
+
|
124
|
+
## [4.1.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.1) (2018-08-08)
|
125
|
+
- Upgraded version of faraday_middleware to 0.12.2 which parses YAML safely
|
126
|
+
|
127
|
+
## [4.1.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.1.0) (2018-02-26)
|
128
|
+
- Add Address and Identity resources
|
129
|
+
- Change a few functions in number-related methods to support the verification flows
|
130
|
+
|
131
|
+
## [4.0.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.0.0) (2018-01-18)
|
132
|
+
- Now supports timeout & proxy (in a non-deprecated way) settings
|
133
|
+
- A bug fixed (#55)
|
134
|
+
|
135
|
+
## [4.0.0.beta.2](https://github.com/plivo/plivo-ruby/releases/tag/v4.0.0.beta.2) (2017-10-24)
|
136
|
+
- The new SDK works with Ruby >= 2. Tested against 2.0.0, 2.1, 2.2.0, 2.3.0, 2.4.0, 2.5-dev.
|
137
|
+
- JSON serialization and deserialization is now handled by the SDK
|
138
|
+
- The API interfaces are consistent and guessable
|
139
|
+
- Handles pagination automatically when listing all objects of a resource
|
140
|
+
|
141
|
+
## [v0.3.19](https://github.com/plivo/plivo-ruby/tree/v0.3.19) (2015-11-24)
|
142
|
+
- Add `modify_number` function
|
143
|
+
|
144
|
+
## [0.3.17](https://github.com/plivo/plivo-ruby/tree/v0.3.17) (2015-07-21)
|
145
|
+
- Add support for `digitsMatchBLeg` in Dial XML
|
146
|
+
- `stop_speak_member` function added
|
147
|
+
|
148
|
+
## Other changes
|
149
|
+
- 2013-10-23 Added `stop_speak()`
|
150
|
+
- 2013-09-25 Added `relayDTMF` to `<Conference>` and `async` to `<DTMF>`
|
151
|
+
- 2013-08-17 Fix unicode characters only for speak element.
|
152
|
+
- 2013-08-12 Fix unicode characters only for speak APIs.
|
153
|
+
- 2013-07-26 Added `XPlivoSignature` header validation.
|
154
|
+
- 2013-07-21 Added outgoing carrier and carrier routing apis.
|
155
|
+
- 2013-07-20 Added `recordWhenAlone` to `<Conference>`.
|
156
|
+
- 2013-07-14 Unicode character support in XML and API.
|
157
|
+
- 2013-03-15 Added `min_silence` to `<Wait>`.
|
158
|
+
- 2013-02-23 Pricing API added.
|
data/Gemfile
ADDED
data/Jenkinsfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2018, Plivo Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,48 +1,179 @@
|
|
1
|
-
#
|
1
|
+
# plivo-ruby
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![Dependency Status](https://gemnasium.com/plivo/plivo-ruby.png)](https://gemnasium.com/plivo/plivo-ruby)
|
3
|
+
[![Build Status](https://travis-ci.org/plivo/plivo-ruby.svg?branch=4.0)](https://travis-ci.org/plivo/plivo-ruby)
|
5
4
|
|
6
|
-
|
5
|
+
The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby applications using the Plivo REST API. Using the SDK, you will be able to make voice calls, send SMS and generate Plivo XML to control your call flows.
|
7
6
|
|
8
|
-
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
9
|
|
10
|
-
|
10
|
+
```ruby
|
11
|
+
gem 'plivo', '>= 4.20.0'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install plivo
|
21
|
+
|
22
|
+
For features in beta, use the beta branch:
|
23
|
+
|
24
|
+
$ gem install plivo --pre
|
25
|
+
|
26
|
+
If you have the `0.3.19` version (a.k.a legacy) already installed, you may have to first uninstall it before installing the new version.
|
27
|
+
|
28
|
+
## Getting started
|
29
|
+
|
30
|
+
### Authentication
|
31
|
+
To make the API requests, you need to create a `RestClient` and provide it with authentication credentials (which can be found at [https://console.plivo.com/dashboard/](https://console.plivo.com/dashboard/)).
|
32
|
+
|
33
|
+
We recommend that you store your credentials in the `PLIVO_AUTH_ID` and the `PLIVO_AUTH_TOKEN` environment variables, so as to avoid the possibility of accidentally committing them to source control. If you do this, you can initialise the client with no arguments and it will automatically fetch them from the environment variables:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
client = RestClient.new;
|
37
|
+
```
|
38
|
+
|
39
|
+
Alternatively, you can specifiy the authentication credentials while initializing the `RestClient`.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
client = RestClient.new('your_auth_id', 'your_auth_token');
|
43
|
+
```
|
44
|
+
|
45
|
+
### The basics
|
46
|
+
The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
client.resources.create(params); # Create
|
50
|
+
client.resources.get(resource_identifier); # Get
|
51
|
+
client.resources.update(resource_identifier, params); # Update
|
52
|
+
client.resources.delete(resource_identifier); # Delete
|
53
|
+
client.resources.list; # List all resources, max 20 at a time
|
54
|
+
```
|
55
|
+
|
56
|
+
You can also use the `resource` directly to update and delete it. For example,
|
11
57
|
|
58
|
+
```ruby
|
59
|
+
resource = client.resources.get(resource_identifier);
|
60
|
+
resource.update(params); # update the resource
|
61
|
+
resource.delete(); # Delete the resource
|
62
|
+
```
|
63
|
+
|
64
|
+
Also, using `client.resources.list` would list the first 20 resources by default (which is the first page, with `limit` as 20, and `offset` as 0). To get more, you will have to use `limit` and `offset` to get the second page of resources.
|
65
|
+
|
66
|
+
To list all resources, you can simply use the following pattern that will handle the pagination for you automatically, so you won't have to worry about passing the right `limit` and `offset` values.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
client.resources.each do |resource|
|
70
|
+
puts resource.id
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
## Examples
|
75
|
+
|
76
|
+
### Send a message
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
require 'rubygems'
|
80
|
+
require 'plivo'
|
81
|
+
|
82
|
+
include Plivo
|
83
|
+
|
84
|
+
client = RestClient.new
|
85
|
+
message_created = client.messages.create(
|
86
|
+
'your_source_number',
|
87
|
+
%w[your_destination_number_1 your_destination_number_2],
|
88
|
+
'Hello, world!'
|
89
|
+
)
|
90
|
+
```
|
91
|
+
|
92
|
+
### Make a call
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
require 'rubygems'
|
96
|
+
require 'plivo'
|
97
|
+
|
98
|
+
include Plivo
|
99
|
+
|
100
|
+
client = RestClient.new
|
101
|
+
call_made = client.calls.create(
|
102
|
+
'your_source_number',
|
103
|
+
['your_destination_number'],
|
104
|
+
'https://answer.url'
|
105
|
+
)
|
106
|
+
```
|
12
107
|
|
13
|
-
|
108
|
+
### Lookup a number
|
14
109
|
|
15
|
-
|
110
|
+
```ruby
|
111
|
+
require 'rubygems'
|
112
|
+
require 'plivo'
|
16
113
|
|
114
|
+
include Plivo
|
17
115
|
|
18
|
-
|
116
|
+
client = RestClient.new
|
117
|
+
resp = client.lookup.get('<number-here>')
|
118
|
+
```
|
19
119
|
|
20
|
-
|
120
|
+
### Generate Plivo XML
|
21
121
|
|
22
|
-
|
23
|
-
|
122
|
+
```ruby
|
123
|
+
require 'rubygems'
|
124
|
+
require 'plivo'
|
24
125
|
|
25
|
-
|
126
|
+
include Plivo::XML
|
26
127
|
|
27
|
-
|
128
|
+
response = Response.new
|
129
|
+
response.addSpeak('Hello, world!')
|
130
|
+
puts response.to_xml # Prints the XML string
|
28
131
|
|
132
|
+
xml_response = PlivoXML.new(response)
|
133
|
+
puts xml_response.to_xml # Prints XML along with XML version & encoding details
|
29
134
|
```
|
30
|
-
|
31
|
-
|
32
|
-
|
135
|
+
This generates the following XML:
|
136
|
+
|
137
|
+
```xml
|
138
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
139
|
+
<Response>
|
140
|
+
<Speak>Hello, world!</Speak>
|
141
|
+
</Response>
|
33
142
|
```
|
34
143
|
|
35
|
-
|
144
|
+
### Run a PHLO
|
36
145
|
|
37
|
-
|
146
|
+
```ruby
|
147
|
+
require 'rubygems'
|
148
|
+
require 'plivo'
|
38
149
|
|
39
|
-
|
150
|
+
include Plivo
|
40
151
|
|
41
|
-
|
152
|
+
AUTH_ID = 'AUTH_ID'
|
153
|
+
AUTH_TOKEN = 'AUTH_TOKEN'
|
42
154
|
|
43
|
-
|
155
|
+
client = Phlo.new(AUTH_ID, AUTH_TOKEN)
|
44
156
|
|
45
|
-
#
|
157
|
+
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
|
158
|
+
# then initialize client as:
|
159
|
+
# client = Phlo.new
|
160
|
+
|
161
|
+
# run a phlo:
|
162
|
+
begin
|
163
|
+
#parameters set in PHLO - params
|
164
|
+
params = {
|
165
|
+
from: '9999999999',
|
166
|
+
to: '0000000000'
|
167
|
+
}
|
168
|
+
response = phlo.run(params)
|
169
|
+
puts response
|
170
|
+
rescue PlivoRESTError => e
|
171
|
+
puts 'Exception: ' + e.message
|
172
|
+
end
|
173
|
+
```
|
46
174
|
|
175
|
+
### More examples
|
176
|
+
Refer to the [Ruby API Reference](https://api-reference.plivo.com/latest/ruby/introduction/overview) for more examples. Also refer to the [guide to setting up dev environment](https://developers.plivo.com/getting-started/setting-up-dev-environment/) on [Plivo Developers Portal](https://developers.plivo.com) to setup a Sinatra server & use it to test out your integration in under 5 minutes.
|
47
177
|
|
48
|
-
|
178
|
+
## Reporting issues
|
179
|
+
Report any feedback or problems with this version by [opening an issue on Github](https://github.com/plivo/plivo-ruby/issues).
|
data/Rakefile
ADDED
data/ci/config.yml
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'plivo'
|
3
|
+
|
4
|
+
include Plivo
|
5
|
+
|
6
|
+
AUTH_ID = 'AUTH_ID'
|
7
|
+
AUTH_TOKEN = 'AUTH_TOKEN'
|
8
|
+
|
9
|
+
client = Phlo.new(AUTH_ID, AUTH_TOKEN)
|
10
|
+
|
11
|
+
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
|
12
|
+
# then initialize client as:
|
13
|
+
# client = Phlo.new
|
14
|
+
#
|
15
|
+
|
16
|
+
# provide the phlo_id in params
|
17
|
+
begin
|
18
|
+
phlo = client.phlo.get('11a5f5cf-b6cd-419b-8ada-e41ef073de74')
|
19
|
+
conference_bridge = phlo.conference_bridge('b24d49ea-fb62-4612-9d98-4565c67f0bdc')
|
20
|
+
puts conference_bridge
|
21
|
+
rescue PlivoRESTError => e
|
22
|
+
puts 'Exception: ' + e.message
|
23
|
+
end
|
24
|
+
|
25
|
+
# Response:
|
26
|
+
# {
|
27
|
+
# "api_id"=>"1bcee5a2-f2db-47c3-b424-49f09bc9c62a",
|
28
|
+
# "node_id"=>"b24d49ea-fb62-4612-9d98-4565c67f0bdc",
|
29
|
+
# "phlo_id"=>"11a5f5cf-b6cd-419b-8ada-e41ef073de74",
|
30
|
+
# "name"=>"Conference_1",
|
31
|
+
# "node_type"=>"conference",
|
32
|
+
# "created_on"=>"2018-12-04 13:51:22.796041+00:00"
|
33
|
+
# }
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# 1. member leaves the call [HANGUP]:
|
38
|
+
#
|
39
|
+
# member_address => phone number of the member
|
40
|
+
#
|
41
|
+
# conference_bridge.member(<member_address>).hangup
|
42
|
+
|
43
|
+
begin
|
44
|
+
response = conference_bridge.member('0000000000').hangup
|
45
|
+
puts response
|
46
|
+
rescue PlivoRESTError => e
|
47
|
+
puts 'Exception: ' + e.message
|
48
|
+
end
|
49
|
+
|
50
|
+
# Response:
|
51
|
+
# {
|
52
|
+
# "api_id"=>"1bcee5a2-f2db-47c3-b424-49f09bc9c62a",
|
53
|
+
# "node_id"=>"b24d49ea-fb62-4612-9d98-4565c67f0bdc",
|
54
|
+
# "phlo_id"=>"11a5f5cf-b6cd-419b-8ada-e41ef073de74",
|
55
|
+
# "member_address"=>"0000000000",
|
56
|
+
# "node_type"=>"conference",
|
57
|
+
# "created_on"=>"2018-12-04 13:51:22.796041+00:00"
|
58
|
+
# }
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
# 2. Mute a member in the conference bridge:
|
63
|
+
#
|
64
|
+
# member_address => phone number of the member
|
65
|
+
#
|
66
|
+
# conference_bridge.member(<member_address>).mute
|
67
|
+
|
68
|
+
begin
|
69
|
+
response = conference_bridge.member('0000000000').mute
|
70
|
+
puts response
|
71
|
+
rescue PlivoRESTError => e
|
72
|
+
puts 'Exception: ' + e.message
|
73
|
+
end
|
74
|
+
|
75
|
+
# Response:
|
76
|
+
# {
|
77
|
+
# "api_id"=>"1bcee5a2-f2db-47c3-b424-49f09bc9c62a",
|
78
|
+
# "node_id"=>"b24d49ea-fb62-4612-9d98-4565c67f0bdc",
|
79
|
+
# "phlo_id"=>"11a5f5cf-b6cd-419b-8ada-e41ef073de74",
|
80
|
+
# "member_address"=>"0000000000",
|
81
|
+
# "node_type"=>"conference",
|
82
|
+
# "created_on"=>"2018-12-04 13:51:22.796041+00:00"
|
83
|
+
# }
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
# 3. Unmute a member in the conference bridge:
|
88
|
+
#
|
89
|
+
# member_address => phone number of the member
|
90
|
+
#
|
91
|
+
# conference_bridge.member(<member_address>).unmute
|
92
|
+
|
93
|
+
begin
|
94
|
+
response = conference_bridge.member('0000000000').unmute
|
95
|
+
puts response
|
96
|
+
rescue PlivoRESTError => e
|
97
|
+
puts 'Exception: ' + e.message
|
98
|
+
end
|
99
|
+
|
100
|
+
# Response:
|
101
|
+
# {
|
102
|
+
# "api_id"=>"1bcee5a2-f2db-47c3-b424-49f09bc9c62a",
|
103
|
+
# "node_id"=>"b24d49ea-fb62-4612-9d98-4565c67f0bdc",
|
104
|
+
# "phlo_id"=>"11a5f5cf-b6cd-419b-8ada-e41ef073de74",
|
105
|
+
# "member_address"=>"0000000000",
|
106
|
+
# "node_type"=>"conference",
|
107
|
+
# "created_on"=>"2018-12-04 13:51:22.796041+00:00"
|
108
|
+
# }
|
data/examples/jwt.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'plivo'
|
3
|
+
|
4
|
+
include Plivo
|
5
|
+
|
6
|
+
AUTH_ID = 'MADADADADADADADADADA'
|
7
|
+
AUTH_TOKEN = 'AUTH_TOKEN'
|
8
|
+
|
9
|
+
begin
|
10
|
+
acctkn = Plivo::Token::AccessToken.new(
|
11
|
+
AUTH_ID,
|
12
|
+
AUTH_TOKEN,
|
13
|
+
'{username}',
|
14
|
+
'{uid}'
|
15
|
+
)
|
16
|
+
# update token validity (from, lifetime)
|
17
|
+
acctkn.update_validity(Time.now, 300)
|
18
|
+
# add voice grants (incoming, outgoing)
|
19
|
+
acctkn.add_voice_grants(Plivo::Token::VoiceGrants.new(true, true))
|
20
|
+
puts acctkn.to_jwt
|
21
|
+
|
22
|
+
# update token validity (from, nil, till)
|
23
|
+
acctkn.update_validity(Time.now, nil, Time.now + 300)
|
24
|
+
# add voice grants (incoming, outgoing)
|
25
|
+
acctkn.add_voice_grants(Plivo::Token::VoiceGrants.new(true, true))
|
26
|
+
puts acctkn.to_jwt
|
27
|
+
rescue ValidationError => e
|
28
|
+
puts 'Exception: ' + e.message
|
29
|
+
end
|
30
|
+
|
31
|
+
# Sample Response:
|
32
|
+
#
|
data/examples/lookup.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "plivo"
|
3
|
+
|
4
|
+
include Plivo
|
5
|
+
include Plivo::Exceptions
|
6
|
+
|
7
|
+
AUTH_ID = ""
|
8
|
+
AUTH_TOKEN = ""
|
9
|
+
|
10
|
+
client = RestClient.new(AUTH_ID, AUTH_TOKEN)
|
11
|
+
|
12
|
+
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
|
13
|
+
# then initialize client as:
|
14
|
+
# client = RestClient.new
|
15
|
+
|
16
|
+
begin
|
17
|
+
resp = client.lookup.get(
|
18
|
+
"<insert-number-here>",
|
19
|
+
"carrier"
|
20
|
+
)
|
21
|
+
puts resp
|
22
|
+
rescue PlivoRESTError => e
|
23
|
+
puts "Exception: " + e.message
|
24
|
+
end
|