bandwidth-sdk 4.0.0 → 5.0.0
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/lib/bandwidth/messaging_lib/messaging.rb +3 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +130 -15
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +12 -11
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +125 -0
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +60 -0
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +4 -4
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +8 -6
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +62 -0
- data/test/controllers/controller_test_base.rb +21 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/test_helper.rb +94 -0
- metadata +42 -3
- data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +0 -107
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc4d4b047d53e1e8c3f34b37696455d916a753aa3566dad6d6fb666fc2b3fa61
|
4
|
+
data.tar.gz: b5cdf37c09788e890f36ef3c78ccf41f0ba18a69291f1424be7f798f207881f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59761140cdddf9f6cda37d7aeeaeff6341a5c0bcc357cf577ae29e8fff0a6cf347f1070536f99db3b2f3f6baae3c2b93edbefb2e94468036c57ffd7a65c279b0
|
7
|
+
data.tar.gz: bdf68653a8640403d2bc5402c9f5af06055079640ab9229b16ac12cf48290ccffbe2ac38e40c11c3e6b518b1ebaad05344779249d0f79c940d32c3a57b36f5ed
|
@@ -7,6 +7,9 @@
|
|
7
7
|
require_relative 'messaging/client.rb'
|
8
8
|
|
9
9
|
# Models
|
10
|
+
require_relative 'messaging/models/bandwidth_messages_list.rb'
|
11
|
+
require_relative 'messaging/models/bandwidth_message_item.rb'
|
12
|
+
require_relative 'messaging/models/page_info.rb'
|
10
13
|
require_relative 'messaging/models/media.rb'
|
11
14
|
require_relative 'messaging/models/tag.rb'
|
12
15
|
require_relative 'messaging/models/deferred_result.rb'
|
@@ -12,8 +12,9 @@ module Messaging
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# listMedia
|
15
|
-
# @param [String] user_id Required parameter:
|
16
|
-
# @param [String] continuation_token Optional parameter:
|
15
|
+
# @param [String] user_id Required parameter: User's account ID
|
16
|
+
# @param [String] continuation_token Optional parameter: Continuation token
|
17
|
+
# used to retrieve subsequent media.
|
17
18
|
# @return [List of Media] response from the API call
|
18
19
|
def list_media(user_id,
|
19
20
|
continuation_token: nil)
|
@@ -83,8 +84,8 @@ module Messaging
|
|
83
84
|
end
|
84
85
|
|
85
86
|
# getMedia
|
86
|
-
# @param [String] user_id Required parameter:
|
87
|
-
# @param [String] media_id Required parameter:
|
87
|
+
# @param [String] user_id Required parameter: User's account ID
|
88
|
+
# @param [String] media_id Required parameter: Media ID to retrieve
|
88
89
|
# @return [Binary] response from the API call
|
89
90
|
def get_media(user_id,
|
90
91
|
media_id)
|
@@ -146,13 +147,17 @@ module Messaging
|
|
146
147
|
end
|
147
148
|
|
148
149
|
# uploadMedia
|
149
|
-
# @param [String] user_id Required parameter:
|
150
|
-
# @param [String] media_id Required parameter:
|
151
|
-
#
|
150
|
+
# @param [String] user_id Required parameter: User's account ID
|
151
|
+
# @param [String] media_id Required parameter: The user supplied custom
|
152
|
+
# media ID
|
153
|
+
# @param [Long] content_length Required parameter: The size of the
|
154
|
+
# entity-body
|
152
155
|
# @param [File | UploadIO] body Required parameter: Example:
|
153
|
-
# @param [String] content_type Optional parameter:
|
154
|
-
#
|
155
|
-
# @param [String] cache_control Optional parameter:
|
156
|
+
# @param [String] content_type Optional parameter: The media type of the
|
157
|
+
# entity-body
|
158
|
+
# @param [String] cache_control Optional parameter: General-header field is
|
159
|
+
# used to specify directives that MUST be obeyed by all caching mechanisms
|
160
|
+
# along the request/response chain.
|
156
161
|
# @return [void] response from the API call
|
157
162
|
def upload_media(user_id,
|
158
163
|
media_id,
|
@@ -234,8 +239,8 @@ module Messaging
|
|
234
239
|
end
|
235
240
|
|
236
241
|
# deleteMedia
|
237
|
-
# @param [String] user_id Required parameter:
|
238
|
-
# @param [String] media_id Required parameter:
|
242
|
+
# @param [String] user_id Required parameter: User's account ID
|
243
|
+
# @param [String] media_id Required parameter: The media ID to delete
|
239
244
|
# @return [void] response from the API call
|
240
245
|
def delete_media(user_id,
|
241
246
|
media_id)
|
@@ -294,12 +299,122 @@ module Messaging
|
|
294
299
|
ApiResponse.new(_response)
|
295
300
|
end
|
296
301
|
|
302
|
+
# getMessages
|
303
|
+
# @param [String] user_id Required parameter: User's account ID
|
304
|
+
# @param [String] message_id Optional parameter: The ID of the message to
|
305
|
+
# search for. Special characters need to be encoded using URL encoding
|
306
|
+
# @param [String] source_tn Optional parameter: The phone number that sent
|
307
|
+
# the message
|
308
|
+
# @param [String] destination_tn Optional parameter: The phone number that
|
309
|
+
# received the message
|
310
|
+
# @param [String] message_status Optional parameter: The status of the
|
311
|
+
# message. One of RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED,
|
312
|
+
# DLR_EXPIRED
|
313
|
+
# @param [Integer] error_code Optional parameter: The error code of the
|
314
|
+
# message
|
315
|
+
# @param [String] from_date_time Optional parameter: The start of the date
|
316
|
+
# range to search in ISO 8601 format. Uses the message receive time. The
|
317
|
+
# date range to search in is currently 14 days.
|
318
|
+
# @param [String] to_date_time Optional parameter: The end of the date range
|
319
|
+
# to search in ISO 8601 format. Uses the message receive time. The date
|
320
|
+
# range to search in is currently 14 days.
|
321
|
+
# @param [String] page_token Optional parameter: A base64 encoded value used
|
322
|
+
# for pagination of results
|
323
|
+
# @param [Integer] limit Optional parameter: The maximum records requested
|
324
|
+
# in search result. Default 100. The sum of limit and after cannot be more
|
325
|
+
# than 10000
|
326
|
+
# @return [BandwidthMessagesList] response from the API call
|
327
|
+
def get_messages(user_id,
|
328
|
+
message_id: nil,
|
329
|
+
source_tn: nil,
|
330
|
+
destination_tn: nil,
|
331
|
+
message_status: nil,
|
332
|
+
error_code: nil,
|
333
|
+
from_date_time: nil,
|
334
|
+
to_date_time: nil,
|
335
|
+
page_token: nil,
|
336
|
+
limit: nil)
|
337
|
+
# Prepare query url.
|
338
|
+
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
339
|
+
_query_builder << '/users/{userId}/messages'
|
340
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
341
|
+
_query_builder,
|
342
|
+
'userId' => { 'value' => user_id, 'encode' => false }
|
343
|
+
)
|
344
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
345
|
+
_query_builder,
|
346
|
+
'messageId' => message_id,
|
347
|
+
'sourceTn' => source_tn,
|
348
|
+
'destinationTn' => destination_tn,
|
349
|
+
'messageStatus' => message_status,
|
350
|
+
'errorCode' => error_code,
|
351
|
+
'fromDateTime' => from_date_time,
|
352
|
+
'toDateTime' => to_date_time,
|
353
|
+
'pageToken' => page_token,
|
354
|
+
'limit' => limit
|
355
|
+
)
|
356
|
+
_query_url = APIHelper.clean_url _query_builder
|
357
|
+
|
358
|
+
# Prepare headers.
|
359
|
+
_headers = {
|
360
|
+
'accept' => 'application/json'
|
361
|
+
}
|
362
|
+
|
363
|
+
# Prepare and execute HttpRequest.
|
364
|
+
_request = config.http_client.get(
|
365
|
+
_query_url,
|
366
|
+
headers: _headers
|
367
|
+
)
|
368
|
+
MessagingBasicAuth.apply(config, _request)
|
369
|
+
_response = execute_request(_request)
|
370
|
+
|
371
|
+
# Validate response against endpoint and global error codes.
|
372
|
+
if _response.status_code == 400
|
373
|
+
raise MessagingException.new(
|
374
|
+
'400 Request is malformed or invalid',
|
375
|
+
_response
|
376
|
+
)
|
377
|
+
elsif _response.status_code == 401
|
378
|
+
raise MessagingException.new(
|
379
|
+
'401 The specified user does not have access to the account',
|
380
|
+
_response
|
381
|
+
)
|
382
|
+
elsif _response.status_code == 403
|
383
|
+
raise MessagingException.new(
|
384
|
+
'403 The user does not have access to this API',
|
385
|
+
_response
|
386
|
+
)
|
387
|
+
elsif _response.status_code == 404
|
388
|
+
raise MessagingException.new(
|
389
|
+
'404 Path not found',
|
390
|
+
_response
|
391
|
+
)
|
392
|
+
elsif _response.status_code == 415
|
393
|
+
raise MessagingException.new(
|
394
|
+
'415 The content-type of the request is incorrect',
|
395
|
+
_response
|
396
|
+
)
|
397
|
+
elsif _response.status_code == 429
|
398
|
+
raise MessagingException.new(
|
399
|
+
'429 The rate limit has been reached',
|
400
|
+
_response
|
401
|
+
)
|
402
|
+
end
|
403
|
+
validate_response(_response)
|
404
|
+
|
405
|
+
# Return appropriate response type.
|
406
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
407
|
+
ApiResponse.new(
|
408
|
+
_response, data: BandwidthMessagesList.from_hash(decoded)
|
409
|
+
)
|
410
|
+
end
|
411
|
+
|
297
412
|
# createMessage
|
298
|
-
# @param [String] user_id Required parameter:
|
299
|
-
# @param [MessageRequest] body
|
413
|
+
# @param [String] user_id Required parameter: User's account ID
|
414
|
+
# @param [MessageRequest] body Required parameter: Example:
|
300
415
|
# @return [BandwidthMessage] response from the API call
|
301
416
|
def create_message(user_id,
|
302
|
-
body
|
417
|
+
body)
|
303
418
|
# Prepare query url.
|
304
419
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
305
420
|
_query_builder << '/users/{userId}/messages'
|
@@ -6,47 +6,48 @@
|
|
6
6
|
module Bandwidth
|
7
7
|
# BandwidthMessage Model.
|
8
8
|
class BandwidthMessage < BaseModel
|
9
|
-
#
|
9
|
+
# The id of the message
|
10
10
|
# @return [String]
|
11
11
|
attr_accessor :id
|
12
12
|
|
13
|
-
#
|
13
|
+
# The Bandwidth phone number associated with the message
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :owner
|
16
16
|
|
17
|
-
#
|
17
|
+
# The application ID associated with the message
|
18
18
|
# @return [String]
|
19
19
|
attr_accessor :application_id
|
20
20
|
|
21
|
-
#
|
21
|
+
# The datetime stamp of the message in ISO 8601
|
22
22
|
# @return [String]
|
23
23
|
attr_accessor :time
|
24
24
|
|
25
|
-
#
|
25
|
+
# The number of segments the original message from the user is broken into
|
26
|
+
# before sending over to carrier networks
|
26
27
|
# @return [Integer]
|
27
28
|
attr_accessor :segment_count
|
28
29
|
|
29
|
-
#
|
30
|
+
# The direction of the message relative to Bandwidth. Can be in or out
|
30
31
|
# @return [String]
|
31
32
|
attr_accessor :direction
|
32
33
|
|
33
|
-
#
|
34
|
+
# The phone number recipients of the message
|
34
35
|
# @return [List of String]
|
35
36
|
attr_accessor :to
|
36
37
|
|
37
|
-
#
|
38
|
+
# The phone number the message was sent from
|
38
39
|
# @return [String]
|
39
40
|
attr_accessor :from
|
40
41
|
|
41
|
-
#
|
42
|
+
# The list of media URLs sent in the message
|
42
43
|
# @return [List of String]
|
43
44
|
attr_accessor :media
|
44
45
|
|
45
|
-
#
|
46
|
+
# The contents of the message
|
46
47
|
# @return [String]
|
47
48
|
attr_accessor :text
|
48
49
|
|
49
|
-
#
|
50
|
+
# The custom string set by the user
|
50
51
|
# @return [String]
|
51
52
|
attr_accessor :tag
|
52
53
|
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# BandwidthMessageItem Model.
|
8
|
+
class BandwidthMessageItem < BaseModel
|
9
|
+
# The message id
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :message_id
|
12
|
+
|
13
|
+
# The account id of the message
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :account_id
|
16
|
+
|
17
|
+
# The source phone number of the message
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :source_tn
|
20
|
+
|
21
|
+
# The recipient phone number of the message
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :destination_tn
|
24
|
+
|
25
|
+
# The status of the message
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :message_status
|
28
|
+
|
29
|
+
# The direction of the message relative to Bandwidth. INBOUND or OUTBOUND
|
30
|
+
# @return [String]
|
31
|
+
attr_accessor :message_direction
|
32
|
+
|
33
|
+
# The type of message. sms or mms
|
34
|
+
# @return [String]
|
35
|
+
attr_accessor :message_type
|
36
|
+
|
37
|
+
# The number of segments the message was sent as
|
38
|
+
# @return [Integer]
|
39
|
+
attr_accessor :segment_count
|
40
|
+
|
41
|
+
# The numeric error code of the message
|
42
|
+
# @return [Integer]
|
43
|
+
attr_accessor :error_code
|
44
|
+
|
45
|
+
# The ISO 8601 datetime of the message
|
46
|
+
# @return [String]
|
47
|
+
attr_accessor :receive_time
|
48
|
+
|
49
|
+
# The name of the carrier. Not currently supported for MMS, coming soon
|
50
|
+
# @return [String]
|
51
|
+
attr_accessor :carrier_name
|
52
|
+
|
53
|
+
# A mapping from model property names to API property names.
|
54
|
+
def self.names
|
55
|
+
@_hash = {} if @_hash.nil?
|
56
|
+
@_hash['message_id'] = 'messageId'
|
57
|
+
@_hash['account_id'] = 'accountId'
|
58
|
+
@_hash['source_tn'] = 'sourceTn'
|
59
|
+
@_hash['destination_tn'] = 'destinationTn'
|
60
|
+
@_hash['message_status'] = 'messageStatus'
|
61
|
+
@_hash['message_direction'] = 'messageDirection'
|
62
|
+
@_hash['message_type'] = 'messageType'
|
63
|
+
@_hash['segment_count'] = 'segmentCount'
|
64
|
+
@_hash['error_code'] = 'errorCode'
|
65
|
+
@_hash['receive_time'] = 'receiveTime'
|
66
|
+
@_hash['carrier_name'] = 'carrierName'
|
67
|
+
@_hash
|
68
|
+
end
|
69
|
+
|
70
|
+
def initialize(message_id = nil,
|
71
|
+
account_id = nil,
|
72
|
+
source_tn = nil,
|
73
|
+
destination_tn = nil,
|
74
|
+
message_status = nil,
|
75
|
+
message_direction = nil,
|
76
|
+
message_type = nil,
|
77
|
+
segment_count = nil,
|
78
|
+
error_code = nil,
|
79
|
+
receive_time = nil,
|
80
|
+
carrier_name = nil)
|
81
|
+
@message_id = message_id
|
82
|
+
@account_id = account_id
|
83
|
+
@source_tn = source_tn
|
84
|
+
@destination_tn = destination_tn
|
85
|
+
@message_status = message_status
|
86
|
+
@message_direction = message_direction
|
87
|
+
@message_type = message_type
|
88
|
+
@segment_count = segment_count
|
89
|
+
@error_code = error_code
|
90
|
+
@receive_time = receive_time
|
91
|
+
@carrier_name = carrier_name
|
92
|
+
end
|
93
|
+
|
94
|
+
# Creates an instance of the object from a hash.
|
95
|
+
def self.from_hash(hash)
|
96
|
+
return nil unless hash
|
97
|
+
|
98
|
+
# Extract variables from the hash.
|
99
|
+
message_id = hash['messageId']
|
100
|
+
account_id = hash['accountId']
|
101
|
+
source_tn = hash['sourceTn']
|
102
|
+
destination_tn = hash['destinationTn']
|
103
|
+
message_status = hash['messageStatus']
|
104
|
+
message_direction = hash['messageDirection']
|
105
|
+
message_type = hash['messageType']
|
106
|
+
segment_count = hash['segmentCount']
|
107
|
+
error_code = hash['errorCode']
|
108
|
+
receive_time = hash['receiveTime']
|
109
|
+
carrier_name = hash['carrierName']
|
110
|
+
|
111
|
+
# Create object from extracted values.
|
112
|
+
BandwidthMessageItem.new(message_id,
|
113
|
+
account_id,
|
114
|
+
source_tn,
|
115
|
+
destination_tn,
|
116
|
+
message_status,
|
117
|
+
message_direction,
|
118
|
+
message_type,
|
119
|
+
segment_count,
|
120
|
+
error_code,
|
121
|
+
receive_time,
|
122
|
+
carrier_name)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# BandwidthMessagesList Model.
|
8
|
+
class BandwidthMessagesList < BaseModel
|
9
|
+
# Total number of messages matched by the search
|
10
|
+
# @return [Integer]
|
11
|
+
attr_accessor :total_count
|
12
|
+
|
13
|
+
# Total number of messages matched by the search
|
14
|
+
# @return [PageInfo]
|
15
|
+
attr_accessor :page_info
|
16
|
+
|
17
|
+
# Total number of messages matched by the search
|
18
|
+
# @return [List of BandwidthMessageItem]
|
19
|
+
attr_accessor :messages
|
20
|
+
|
21
|
+
# A mapping from model property names to API property names.
|
22
|
+
def self.names
|
23
|
+
@_hash = {} if @_hash.nil?
|
24
|
+
@_hash['total_count'] = 'totalCount'
|
25
|
+
@_hash['page_info'] = 'pageInfo'
|
26
|
+
@_hash['messages'] = 'messages'
|
27
|
+
@_hash
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(total_count = nil,
|
31
|
+
page_info = nil,
|
32
|
+
messages = nil)
|
33
|
+
@total_count = total_count
|
34
|
+
@page_info = page_info
|
35
|
+
@messages = messages
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates an instance of the object from a hash.
|
39
|
+
def self.from_hash(hash)
|
40
|
+
return nil unless hash
|
41
|
+
|
42
|
+
# Extract variables from the hash.
|
43
|
+
total_count = hash['totalCount']
|
44
|
+
page_info = PageInfo.from_hash(hash['pageInfo']) if hash['pageInfo']
|
45
|
+
# Parameter is an array, so we need to iterate through it
|
46
|
+
messages = nil
|
47
|
+
unless hash['messages'].nil?
|
48
|
+
messages = []
|
49
|
+
hash['messages'].each do |structure|
|
50
|
+
messages << (BandwidthMessageItem.from_hash(structure) if structure)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Create object from extracted values.
|
55
|
+
BandwidthMessagesList.new(total_count,
|
56
|
+
page_info,
|
57
|
+
messages)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -30,19 +30,19 @@ module Bandwidth
|
|
30
30
|
# @return [List of Tag]
|
31
31
|
attr_accessor :tags
|
32
32
|
|
33
|
-
#
|
33
|
+
# User's account ID
|
34
34
|
# @return [String]
|
35
35
|
attr_accessor :user_id
|
36
36
|
|
37
|
-
#
|
37
|
+
# User's account ID
|
38
38
|
# @return [String]
|
39
39
|
attr_accessor :media_name
|
40
40
|
|
41
|
-
#
|
41
|
+
# User's account ID
|
42
42
|
# @return [String]
|
43
43
|
attr_accessor :media_id
|
44
44
|
|
45
|
-
#
|
45
|
+
# User's account ID
|
46
46
|
# @return [String]
|
47
47
|
attr_accessor :cache_control
|
48
48
|
|
@@ -6,27 +6,29 @@
|
|
6
6
|
module Bandwidth
|
7
7
|
# MessageRequest Model.
|
8
8
|
class MessageRequest < BaseModel
|
9
|
-
#
|
9
|
+
# The ID of the Application your from number is associated with in the
|
10
|
+
# Bandwidth Phone Number Dashboard.
|
10
11
|
# @return [String]
|
11
12
|
attr_accessor :application_id
|
12
13
|
|
13
|
-
#
|
14
|
+
# The phone number(s) the message should be sent to in E164 format
|
14
15
|
# @return [List of String]
|
15
16
|
attr_accessor :to
|
16
17
|
|
17
|
-
#
|
18
|
+
# One of your telephone numbers the message should come from in E164 format
|
18
19
|
# @return [String]
|
19
20
|
attr_accessor :from
|
20
21
|
|
21
|
-
#
|
22
|
+
# The contents of the text message. Must be 2048 characters or less.
|
22
23
|
# @return [String]
|
23
24
|
attr_accessor :text
|
24
25
|
|
25
|
-
#
|
26
|
+
# A list of URLs to include as media attachments as part of the message.
|
26
27
|
# @return [List of String]
|
27
28
|
attr_accessor :media
|
28
29
|
|
29
|
-
#
|
30
|
+
# A custom string that will be included in callback events of the message.
|
31
|
+
# Max 1024 characters
|
30
32
|
# @return [String]
|
31
33
|
attr_accessor :tag
|
32
34
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# PageInfo Model.
|
8
|
+
class PageInfo < BaseModel
|
9
|
+
# The link to the previous page for pagination
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :prev_page
|
12
|
+
|
13
|
+
# The link to the next page for pagination
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :next_page
|
16
|
+
|
17
|
+
# The isolated pagination token for the previous page
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :prev_page_token
|
20
|
+
|
21
|
+
# The isolated pagination token for the next page
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :next_page_token
|
24
|
+
|
25
|
+
# A mapping from model property names to API property names.
|
26
|
+
def self.names
|
27
|
+
@_hash = {} if @_hash.nil?
|
28
|
+
@_hash['prev_page'] = 'prevPage'
|
29
|
+
@_hash['next_page'] = 'nextPage'
|
30
|
+
@_hash['prev_page_token'] = 'prevPageToken'
|
31
|
+
@_hash['next_page_token'] = 'nextPageToken'
|
32
|
+
@_hash
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(prev_page = nil,
|
36
|
+
next_page = nil,
|
37
|
+
prev_page_token = nil,
|
38
|
+
next_page_token = nil)
|
39
|
+
@prev_page = prev_page
|
40
|
+
@next_page = next_page
|
41
|
+
@prev_page_token = prev_page_token
|
42
|
+
@next_page_token = next_page_token
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creates an instance of the object from a hash.
|
46
|
+
def self.from_hash(hash)
|
47
|
+
return nil unless hash
|
48
|
+
|
49
|
+
# Extract variables from the hash.
|
50
|
+
prev_page = hash['prevPage']
|
51
|
+
next_page = hash['nextPage']
|
52
|
+
prev_page_token = hash['prevPageToken']
|
53
|
+
next_page_token = hash['nextPageToken']
|
54
|
+
|
55
|
+
# Create object from extracted values.
|
56
|
+
PageInfo.new(prev_page,
|
57
|
+
next_page,
|
58
|
+
prev_page_token,
|
59
|
+
next_page_token)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'minitest/hell'
|
9
|
+
require 'minitest/pride'
|
10
|
+
require 'minitest/proveit'
|
11
|
+
require 'bandwidth'
|
12
|
+
require_relative '../test_helper'
|
13
|
+
require_relative '../http_response_catcher'
|
14
|
+
|
15
|
+
class ControllerTestBase < Minitest::Test
|
16
|
+
parallelize_me!
|
17
|
+
include Bandwidth
|
18
|
+
|
19
|
+
# Create configuration and set any test parameters
|
20
|
+
CONFIG = Configuration.new
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
class HttpResponseCatcher < Bandwidth::HttpCallBack
|
7
|
+
attr_accessor :response
|
8
|
+
|
9
|
+
def on_before_request(request)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Catching the response
|
13
|
+
def on_after_response(response)
|
14
|
+
@response = response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'tempfile'
|
7
|
+
require 'open-uri'
|
8
|
+
|
9
|
+
class TestHelper
|
10
|
+
|
11
|
+
@cache = Hash.new
|
12
|
+
|
13
|
+
# Class method to compare the received headers with the expected headers.
|
14
|
+
# @param [Hash] A hash of expected headers (keys in lower case).
|
15
|
+
# @param [Hash] A hash of received headers.
|
16
|
+
# @param [Boolean, optional] A flag which determines if we allow extra headers.
|
17
|
+
def self.match_headers(expected_headers,
|
18
|
+
received_headers,
|
19
|
+
allow_extra: true)
|
20
|
+
return false if ((received_headers.length < expected_headers.length) ||
|
21
|
+
((allow_extra == false) && (received_headers.length > expected_headers.length)))
|
22
|
+
|
23
|
+
received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}]
|
24
|
+
expected_headers.each do |e_key, e_value|
|
25
|
+
return false unless received_headers.key?(e_key)
|
26
|
+
return false if ((e_value != nil) &&
|
27
|
+
(e_value != received_headers[e_key]))
|
28
|
+
end
|
29
|
+
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
|
33
|
+
# Class method to compare the received body with the expected body.
|
34
|
+
# @param [Dynamic] The expected body.
|
35
|
+
# @param [Dynamic] The received body.
|
36
|
+
# @param [Boolean, optional] A flag which determines if we check values in dictionaries.
|
37
|
+
# @param [Boolean, optional] A flag which determines if we check the order of array elements.
|
38
|
+
# @param [Boolean, optional] A flag which determines if we check the count of array elements.
|
39
|
+
def self.match_body(expected_body,
|
40
|
+
received_body,
|
41
|
+
check_values: false,
|
42
|
+
check_order: false,
|
43
|
+
check_count: false)
|
44
|
+
if expected_body.instance_of? Hash
|
45
|
+
return false unless received_body.instance_of? Hash
|
46
|
+
for key in expected_body.keys
|
47
|
+
return false unless received_body.keys.include? key
|
48
|
+
if check_values or expected_body[key].instance_of? Hash
|
49
|
+
return false unless TestHelper.match_body(expected_body[key],
|
50
|
+
received_body[key],
|
51
|
+
check_values: check_values,
|
52
|
+
check_order: check_order,
|
53
|
+
check_count: check_count)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
elsif expected_body.instance_of? Array
|
57
|
+
return False unless received_body.instance_of? Array
|
58
|
+
if check_count == true && (expected_body.length != received_body.length)
|
59
|
+
return false
|
60
|
+
else
|
61
|
+
previous_matches = Array.new
|
62
|
+
expected_body.each.with_index do |expected_element, i|
|
63
|
+
matches = (received_body.map.with_index do |received_element, j|
|
64
|
+
j if TestHelper.match_body(expected_element,
|
65
|
+
received_element,
|
66
|
+
check_values: check_values,
|
67
|
+
check_order: check_order,
|
68
|
+
check_count: check_count)
|
69
|
+
end).compact
|
70
|
+
return false if matches.length == 0
|
71
|
+
if check_order == true
|
72
|
+
return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
|
73
|
+
previous_matches = matches
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
elsif expected_body != received_body
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Class method which takes a URL, downloads the file (if not already downloaded
|
84
|
+
# for this test session) and returns the path of the file.
|
85
|
+
# @param [String] The URL of the required file.
|
86
|
+
def self.get_file(url)
|
87
|
+
unless @cache.keys.include? url
|
88
|
+
@cache[url] = Tempfile.new('APIMatic')
|
89
|
+
@cache[url].binmode
|
90
|
+
@cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
|
91
|
+
end
|
92
|
+
return @cache[url].path
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bandwidth-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- APIMatic SDK Generator
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01
|
11
|
+
date: 2021-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -106,6 +106,40 @@ dependencies:
|
|
106
106
|
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: 3.2.4
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: minitest
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '5.14'
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 5.14.1
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '5.14'
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 5.14.1
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: minitest-proveit
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '1.0'
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - "~>"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '1.0'
|
109
143
|
description: Bandwidth's set of APIs
|
110
144
|
email: support@apimatic.io
|
111
145
|
executables: []
|
@@ -137,9 +171,12 @@ files:
|
|
137
171
|
- lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb
|
138
172
|
- lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb
|
139
173
|
- lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb
|
174
|
+
- lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb
|
175
|
+
- lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb
|
140
176
|
- lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb
|
141
177
|
- lib/bandwidth/messaging_lib/messaging/models/media.rb
|
142
178
|
- lib/bandwidth/messaging_lib/messaging/models/message_request.rb
|
179
|
+
- lib/bandwidth/messaging_lib/messaging/models/page_info.rb
|
143
180
|
- lib/bandwidth/messaging_lib/messaging/models/tag.rb
|
144
181
|
- lib/bandwidth/models/base_model.rb
|
145
182
|
- lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb
|
@@ -190,7 +227,6 @@ files:
|
|
190
227
|
- lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb
|
191
228
|
- lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb
|
192
229
|
- lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb
|
193
|
-
- lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb
|
194
230
|
- lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb
|
195
231
|
- lib/bandwidth/voice_lib/voice/models/conference_detail.rb
|
196
232
|
- lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb
|
@@ -225,6 +261,9 @@ files:
|
|
225
261
|
- lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb
|
226
262
|
- lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb
|
227
263
|
- lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb
|
264
|
+
- test/controllers/controller_test_base.rb
|
265
|
+
- test/http_response_catcher.rb
|
266
|
+
- test/test_helper.rb
|
228
267
|
homepage: https://apimatic.io
|
229
268
|
licenses:
|
230
269
|
- MIT
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# bandwidth
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Bandwidth
|
7
|
-
# CallEngineModifyConferenceRequest Model.
|
8
|
-
class CallEngineModifyConferenceRequest < BaseModel
|
9
|
-
# TODO: Write general description for this method
|
10
|
-
# @return [StatusEnum]
|
11
|
-
attr_accessor :status
|
12
|
-
|
13
|
-
# TODO: Write general description for this method
|
14
|
-
# @return [String]
|
15
|
-
attr_accessor :redirect_url
|
16
|
-
|
17
|
-
# TODO: Write general description for this method
|
18
|
-
# @return [String]
|
19
|
-
attr_accessor :redirect_fallback_url
|
20
|
-
|
21
|
-
# TODO: Write general description for this method
|
22
|
-
# @return [RedirectMethodEnum]
|
23
|
-
attr_accessor :redirect_method
|
24
|
-
|
25
|
-
# TODO: Write general description for this method
|
26
|
-
# @return [RedirectFallbackMethodEnum]
|
27
|
-
attr_accessor :redirect_fallback_method
|
28
|
-
|
29
|
-
# TODO: Write general description for this method
|
30
|
-
# @return [String]
|
31
|
-
attr_accessor :username
|
32
|
-
|
33
|
-
# TODO: Write general description for this method
|
34
|
-
# @return [String]
|
35
|
-
attr_accessor :password
|
36
|
-
|
37
|
-
# TODO: Write general description for this method
|
38
|
-
# @return [String]
|
39
|
-
attr_accessor :fallback_username
|
40
|
-
|
41
|
-
# TODO: Write general description for this method
|
42
|
-
# @return [String]
|
43
|
-
attr_accessor :fallback_password
|
44
|
-
|
45
|
-
# A mapping from model property names to API property names.
|
46
|
-
def self.names
|
47
|
-
@_hash = {} if @_hash.nil?
|
48
|
-
@_hash['status'] = 'status'
|
49
|
-
@_hash['redirect_url'] = 'redirectUrl'
|
50
|
-
@_hash['redirect_fallback_url'] = 'redirectFallbackUrl'
|
51
|
-
@_hash['redirect_method'] = 'redirectMethod'
|
52
|
-
@_hash['redirect_fallback_method'] = 'redirectFallbackMethod'
|
53
|
-
@_hash['username'] = 'username'
|
54
|
-
@_hash['password'] = 'password'
|
55
|
-
@_hash['fallback_username'] = 'fallbackUsername'
|
56
|
-
@_hash['fallback_password'] = 'fallbackPassword'
|
57
|
-
@_hash
|
58
|
-
end
|
59
|
-
|
60
|
-
def initialize(redirect_url = nil,
|
61
|
-
status = nil,
|
62
|
-
redirect_fallback_url = nil,
|
63
|
-
redirect_method = nil,
|
64
|
-
redirect_fallback_method = nil,
|
65
|
-
username = nil,
|
66
|
-
password = nil,
|
67
|
-
fallback_username = nil,
|
68
|
-
fallback_password = nil)
|
69
|
-
@status = status
|
70
|
-
@redirect_url = redirect_url
|
71
|
-
@redirect_fallback_url = redirect_fallback_url
|
72
|
-
@redirect_method = redirect_method
|
73
|
-
@redirect_fallback_method = redirect_fallback_method
|
74
|
-
@username = username
|
75
|
-
@password = password
|
76
|
-
@fallback_username = fallback_username
|
77
|
-
@fallback_password = fallback_password
|
78
|
-
end
|
79
|
-
|
80
|
-
# Creates an instance of the object from a hash.
|
81
|
-
def self.from_hash(hash)
|
82
|
-
return nil unless hash
|
83
|
-
|
84
|
-
# Extract variables from the hash.
|
85
|
-
redirect_url = hash['redirectUrl']
|
86
|
-
status = hash['status']
|
87
|
-
redirect_fallback_url = hash['redirectFallbackUrl']
|
88
|
-
redirect_method = hash['redirectMethod']
|
89
|
-
redirect_fallback_method = hash['redirectFallbackMethod']
|
90
|
-
username = hash['username']
|
91
|
-
password = hash['password']
|
92
|
-
fallback_username = hash['fallbackUsername']
|
93
|
-
fallback_password = hash['fallbackPassword']
|
94
|
-
|
95
|
-
# Create object from extracted values.
|
96
|
-
CallEngineModifyConferenceRequest.new(redirect_url,
|
97
|
-
status,
|
98
|
-
redirect_fallback_url,
|
99
|
-
redirect_method,
|
100
|
-
redirect_fallback_method,
|
101
|
-
username,
|
102
|
-
password,
|
103
|
-
fallback_username,
|
104
|
-
fallback_password)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|