plivo 4.16.0 → 4.58.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/unitTests.yml +32 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +225 -0
  5. data/Dockerfile +12 -0
  6. data/Gemfile +1 -0
  7. data/Makefile +18 -0
  8. data/README.md +389 -20
  9. data/docker-compose.yml +18 -0
  10. data/examples/tollfree_verification.rb +42 -0
  11. data/lib/plivo/base/resource.rb +30 -0
  12. data/lib/plivo/base/resource_interface.rb +18 -2
  13. data/lib/plivo/base.rb +3 -3
  14. data/lib/plivo/base_client.rb +9 -9
  15. data/lib/plivo/interactive.rb +139 -0
  16. data/lib/plivo/location.rb +22 -0
  17. data/lib/plivo/resources/brand.rb +98 -0
  18. data/lib/plivo/resources/call_feedback.rb +0 -1
  19. data/lib/plivo/resources/calls.rb +183 -29
  20. data/lib/plivo/resources/campaign.rb +168 -0
  21. data/lib/plivo/resources/messages.rb +392 -58
  22. data/lib/plivo/resources/multipartycalls.rb +637 -0
  23. data/lib/plivo/resources/numbers.rb +40 -7
  24. data/lib/plivo/resources/profile.rb +93 -0
  25. data/lib/plivo/resources/recordings.rb +29 -2
  26. data/lib/plivo/resources/token.rb +66 -0
  27. data/lib/plivo/resources/tollfree_verification.rb +178 -0
  28. data/lib/plivo/resources/verify_caller_id.rb +110 -0
  29. data/lib/plivo/resources/verify_session.rb +106 -0
  30. data/lib/plivo/resources.rb +8 -0
  31. data/lib/plivo/rest_client.rb +14 -1
  32. data/lib/plivo/template.rb +102 -0
  33. data/lib/plivo/utils.rb +112 -1
  34. data/lib/plivo/version.rb +1 -1
  35. data/lib/plivo/xml/cont.rb +13 -0
  36. data/lib/plivo/xml/dial.rb +1 -1
  37. data/lib/plivo/xml/element.rb +9 -2
  38. data/lib/plivo/xml/emphasis.rb +1 -1
  39. data/lib/plivo/xml/lang.rb +1 -1
  40. data/lib/plivo/xml/multipartycall.rb +216 -0
  41. data/lib/plivo/xml/p.rb +1 -1
  42. data/lib/plivo/xml/plivo_xml.rb +2 -2
  43. data/lib/plivo/xml/prosody.rb +1 -1
  44. data/lib/plivo/xml/response.rb +1 -1
  45. data/lib/plivo/xml/s.rb +1 -1
  46. data/lib/plivo/xml/speak.rb +1 -1
  47. data/lib/plivo/xml/stream.rb +27 -0
  48. data/lib/plivo/xml/w.rb +1 -1
  49. data/lib/plivo/xml.rb +3 -1
  50. data/plivo.gemspec +1 -2
  51. data/setup_sdk.sh +47 -0
  52. metadata +24 -19
  53. data/.travis.yml +0 -11
