plivo 0.3.19 → 4.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +11 -0
  5. data/AUTHORS.md +4 -0
  6. data/CHANGELOG.md +158 -0
  7. data/Gemfile +10 -0
  8. data/Jenkinsfile +7 -0
  9. data/LICENSE.txt +19 -0
  10. data/README.md +155 -24
  11. data/Rakefile +9 -0
  12. data/ci/config.yml +7 -0
  13. data/examples/conference_bridge.rb +108 -0
  14. data/examples/jwt.rb +32 -0
  15. data/examples/lookup.rb +24 -0
  16. data/examples/multi_party_call.rb +295 -0
  17. data/examples/phlos.rb +55 -0
  18. data/examples/regulatory_compliance.rb +167 -0
  19. data/lib/plivo/base/resource.rb +148 -0
  20. data/lib/plivo/base/resource_interface.rb +108 -0
  21. data/lib/plivo/base/response.rb +38 -0
  22. data/lib/plivo/base.rb +17 -0
  23. data/lib/plivo/base_client.rb +393 -0
  24. data/lib/plivo/exceptions.rb +50 -0
  25. data/lib/plivo/jwt.rb +120 -0
  26. data/lib/plivo/phlo_client.rb +29 -0
  27. data/lib/plivo/resources/accounts.rb +181 -0
  28. data/lib/plivo/resources/addresses.rb +302 -0
  29. data/lib/plivo/resources/applications.rb +258 -0
  30. data/lib/plivo/resources/call_feedback.rb +55 -0
  31. data/lib/plivo/resources/calls.rb +559 -0
  32. data/lib/plivo/resources/conferences.rb +367 -0
  33. data/lib/plivo/resources/endpoints.rb +132 -0
  34. data/lib/plivo/resources/identities.rb +319 -0
  35. data/lib/plivo/resources/lookup.rb +88 -0
  36. data/lib/plivo/resources/media.rb +97 -0
  37. data/lib/plivo/resources/messages.rb +215 -0
  38. data/lib/plivo/resources/multipartycalls.rb +554 -0
  39. data/lib/plivo/resources/nodes.rb +83 -0
  40. data/lib/plivo/resources/numbers.rb +319 -0
  41. data/lib/plivo/resources/phlo_member.rb +64 -0
  42. data/lib/plivo/resources/phlos.rb +55 -0
  43. data/lib/plivo/resources/powerpacks.rb +717 -0
  44. data/lib/plivo/resources/pricings.rb +43 -0
  45. data/lib/plivo/resources/recordings.rb +116 -0
  46. data/lib/plivo/resources/regulatory_compliance.rb +610 -0
  47. data/lib/plivo/resources.rb +25 -0
  48. data/lib/plivo/rest_client.rb +63 -0
  49. data/lib/plivo/utils.rb +294 -0
  50. data/lib/plivo/version.rb +3 -0
  51. data/lib/plivo/xml/break.rb +31 -0
  52. data/lib/plivo/xml/conference.rb +20 -0
  53. data/lib/plivo/xml/cont.rb +13 -0
  54. data/lib/plivo/xml/dial.rb +16 -0
  55. data/lib/plivo/xml/dtmf.rb +13 -0
  56. data/lib/plivo/xml/element.rb +106 -0
  57. data/lib/plivo/xml/emphasis.rb +17 -0
  58. data/lib/plivo/xml/get_digits.rb +15 -0
  59. data/lib/plivo/xml/get_input.rb +16 -0
  60. data/lib/plivo/xml/hangup.rb +12 -0
  61. data/lib/plivo/xml/lang.rb +29 -0
  62. data/lib/plivo/xml/message.rb +13 -0
  63. data/lib/plivo/xml/multipartycall.rb +188 -0
  64. data/lib/plivo/xml/number.rb +13 -0
  65. data/lib/plivo/xml/p.rb +12 -0
  66. data/lib/plivo/xml/phoneme.rb +20 -0
  67. data/lib/plivo/xml/play.rb +13 -0
  68. data/lib/plivo/xml/plivo_xml.rb +19 -0
  69. data/lib/plivo/xml/pre_answer.rb +12 -0
  70. data/lib/plivo/xml/prosody.rb +28 -0
  71. data/lib/plivo/xml/record.rb +17 -0
  72. data/lib/plivo/xml/redirect.rb +13 -0
  73. data/lib/plivo/xml/response.rb +21 -0
  74. data/lib/plivo/xml/s.rb +12 -0
  75. data/lib/plivo/xml/say_as.rb +24 -0
  76. data/lib/plivo/xml/speak.rb +28 -0
  77. data/lib/plivo/xml/sub.rb +16 -0
  78. data/lib/plivo/xml/user.rb +13 -0
  79. data/lib/plivo/xml/w.rb +17 -0
  80. data/lib/plivo/xml/wait.rb +12 -0
  81. data/lib/plivo/xml.rb +39 -0
  82. data/lib/plivo.rb +12 -815
  83. data/plivo.gemspec +44 -0
  84. metadata +181 -41
  85. data/ext/mkrf_conf.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69f17b3110741fa96e01482d33428105adf80494
