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
@@ -0,0 +1,43 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+ class Pricing < Base::Resource
5
+ def initialize(client, options = nil)
6
+ @_name = 'Pricing'
7
+ @_identifier_string = 'country_iso'
8
+ super
9
+ end
10
+
11
+ def to_s
12
+ {
13
+ api_id: @api_id,
14
+ country: @country,
15
+ country_code: @country_code,
16
+ country_iso: @country_iso,
17
+ message: @message,
18
+ phone_numbers: @phone_numbers,
19
+ voice: @voice
20
+ }.to_s
21
+ end
22
+ end
23
+
24
+ class PricingInterface < Base::ResourceInterface
25
+ def initialize(client, resource_list_json = nil)
26
+ @_name = 'Pricing'
27
+ @_resource_type = Pricing
28
+ @_identifier_string = 'country_iso'
29
+ super
30
+ end
31
+
32
+ # @param [String] country_iso
33
+ def get(country_iso)
34
+ valid_param?(:country_iso, country_iso, [String, Symbol], true)
35
+ unless country_iso.length == 2
36
+ raise_invalid_request('country_iso should be of length 2')
37
+ end
38
+ params = { country_iso: country_iso }
39
+ perform_get_without_identifier(params)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,116 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+ class Recording < Base::Resource
5
+ def initialize(client, options = nil)
6
+ @_name = 'Recording'
7
+ @_identifier_string = 'recording_id'
8
+ super
9
+ @_is_voice_request = true
10
+ end
11
+
12
+ def delete
13
+ perform_delete
14
+ end
15
+
16
+ def to_s
17
+ {
18
+ add_time: @add_time,
19
+ api_id: @api_id,
20
+ call_uuid: @call_uuid,
21
+ conference_name: @conference_name,
22
+ recording_duration_ms: @recording_duration_ms,
23
+ recording_end_ms: @recording_end_ms,
24
+ recording_format: @recording_format,
25
+ recording_id: @recording_id,
26
+ recording_start_ms: @recording_start_ms,
27
+ recording_type: @recording_type,
28
+ recording_url: @recording_url,
29
+ resource_uri: @resource_uri
30
+ }.to_s
31
+ end
32
+ end
33
+
34
+ class RecordingInterface < Base::ResourceInterface
35
+ def initialize(client, resource_list_json = nil)
36
+ @_name = 'Recording'
37
+ @_resource_type = Recording
38
+ @_identifier_string = 'recording_id'
39
+ super
40
+ @_is_voice_request = true
41
+ end
42
+
43
+ # @param [Hash] options
44
+ # @option options [String] :subaccount auth_id of the subaccount. Lists only those recordings of the main accounts which are tied to the specified subaccount.
45
+ # @option options [String] :call_uuid Used to filter recordings for a specific call.
46
+ # @option options [String] :add_time Used to filter out recordings according to the time they were added.The add_time filter is a comparative filter that can be used in the following four forms:
47
+ # - add_time\__gt: gt stands for greater than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all recordings that started after 2012-03-21 11:47, use add_time\__gt=2012-03-21 11:47
48
+ # - add_time\__gte: gte stands for greater than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all recordings that started after or exactly at 2012-03-21 11:47[:30], use add_time\__gte=2012-03-21 11:47[:30]
49
+ # - add_time\__lt: lt stands for lesser than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all recordings that started before 2012-03-21 11:47, use add_time\__lt=2012-03-21 11:47
50
+ # - add_time\__gte: lte stands for lesser than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all recordings that started before or exactly at 2012-03-21 11:47[:30], use add_time\__lte=2012-03-21 11:47[:30]
51
+ # - Note: The above filters can be combined to get recordings that started in a particular time range.
52
+ # @option options [Int] :limit Used to display the number of results per page. The maximum number of results that can be fetched is 20.
53
+ # @option options [Int] :offset Denotes the number of value items by which the results should be offset. Eg:- If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results.
54
+ def list(options = nil)
55
+ return perform_list if options.nil?
56
+ valid_param?(:options, options, Hash, true)
57
+
58
+ params = {}
59
+ params_expected = %i[
60
+ call_uuid add_time__gt add_time__gte
61
+ add_time__lt add_time__lte
62
+ ]
63
+
64
+ params_expected.each do |param|
65
+ if options.key?(param) && valid_param?(param, options[param], [String, Symbol], true)
66
+ params[param] = options[param]
67
+ end
68
+ end
69
+
70
+ if options.key?(:subaccount) &&
71
+ valid_subaccount?(options[:subaccount], true)
72
+ params[:subaccount] = options[:subaccount]
73
+ end
74
+
75
+ %i[offset limit].each do |param|
76
+ if options.key?(param) && valid_param?(param, options[param], [Integer, Integer], true)
77
+ params[param] = options[param]
78
+ end
79
+ end
80
+
81
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
82
+ raise_invalid_request('The maximum number of results that can be fetched'\
83
+ " is 20. limit can't be more than 20 or less than 1")
84
+ end
85
+
86
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
87
+
88
+ perform_list(params)
89
+ end
90
+
91
+ # @param [String] recording_id
92
+ def get(recording_id)
93
+ valid_param?(:recording_id, recording_id, [String, Symbol], true)
94
+ raise_invalid_request('Invalid recording_id passed') if recording_id.empty?
95
+ perform_get(recording_id)
96
+ end
97
+
98
+ def each
99
+ offset = 0
100
+ loop do
101
+ recording_list = list(offset: offset)
102
+ recording_list[:objects].each { |recording| yield recording }
103
+ offset += 20
104
+ return unless recording_list.length == 20
105
+ end
106
+ end
107
+
108
+ # @param [String] recording_id
109
+ def delete(recording_id)
110
+ valid_param?(:recording_id, recording_id, [String, Symbol], true)
111
+ raise_invalid_request('Invalid recording_id passed') if recording_id.empty?
112
+ Recording.new(@_client, resource_id: recording_id).delete
113
+ end
114
+ end
115
+ end
116
+ end