@@ -0,0 +1,168 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+ class Campaign < Base::Resource
5
+ def initialize(client, options = nil)
6
+ @_name = '10dlc/Campaign'
7
+ @_identifier_string = 'campaign_id'
8
+ super
9
+ end
10
+
11
+ def to_s
12
+ {
13
+ api_id: @api_id,
14
+ campaign: @campaign
15
+ }.to_s
16
+ end
17
+ end
18
+
19
+ class CampaignInterface < Base::ResourceInterface
20
+ def initialize(client, resource_list_json = nil)
21
+ @_name = '10dlc/Campaign'
22
+ @_resource_type = Campaign
23
+ @_identifier_string = 'campaign_id'
24
+ super
25
+ end
26
+
27
+ ##
28
+ # Get an Campaign
29
+ # @param [String] campaign_id
30
+ # @return [Campaign] Campaign
31
+ def get(campaign_id)
32
+ valid_param?(:campaign_id, campaign_id, [String, Symbol], true)
33
+ perform_get(campaign_id)
34
+ end
35
+
36
+ ##
37
+ # List all Campaign
38
+ # @param [Hash] options
39
+ # @option options [String] :brand_id
40
+ # @option options [Status] :usecase
41
+ # @option options [String] :campaign_source
42
+ # @option options [String] :registration_status
43
+ # @option options [Status] :limit
44
+ # @option options [Status] :offset
45
+ # @return [Hash]
46
+ def list(options=nil)
47
+ return perform_list_without_object if options.nil?
48
+
49
+ params = {}
50
+ %i[usecase brand_id campaign_source limit offset registration_status].each do |param|
51
+ if options.key?(param) && valid_param?(param, options[param],
52
+ [String, Integer], true)
53
+ params[param] = options[param]
54
+ end
55
+ end
56
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
57
+ raise_invalid_request('The maximum number of results that can be '\
58
+ "fetched is 20. limit can't be more than 20 or less than 1")
59
+ end
60
+ if options.key?(:offset) && options[:offset] < 0
61
+ raise_invalid_request("Offset can't be negative")
62
+ end
63
+ perform_list_without_object(params)
64
+ end
65
+
66
+ ##
67
+ # Create a new Camapign
68
+ def create(options=nil)
69
+ valid_param?(:options, options, Hash, true)
70
+ if not options[:brand_id]
71
+ raise_invalid_request("brand_id must be provided")
72
+ end
73
+ if not options[:vertical]
74
+ raise_invalid_request("vertical must be provided")
75
+ end
76
+ if not options[:usecase]
77
+ raise_invalid_request("usecase must be provided")
78
+ end
79
+ if not options[:message_flow]
80
+ raise_invalid_request("message_flow must be provided")
81
+ end
82
+ if not options[:help_message]
83
+ raise_invalid_request("help_message must be provided")
84
+ end
85
+ if not options[:optout_message]
86
+ raise_invalid_request("optout_message must be provided")
87
+ end
88
+ perform_create(options)
89
+ end
90
+ ##
91
+ # Update Camapign
92
+ def update(campaign_id, options=nil)
93
+ valid_param?(:options, options, Hash, true)
94
+ if not campaign_id
95
+ raise_invalid_request("campaign_id must be provided")
96
+ end
97
+ action = campaign_id
98
+ perform_action_with_identifier(action, 'POST', options)
99
+ end
100
+ ##
101
+
102
+ #import campaign
103
+ def import(options=nil)
104
+ valid_param?(:options, options, Hash, true)
105
+ if not options[:campaign_id]
106
+ raise_invalid_request("campaign_id must be provided")
107
+ end
108
+ if not options[:campaign_alias]
109
+ raise_invalid_request("campaign_alias must be provided")
110
+ end
111
+ action = 'Import'
112
+ perform_action_with_identifier(action, 'POST', options)
113
+ end
114
+ # campaign number link
115
+ #
116
+ def number_link(options=nil)
117
+ valid_param?(:options, options, Hash, true)
118
+ if not options[:campaign_id]
119
+ raise_invalid_request("campaign_id must be provided")
120
+ end
121
+ action = options[:campaign_id] + '/Number'
122
+ perform_action_with_identifier(action, 'POST', options)
123
+ end
124
+ ##
125
+ #get campaign numbers
126
+ #
127
+ def get_numbers(campaign_id, options = nil)
128
+ params = {}
129
+ %i[offset limit].each do |param|
130
+ if options.key?(param) && valid_param?(param, options[param],
131
+ [Integer, Integer], true)
132
+ params[param] = options[param]
133
+ end
134
+ end
135
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
136
+ raise_invalid_request('The maximum number of results that can be '\
137
+ "fetched is 20. limit can't be more than 20 or less than 1")
138
+ end
139
+ if options.key?(:offset) && options[:offset] < 0
140
+ raise_invalid_request("Offset can't be negative")
141
+ end
142
+ action = campaign_id + '/Number'
143
+ perform_action_with_identifier(action, 'GET', params)
144
+ end
145
+ ##
146
+ #get campaign number
147
+ #
148
+ def get_number(campaign_id, number)
149
+ action = campaign_id + '/Number/' + number
150
+ perform_action_with_identifier(action, 'GET', nil)
151
+ end
152
+ ##
153
+ #unlink campaign number
154
+ #
155
+ def number_unlink(campaign_id, number, options = nil)
156
+ action = campaign_id + '/Number/' + number
157
+ perform_action_with_identifier(action, 'DELETE', nil)
158
+ end
159
+ ##
160
+ # Delete Campaign
161
+ # @param [String] campaign_id
162
+ def delete(campaign_id)
163
+ valid_param?(:campaign_id, campaign_id, [String, Symbol], true)
164
+ perform_delete(campaign_id)
165
+ end
166
+ end
167
+ end
168
+ end