4
- data.tar.gz: 523a1d10dcd6460ead4d1211f6c068a3a3e6e53c
3
+ metadata.gz: 6472d23802b39086fb94ce313553e668bd3f210b
4
+ data.tar.gz: b620b7efeb18cbd2680d5701ba1054e23a0e3874
5
5
  SHA512:
6
- metadata.gz: c97730771de4bb3abdfd55d8c5e3705455ae059d57e4f976a4a35c86abdb02eb401b061c45d1bd045ff87d21bbaa16b6956326cafc635e44d19c8e6e0e8cdf39
7
- data.tar.gz: 063f82c22953e7fa294a1b9bec40b7eeb39dc13e51b3f1eaaeb5b492d51b88abc153d166ac8bad59b910397e0105c45261c1e07a7b0abb9c7d06c7e34b1984a5
6
+ metadata.gz: c5bbacc139403864cf9ee636063d8eb9717a9b8b175a4265d08cdaa85c3813f678a97573940a2c8d90c15d364c535578932331b817b7278f96c0ccdaa6c81f2b
7
+ data.tar.gz: a2ec84374d288f88cba292e667193810f51c6565be8c5457ee8deb952eb1c6f160f62205fb5d85532dc0d542c3880fe4552d79eb20c63bf0afa0e97bf3c648ac
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ .idea/
2
+ .DS_STORE
3
+ .bundle/
4
+ .yardoc
5
+ Gemfile.lock
6
+ _yardoc/
7
+ coverage/
8
+ pkg/
9
+ doc/
10
+ spec/reports/
11
+ tmp/
12
+ bin/
13
+ # rspec failure tracking
14
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ bundler_args: --without development
5
+ rvm:
6
+ - ruby-head
7
+ - 2.4.0
8
+ - 2.3.0
9
+ - 2.2.0
10
+ - 2.1
11
+ - 2.0.0
data/AUTHORS.md ADDED
@@ -0,0 +1,4 @@
1
+ # Authors
2
+ - [Sreyantha Chary](https://sreyanth.com?ref=github/plivo-python) ([@sreyanth](https://github.com/sreyanth))
3
+ - Kritarth ([@kritarth3010](https://github.com/kritarth3010))
4
+ - Abhishek ([@abhishek-plivo](https://github.com/abhishek-plivo))
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
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rake', '~> 10.1'
7
+ gem 'rspec', '~> 3.0'
8
+ gem 'simplecov'
9
+ gem 'json'
10
+ end
data/Jenkinsfile ADDED
@@ -0,0 +1,7 @@
1
+ #!groovy
2
+
3
+ @Library('plivo_standard_libs@sdks') _
4
+
5
+ sdksPipeline ([
6
+ buildContainer: 'plivo/jenkins-ci/plivo-rubysdk:master'
7
+ ])
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
- # Plivo Ruby Library
1
+ # plivo-ruby
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/plivo.png)](http://badge.fury.io/rb/plivo)
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
- ## Description
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
- The Plivo Ruby library simplifies the process of making REST calls and generating RESTXML.
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
9
 
10
- See [Plivo Documentation](http://www.plivo.com/docs/) for more information.
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
- ## GEM Installation
108
+ ### Lookup a number
14
109
 
15
- $ sudo gem install plivo
110
+ ```ruby
111
+ require 'rubygems'
112
+ require 'plivo'
16
113
 
114
+ include Plivo
17
115
 
18
- ## Manual Installation
116
+ client = RestClient.new
117
+ resp = client.lookup.get('<number-here>')
118
+ ```
19
119
 
20
- To use the rake command to build the gem and
120
+ ### Generate Plivo XML
21
121
 
22
- **Download the source and run:**
23
- $ sudo gem install /path/to/plivo/gem
122
+ ```ruby
123
+ require 'rubygems'
124
+ require 'plivo'
24
125
 
25
- to finish the installation
126
+ include Plivo::XML
26
127
 
27
- ### Requirements
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
- gem "rest-client", "~> 1.6.7"
31
- gem "json", "~> 1.6.6"
32
- gem "htmlentities", "~> 4.3.1"
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
- ## Usage
144
+ ### Run a PHLO
36
145
 
37
- To use the Plivo Ruby library, you will need to specify the AUTH_ID and AUTH_TOKEN, before you can make REST requests.
146
+ ```ruby
147
+ require 'rubygems'
148
+ require 'plivo'
38
149
 
39
- See [Plivo Documentation](http://www.plivo.com/docs/) for more information.
150
+ include Plivo
40
151
 
41
- ## Files
152
+ AUTH_ID = 'AUTH_ID'
153
+ AUTH_TOKEN = 'AUTH_TOKEN'
42
154
 
43
- **lib/plivo.rb:** include this library in your code
155
+ client = Phlo.new(AUTH_ID, AUTH_TOKEN)
44
156
 
45
- # License
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
- The Plivo Ruby library is distributed under the MPL 1.1 License
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
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+ Bundler::GemHelper.install_tasks
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
9
+ task :test => :spec
data/ci/config.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ parent: central
3
+ serviceName: plivo-ruby
4
+ language: ruby-sdk
5
+ build:
6
+ command: |
7
+ gem build plivo.gemspec
@@ -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
+ #
@@ -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