gupshup-rb 0.1.7.1 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +17 -0
- data/.rubocop.yml +59 -0
- data/CHANGELOG.md +9 -0
- data/CODE_OF_CONDUCT.md +62 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +1 -1
- data/Rakefile +10 -0
- data/bin/console +9 -0
- data/bin/setup +5 -0
- data/gupshup-rb-0.1.0.gem +0 -0
- data/gupshup-rb-0.1.1.gem +0 -0
- data/gupshup-rb-0.1.2.gem +0 -0
- data/gupshup-rb-0.1.3.gem +0 -0
- data/gupshup-rb-0.1.4.gem +0 -0
- data/gupshup-rb-0.1.5.gem +0 -0
- data/gupshup-rb-0.1.6.gem +0 -0
- data/gupshup-rb.gemspec +39 -0
- data/lib/gupshup-rb/framework/gupshup_response.rb +19 -0
- data/lib/gupshup-rb/framework/request.rb +41 -0
- data/lib/gupshup-rb/framework/response.rb +18 -0
- data/lib/gupshup-rb/framework/rest/domain.rb +36 -0
- data/lib/gupshup-rb/framework/rest/error.rb +51 -0
- data/lib/gupshup-rb/framework/rest/helper.rb +11 -0
- data/lib/gupshup-rb/framework/rest/obsolete_client.rb +12 -0
- data/lib/gupshup-rb/framework/rest/page.rb +103 -0
- data/lib/gupshup-rb/framework/rest/resource.rb +23 -0
- data/lib/gupshup-rb/framework/rest/version.rb +153 -0
- data/lib/gupshup-rb/framework/serialize.rb +81 -0
- data/lib/gupshup-rb/framework/values.rb +9 -0
- data/lib/gupshup-rb/http/http_client.rb +53 -0
- data/lib/gupshup-rb/http.rb +5 -0
- data/lib/gupshup-rb/rest/api/v1/message.rb +59 -0
- data/lib/gupshup-rb/rest/api/v1.rb +29 -0
- data/lib/gupshup-rb/rest/api.rb +245 -0
- data/lib/gupshup-rb/rest/client.rb +581 -0
- data/lib/gupshup-rb/rest.rb +13 -0
- data/lib/gupshup-rb/util/configuration.rb +33 -0
- data/lib/gupshup-rb/version.rb +3 -0
- data/lib/gupshup-rb.rb +47 -0
- metadata +50 -7
@@ -0,0 +1,581 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Gupshup
|
10
|
+
module REST
|
11
|
+
##
|
12
|
+
# A client for accessing the Gupshup API.
|
13
|
+
class Client
|
14
|
+
@@default_region = 'us1'
|
15
|
+
|
16
|
+
attr_accessor :http_client, :username, :password, :src_name, :api_key, :region, :edge, :logger, :user_agent_extensions
|
17
|
+
|
18
|
+
##
|
19
|
+
# Initializes the Gupshup Client
|
20
|
+
def initialize(username=nil, password=nil, src_name=nil, region=nil, http_client=nil, logger=nil, user_agent_extensions=nil)
|
21
|
+
puts 'Gupshup'
|
22
|
+
puts Gupshup
|
23
|
+
|
24
|
+
binding.local_variables.each do |var_name|
|
25
|
+
var_value = binding.local_variable_get(var_name)
|
26
|
+
puts "#{var_name}: #{var_value}"
|
27
|
+
end
|
28
|
+
@src_name = src_name || Gupshup.src_name
|
29
|
+
@api_key = password || Gupshup.api_key
|
30
|
+
@auth = [@src_name, @api_key]
|
31
|
+
@logger = logger || Gupshup.logger
|
32
|
+
@user_agent_extensions = user_agent_extensions || []
|
33
|
+
|
34
|
+
# Domains
|
35
|
+
@api = nil
|
36
|
+
@content = nil
|
37
|
+
@conversations = nil
|
38
|
+
@events = nil
|
39
|
+
@media = nil
|
40
|
+
@messaging = nil
|
41
|
+
@video = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Makes a request to the Gupshup API using the configured http client
|
46
|
+
# Authentication information is automatically added if none is provided
|
47
|
+
def request(host, port, method, uri, params={}, data={}, headers={}, auth=nil, timeout=nil)
|
48
|
+
auth ||= @auth
|
49
|
+
|
50
|
+
ruby_config = RbConfig::CONFIG
|
51
|
+
headers['User-Agent'] = "gupshup-rb/#{Gupshup::VERSION} (#{ruby_config["host_os"]} #{ruby_config["host_cpu"]}) Ruby/#{RUBY_VERSION}"
|
52
|
+
headers['Accept-Charset'] = 'utf-8'
|
53
|
+
|
54
|
+
user_agent_extensions.each { |extension| headers['User-Agent'] += " #{extension}" }
|
55
|
+
|
56
|
+
if method == 'POST' && !headers['Content-Type']
|
57
|
+
headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
58
|
+
end
|
59
|
+
|
60
|
+
unless headers['Accept']
|
61
|
+
headers['Accept'] = 'application/json'
|
62
|
+
end
|
63
|
+
|
64
|
+
uri = build_uri(uri)
|
65
|
+
|
66
|
+
if @logger
|
67
|
+
@logger.debug("--BEGIN Gupshup API Request--")
|
68
|
+
@logger.debug("Request Method: <#{method}>")
|
69
|
+
|
70
|
+
headers.each do |key, value|
|
71
|
+
unless key.downcase == 'authorization'
|
72
|
+
@logger.debug("#{key}:#{value}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
url = URI(uri)
|
77
|
+
@logger.debug("Host:#{url.host}")
|
78
|
+
@logger.debug("Path:#{url.path}")
|
79
|
+
@logger.debug("Query:#{url.query}")
|
80
|
+
@logger.debug("Request Params:#{params}")
|
81
|
+
end
|
82
|
+
|
83
|
+
response = @http_client.request(
|
84
|
+
host,
|
85
|
+
port,
|
86
|
+
method,
|
87
|
+
uri,
|
88
|
+
params,
|
89
|
+
data,
|
90
|
+
headers,
|
91
|
+
auth,
|
92
|
+
timeout
|
93
|
+
)
|
94
|
+
|
95
|
+
if @logger
|
96
|
+
@logger.debug("Response Status Code:#{response.status_code}")
|
97
|
+
@logger.debug("Response Headers:#{response.headers}")
|
98
|
+
@logger.debug("--END GUPSHUP API REQUEST--")
|
99
|
+
end
|
100
|
+
|
101
|
+
response
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# Build the final request uri
|
106
|
+
def build_uri(uri)
|
107
|
+
if @region.nil? and @edge.nil?
|
108
|
+
return uri
|
109
|
+
end
|
110
|
+
|
111
|
+
parsed_url = URI(uri)
|
112
|
+
pieces = parsed_url.host.split('.')
|
113
|
+
product = pieces[0]
|
114
|
+
domain = pieces[-2, 2]
|
115
|
+
new_edge = @edge
|
116
|
+
new_region = @region
|
117
|
+
|
118
|
+
if pieces.length == 4
|
119
|
+
new_region ||= pieces[1]
|
120
|
+
elsif pieces.length == 5
|
121
|
+
new_edge ||= pieces[1]
|
122
|
+
new_region ||= pieces[2]
|
123
|
+
end
|
124
|
+
|
125
|
+
if !new_edge.nil? && new_region.nil?
|
126
|
+
new_region = @@default_region
|
127
|
+
end
|
128
|
+
|
129
|
+
parsed_url.host = [product, new_edge, new_region, domain].select {|item| !item.nil?}.join('.')
|
130
|
+
parsed_url.to_s
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# Validate the new SSL certificate for the Gupshup API
|
135
|
+
def validate_ssl_certificate
|
136
|
+
response = request('api.gupshup.com', '8443', 'GET', 'https://api.gupshup.com:8443/.json')
|
137
|
+
if response.status_code < 200 || response.status_code >= 300
|
138
|
+
raise RestError.new 'Unexpected response from certificate endpoint', response
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# Access the Accounts Gupshup Domain
|
144
|
+
def accounts
|
145
|
+
@accounts ||= Accounts.new self
|
146
|
+
end
|
147
|
+
|
148
|
+
##
|
149
|
+
# Access the Api Gupshup Domain
|
150
|
+
def api
|
151
|
+
@api ||= Api.new self
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# Access the Autopilot Gupshup Domain
|
156
|
+
def autopilot
|
157
|
+
@autopilot ||= Autopilot.new self
|
158
|
+
end
|
159
|
+
|
160
|
+
##
|
161
|
+
# Access the Chat Gupshup Domain
|
162
|
+
def chat
|
163
|
+
@chat ||= Chat.new self
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# Access the Content Gupshup Domain
|
168
|
+
def content
|
169
|
+
@content ||= Content.new self
|
170
|
+
end
|
171
|
+
|
172
|
+
##
|
173
|
+
# Access the Conversations Gupshup Domain
|
174
|
+
def conversations
|
175
|
+
@conversations ||= Conversations.new self
|
176
|
+
end
|
177
|
+
|
178
|
+
##
|
179
|
+
# Access the Events Gupshup Domain
|
180
|
+
def events
|
181
|
+
@events ||= Events.new self
|
182
|
+
end
|
183
|
+
|
184
|
+
##
|
185
|
+
# Access the FlexApi Gupshup Domain
|
186
|
+
def flex_api
|
187
|
+
@flex_api ||= FlexApi.new self
|
188
|
+
end
|
189
|
+
|
190
|
+
##
|
191
|
+
# Access the FrontlineApi Gupshup Domain
|
192
|
+
def frontline_api
|
193
|
+
@frontline_api ||= FrontlineApi.new self
|
194
|
+
end
|
195
|
+
|
196
|
+
##
|
197
|
+
# Access the Insights Gupshup Domain
|
198
|
+
def insights
|
199
|
+
@insights ||= Insights.new self
|
200
|
+
end
|
201
|
+
|
202
|
+
##
|
203
|
+
# Access the IpMessaging Gupshup Domain
|
204
|
+
def ip_messaging
|
205
|
+
@ip_messaging ||= IpMessaging.new self
|
206
|
+
end
|
207
|
+
|
208
|
+
##
|
209
|
+
# Access the Lookups Gupshup Domain
|
210
|
+
def lookups
|
211
|
+
@lookups ||= Lookups.new self
|
212
|
+
end
|
213
|
+
|
214
|
+
##
|
215
|
+
# Access the Media Gupshup Domain
|
216
|
+
def media
|
217
|
+
@media ||= Media.new self
|
218
|
+
end
|
219
|
+
|
220
|
+
##
|
221
|
+
# Access the Messaging Gupshup Domain
|
222
|
+
def messaging
|
223
|
+
@messaging ||= Messaging.new self
|
224
|
+
end
|
225
|
+
|
226
|
+
##
|
227
|
+
# Access the Monitor Gupshup Domain
|
228
|
+
def monitor
|
229
|
+
@monitor ||= Monitor.new self
|
230
|
+
end
|
231
|
+
|
232
|
+
##
|
233
|
+
# Access the Notify Gupshup Domain
|
234
|
+
def notify
|
235
|
+
@notify ||= Notify.new self
|
236
|
+
end
|
237
|
+
|
238
|
+
##
|
239
|
+
# Access the Numbers Gupshup Domain
|
240
|
+
def numbers
|
241
|
+
@numbers ||= Numbers.new self
|
242
|
+
end
|
243
|
+
|
244
|
+
##
|
245
|
+
# Access the Oauth Gupshup Domain
|
246
|
+
def oauth
|
247
|
+
@oauth ||= Oauth.new self
|
248
|
+
end
|
249
|
+
|
250
|
+
##
|
251
|
+
# Access the Preview Gupshup Domain
|
252
|
+
def preview
|
253
|
+
@preview ||= Preview.new self
|
254
|
+
end
|
255
|
+
|
256
|
+
##
|
257
|
+
# Access the Pricing Gupshup Domain
|
258
|
+
def pricing
|
259
|
+
@pricing ||= Pricing.new self
|
260
|
+
end
|
261
|
+
|
262
|
+
##
|
263
|
+
# Access the Proxy Gupshup Domain
|
264
|
+
def proxy
|
265
|
+
@proxy ||= Proxy.new self
|
266
|
+
end
|
267
|
+
|
268
|
+
##
|
269
|
+
# Access the Routes Gupshup Domain
|
270
|
+
def routes
|
271
|
+
@routes ||= Routes.new self
|
272
|
+
end
|
273
|
+
|
274
|
+
##
|
275
|
+
# Access the Serverless Gupshup Domain
|
276
|
+
def serverless
|
277
|
+
@serverless ||= Serverless.new self
|
278
|
+
end
|
279
|
+
|
280
|
+
##
|
281
|
+
# Access the Studio Gupshup Domain
|
282
|
+
def studio
|
283
|
+
@studio ||= Studio.new self
|
284
|
+
end
|
285
|
+
|
286
|
+
##
|
287
|
+
# Access the Sync Gupshup Domain
|
288
|
+
def sync
|
289
|
+
@sync ||= Sync.new self
|
290
|
+
end
|
291
|
+
|
292
|
+
##
|
293
|
+
# Access the Taskrouter Gupshup Domain
|
294
|
+
def taskrouter
|
295
|
+
@taskrouter ||= Taskrouter.new self
|
296
|
+
end
|
297
|
+
|
298
|
+
##
|
299
|
+
# Access the Trunking Gupshup Domain
|
300
|
+
def trunking
|
301
|
+
@trunking ||= Trunking.new self
|
302
|
+
end
|
303
|
+
|
304
|
+
##
|
305
|
+
# Access the Trusthub Gupshup Domain
|
306
|
+
def trusthub
|
307
|
+
@trusthub ||= Trusthub.new self
|
308
|
+
end
|
309
|
+
|
310
|
+
##
|
311
|
+
# Access the Verify Gupshup Domain
|
312
|
+
def verify
|
313
|
+
@verify ||= Verify.new self
|
314
|
+
end
|
315
|
+
|
316
|
+
##
|
317
|
+
# Access the Video Gupshup Domain
|
318
|
+
def video
|
319
|
+
@video ||= Video.new self
|
320
|
+
end
|
321
|
+
|
322
|
+
##
|
323
|
+
# Access the Voice Gupshup Domain
|
324
|
+
def voice
|
325
|
+
@voice ||= Voice.new self
|
326
|
+
end
|
327
|
+
|
328
|
+
##
|
329
|
+
# Access the Wireless Gupshup Domain
|
330
|
+
def wireless
|
331
|
+
@wireless ||= Wireless.new self
|
332
|
+
end
|
333
|
+
|
334
|
+
##
|
335
|
+
# Access the Supersim Gupshup Domain
|
336
|
+
def supersim
|
337
|
+
@supersim ||= Supersim.new self
|
338
|
+
end
|
339
|
+
|
340
|
+
##
|
341
|
+
# Access the Bulkexports Gupshup Domain
|
342
|
+
def bulkexports
|
343
|
+
@bulkexports ||= Bulkexports.new self
|
344
|
+
end
|
345
|
+
|
346
|
+
##
|
347
|
+
# Access the Microvisor Gupshup Domain
|
348
|
+
def microvisor
|
349
|
+
@microvisor ||= Microvisor.new self
|
350
|
+
end
|
351
|
+
|
352
|
+
##
|
353
|
+
# @param [String] sid The unique string that that we created to identify the
|
354
|
+
# Address resource.
|
355
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::AddressInstance] if sid was passed.
|
356
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::AddressList]
|
357
|
+
def addresses(sid=:unset)
|
358
|
+
self.api.v2010.account.addresses(sid)
|
359
|
+
end
|
360
|
+
|
361
|
+
##
|
362
|
+
# @param [String] sid The unique string that that we created to identify the
|
363
|
+
# Application resource.
|
364
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ApplicationInstance] if sid was passed.
|
365
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ApplicationList]
|
366
|
+
def applications(sid=:unset)
|
367
|
+
self.api.v2010.account.applications(sid)
|
368
|
+
end
|
369
|
+
|
370
|
+
##
|
371
|
+
# @param [String] connect_app_sid The SID that we assigned to the Connect App.
|
372
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::AuthorizedConnectAppInstance] if connect_app_sid was passed.
|
373
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::AuthorizedConnectAppList]
|
374
|
+
def authorized_connect_apps(connect_app_sid=:unset)
|
375
|
+
self.api.v2010.account.authorized_connect_apps(connect_app_sid)
|
376
|
+
end
|
377
|
+
|
378
|
+
##
|
379
|
+
# @param [String] country_code The
|
380
|
+
# {ISO-3166-1}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2] country code of
|
381
|
+
# the country.
|
382
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::AvailablePhoneNumberCountryInstance] if country_code was passed.
|
383
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::AvailablePhoneNumberCountryList]
|
384
|
+
def available_phone_numbers(country_code=:unset)
|
385
|
+
self.api.v2010.account.available_phone_numbers(country_code)
|
386
|
+
end
|
387
|
+
|
388
|
+
##
|
389
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::BalanceInstance]
|
390
|
+
def balance
|
391
|
+
self.api.v2010.account.balance
|
392
|
+
end
|
393
|
+
|
394
|
+
##
|
395
|
+
# @param [String] sid The unique string that we created to identify this Call
|
396
|
+
# resource.
|
397
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::CallInstance] if sid was passed.
|
398
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::CallList]
|
399
|
+
def calls(sid=:unset)
|
400
|
+
self.api.v2010.account.calls(sid)
|
401
|
+
end
|
402
|
+
|
403
|
+
##
|
404
|
+
# @param [String] sid The unique string that that we created to identify this
|
405
|
+
# Conference resource.
|
406
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ConferenceInstance] if sid was passed.
|
407
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ConferenceList]
|
408
|
+
def conferences(sid=:unset)
|
409
|
+
self.api.v2010.account.conferences(sid)
|
410
|
+
end
|
411
|
+
|
412
|
+
##
|
413
|
+
# @param [String] sid The unique string that that we created to identify the
|
414
|
+
# ConnectApp resource.
|
415
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ConnectAppInstance] if sid was passed.
|
416
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ConnectAppList]
|
417
|
+
def connect_apps(sid=:unset)
|
418
|
+
self.api.v2010.account.connect_apps(sid)
|
419
|
+
end
|
420
|
+
|
421
|
+
##
|
422
|
+
# @param [String] sid The unique string that that we created to identify this
|
423
|
+
# IncomingPhoneNumber resource.
|
424
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::IncomingPhoneNumberInstance] if sid was passed.
|
425
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::IncomingPhoneNumberList]
|
426
|
+
def incoming_phone_numbers(sid=:unset)
|
427
|
+
self.api.v2010.account.incoming_phone_numbers(sid)
|
428
|
+
end
|
429
|
+
|
430
|
+
##
|
431
|
+
# @param [String] sid The unique string that that we created to identify the Key
|
432
|
+
# resource.
|
433
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::KeyInstance] if sid was passed.
|
434
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::KeyList]
|
435
|
+
def keys(sid=:unset)
|
436
|
+
self.api.v2010.account.keys(sid)
|
437
|
+
end
|
438
|
+
|
439
|
+
##
|
440
|
+
# @param [String] sid The unique string that that we created to identify the
|
441
|
+
# Message resource.
|
442
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::MessageInstance] if sid was passed.
|
443
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::MessageList]
|
444
|
+
def messages(sid=:unset)
|
445
|
+
self.api.v2010.account.messages(sid)
|
446
|
+
end
|
447
|
+
|
448
|
+
##
|
449
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::NewKeyInstance]
|
450
|
+
def new_keys
|
451
|
+
self.api.v2010.account.new_keys
|
452
|
+
end
|
453
|
+
|
454
|
+
##
|
455
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::NewSigningKeyInstance]
|
456
|
+
def new_signing_keys
|
457
|
+
self.api.v2010.account.new_signing_keys
|
458
|
+
end
|
459
|
+
|
460
|
+
##
|
461
|
+
# @param [String] sid The unique string that that we created to identify the
|
462
|
+
# Notification resource.
|
463
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::NotificationInstance] if sid was passed.
|
464
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::NotificationList]
|
465
|
+
def notifications(sid=:unset)
|
466
|
+
self.api.v2010.account.notifications(sid)
|
467
|
+
end
|
468
|
+
|
469
|
+
##
|
470
|
+
# @param [String] sid The unique string that that we created to identify the
|
471
|
+
# OutgoingCallerId resource.
|
472
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::OutgoingCallerIdInstance] if sid was passed.
|
473
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::OutgoingCallerIdList]
|
474
|
+
def outgoing_caller_ids(sid=:unset)
|
475
|
+
self.api.v2010.account.outgoing_caller_ids(sid)
|
476
|
+
end
|
477
|
+
|
478
|
+
##
|
479
|
+
# @param [String] sid The unique string that that we created to identify this
|
480
|
+
# Queue resource.
|
481
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::QueueInstance] if sid was passed.
|
482
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::QueueList]
|
483
|
+
def queues(sid=:unset)
|
484
|
+
self.api.v2010.account.queues(sid)
|
485
|
+
end
|
486
|
+
|
487
|
+
##
|
488
|
+
# @param [String] sid The unique string that that we created to identify the
|
489
|
+
# Recording resource.
|
490
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::RecordingInstance] if sid was passed.
|
491
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::RecordingList]
|
492
|
+
def recordings(sid=:unset)
|
493
|
+
self.api.v2010.account.recordings(sid)
|
494
|
+
end
|
495
|
+
|
496
|
+
##
|
497
|
+
# @param [String] sid The sid
|
498
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::SigningKeyInstance] if sid was passed.
|
499
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::SigningKeyList]
|
500
|
+
def signing_keys(sid=:unset)
|
501
|
+
self.api.v2010.account.signing_keys(sid)
|
502
|
+
end
|
503
|
+
|
504
|
+
##
|
505
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::SipInstance]
|
506
|
+
def sip
|
507
|
+
self.api.v2010.account.sip
|
508
|
+
end
|
509
|
+
|
510
|
+
##
|
511
|
+
# @param [String] sid The unique string that that we created to identify this
|
512
|
+
# ShortCode resource.
|
513
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ShortCodeInstance] if sid was passed.
|
514
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ShortCodeList]
|
515
|
+
def short_codes(sid=:unset)
|
516
|
+
self.api.v2010.account.short_codes(sid)
|
517
|
+
end
|
518
|
+
|
519
|
+
##
|
520
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::TokenInstance]
|
521
|
+
def tokens
|
522
|
+
self.api.v2010.account.tokens
|
523
|
+
end
|
524
|
+
|
525
|
+
##
|
526
|
+
# @param [String] sid The unique string that that we created to identify the
|
527
|
+
# Transcription resource.
|
528
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::TranscriptionInstance] if sid was passed.
|
529
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::TranscriptionList]
|
530
|
+
def transcriptions(sid=:unset)
|
531
|
+
self.api.v2010.account.transcriptions(sid)
|
532
|
+
end
|
533
|
+
|
534
|
+
##
|
535
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::UsageInstance]
|
536
|
+
def usage
|
537
|
+
self.api.v2010.account.usage
|
538
|
+
end
|
539
|
+
|
540
|
+
##
|
541
|
+
# @return [Gupshup::REST::Api::V2010::AccountContext::ValidationRequestInstance]
|
542
|
+
def validation_requests
|
543
|
+
self.api.v2010.account.validation_requests
|
544
|
+
end
|
545
|
+
|
546
|
+
##
|
547
|
+
# Provide a user friendly representation
|
548
|
+
def to_s
|
549
|
+
"#<Gupshup::REST::Client #{@src_name}>"
|
550
|
+
end
|
551
|
+
end
|
552
|
+
|
553
|
+
##
|
554
|
+
# Dummy client which provides no functionality. Please use Gupshup::REST::Client instead.
|
555
|
+
class BaseClient < ObsoleteClient; end
|
556
|
+
|
557
|
+
##
|
558
|
+
# Dummy client which provides no functionality. Please use Gupshup::REST::Client instead.
|
559
|
+
class IpMessagingClient < ObsoleteClient; end
|
560
|
+
|
561
|
+
##
|
562
|
+
# Dummy client which provides no functionality. Please use Gupshup::REST::Client instead.
|
563
|
+
class LookupsClient < ObsoleteClient; end
|
564
|
+
|
565
|
+
##
|
566
|
+
# Dummy client which provides no functionality. Please use Gupshup::REST::Client instead.
|
567
|
+
class MonitorClient < ObsoleteClient; end
|
568
|
+
|
569
|
+
##
|
570
|
+
# Dummy client which provides no functionality. Please use Gupshup::REST::Client instead.
|
571
|
+
class PricingClient < ObsoleteClient; end
|
572
|
+
|
573
|
+
##
|
574
|
+
# Dummy client which provides no functionality. Please use Gupshup::REST::Client instead.
|
575
|
+
class TaskRouterClient < ObsoleteClient; end
|
576
|
+
|
577
|
+
##
|
578
|
+
# Dummy client which provides no functionality. Please use Gupshup::REST::Client instead.
|
579
|
+
class TrunkingClient < ObsoleteClient; end
|
580
|
+
end
|
581
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Dir[File.join(__dir__, 'framework/rest/*.rb')].sort.each do |file|
|
4
|
+
require file
|
5
|
+
end
|
6
|
+
|
7
|
+
Dir[File.join(__dir__, 'rest/*.rb')].sort.each do |file|
|
8
|
+
require file
|
9
|
+
end
|
10
|
+
|
11
|
+
Dir[File.join(__dir__, 'rest/**/*.rb')].sort.each do |file|
|
12
|
+
require file
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gupshup
|
4
|
+
module Util
|
5
|
+
class Configuration
|
6
|
+
attr_accessor :src_name, :api_key, :http_client, :region, :edge, :logger
|
7
|
+
|
8
|
+
def src_name=(value)
|
9
|
+
@src_name = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def api_key=(value)
|
13
|
+
@api_key = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def http_client=(value)
|
17
|
+
@http_client = value
|
18
|
+
end
|
19
|
+
|
20
|
+
def region=(value)
|
21
|
+
@region = value
|
22
|
+
end
|
23
|
+
|
24
|
+
def edge=(value)
|
25
|
+
@edge = value
|
26
|
+
end
|
27
|
+
|
28
|
+
def logger=(value)
|
29
|
+
@logger = value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/gupshup-rb.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'net/https'
|
5
|
+
require 'cgi'
|
6
|
+
require 'openssl'
|
7
|
+
require 'base64'
|
8
|
+
require 'forwardable'
|
9
|
+
require 'time'
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
require 'gupshup-rb/version' unless defined?(Gupshup::VERSION)
|
13
|
+
require 'rack/gupshup_webhook_authentication' if defined?(Rack) && defined?(Rack::MediaType)
|
14
|
+
|
15
|
+
require 'gupshup-rb/util'
|
16
|
+
require 'gupshup-rb/security/request_validator'
|
17
|
+
require 'gupshup-rb/util/configuration'
|
18
|
+
|
19
|
+
Dir[File.join(__dir__, 'gupshup-rb/framework/*.rb')].sort.each do |file|
|
20
|
+
require file
|
21
|
+
end
|
22
|
+
|
23
|
+
module Gupshup
|
24
|
+
extend SingleForwardable
|
25
|
+
|
26
|
+
autoload :JWT, File.join(__dir__, 'gupshup-rb', 'jwt', 'jwt.rb')
|
27
|
+
autoload :TwiML, File.join(__dir__, 'gupshup-rb', 'twiml', 'twiml.rb')
|
28
|
+
autoload :HTTP, File.join(__dir__, 'gupshup-rb', 'http.rb')
|
29
|
+
autoload :REST, File.join(__dir__, 'gupshup-rb', 'rest.rb')
|
30
|
+
|
31
|
+
def_delegators :configuration, :src_name, :api_key, :http_client, :region, :edge, :logger
|
32
|
+
|
33
|
+
##
|
34
|
+
# Pre-configure with account SID and auth token so that you don't need to
|
35
|
+
# pass them to various initializers each time.
|
36
|
+
def self.configure(&block)
|
37
|
+
yield configuration
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Returns an existing or instantiates a new configuration object.
|
42
|
+
def self.configuration
|
43
|
+
@configuration ||= Util::Configuration.new
|
44
|
+
end
|
45
|
+
|
46
|
+
private_class_method :configuration
|
47
|
+
end
|