bandwidth-sdk 6.1.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +89 -12
- data/lib/bandwidth.rb +5 -2
- data/lib/bandwidth/api_helper.rb +5 -17
- data/lib/bandwidth/client.rb +23 -9
- data/lib/bandwidth/configuration.rb +54 -18
- data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb} +3 -3
- data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +22 -0
- data/lib/bandwidth/http/faraday_client.rb +5 -2
- data/lib/bandwidth/messaging_lib/messaging/client.rb +14 -5
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +25 -29
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +47 -2
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +5 -75
- data/lib/bandwidth/models/base_model.rb +19 -8
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +23 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/client.rb +15 -6
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/base_controller.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/mfa_controller.rb +7 -7
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/error_with_request_exception.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/forbidden_request_exception.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/unauthorized_request_exception.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_code_request_schema.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_messaging_response.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_code_response.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_request_schema.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_voice_response.rb +0 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +20 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +60 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +1551 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +29 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +35 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +45 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +74 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +107 -0
- data/lib/bandwidth/utilities/date_time_helper.rb +156 -0
- data/lib/bandwidth/voice_lib/voice.rb +14 -18
- data/lib/bandwidth/voice_lib/voice/client.rb +14 -5
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +248 -230
- data/lib/bandwidth/voice_lib/voice/exceptions/{api_error_response_exception.rb → api_error_exception.rb} +2 -2
- data/lib/bandwidth/voice_lib/voice/models/{recording_metadata_response.rb → call_recording_metadata.rb} +47 -28
- data/lib/bandwidth/voice_lib/voice/models/call_state.rb +232 -0
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +2 -20
- data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +2 -20
- data/lib/bandwidth/voice_lib/voice/models/{conference_member_detail.rb → conference_member_state.rb} +8 -8
- data/lib/bandwidth/voice_lib/voice/models/{conference_recording_metadata_response.rb → conference_recording_metadata.rb} +34 -18
- data/lib/bandwidth/voice_lib/voice/models/{conference_detail.rb → conference_state.rb} +22 -14
- data/lib/bandwidth/voice_lib/voice/models/{api_create_call_request.rb → create_call_request.rb} +35 -59
- data/lib/bandwidth/voice_lib/voice/models/{api_call_response.rb → create_call_response.rb} +28 -23
- data/lib/bandwidth/voice_lib/voice/models/{modify_call_recording_state.rb → modify_call_recording_request.rb} +4 -4
- data/lib/bandwidth/voice_lib/voice/models/{api_modify_call_request.rb → modify_call_request.rb} +25 -25
- data/lib/bandwidth/voice_lib/voice/models/{api_modify_conference_request.rb → modify_conference_request.rb} +11 -11
- data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +7 -4
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +4 -7
- data/lib/bandwidth/voice_lib/voice/models/{api_transcribe_recording_request.rb → transcribe_recording_request.rb} +8 -8
- data/lib/bandwidth/voice_lib/voice/models/{transcription.rb → transcription_metadata.rb} +19 -10
- data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +7 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +14 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +14 -14
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +2 -2
- data/test/controllers/controller_test_base.rb +21 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/integration/test_integration.rb +39 -13
- data/test/test_helper.rb +94 -0
- metadata +47 -37
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +0 -22
- data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +0 -164
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +0 -47
- data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +0 -29
- data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +0 -32
data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb}
RENAMED
@@ -7,13 +7,13 @@ require 'base64'
|
|
7
7
|
|
8
8
|
module Bandwidth
|
9
9
|
# Utility class for basic authorization.
|
10
|
-
class
|
10
|
+
class MultiFactorAuthBasicAuth
|
11
11
|
# Add basic authentication to the request.
|
12
12
|
# @param [HttpRequest] The HttpRequest object to which authentication will
|
13
13
|
# be added.
|
14
14
|
def self.apply(config, http_request)
|
15
|
-
username = config.
|
16
|
-
password = config.
|
15
|
+
username = config.multi_factor_auth_basic_auth_user_name
|
16
|
+
password = config.multi_factor_auth_basic_auth_password
|
17
17
|
value = Base64.strict_encode64("#{username}:#{password}")
|
18
18
|
header_value = "Basic #{value}"
|
19
19
|
http_request.headers['Authorization'] = header_value
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
module Bandwidth
|
9
|
+
# Utility class for basic authorization.
|
10
|
+
class PhoneNumberLookupBasicAuth
|
11
|
+
# Add basic authentication to the request.
|
12
|
+
# @param [HttpRequest] The HttpRequest object to which authentication will
|
13
|
+
# be added.
|
14
|
+
def self.apply(config, http_request)
|
15
|
+
username = config.phone_number_lookup_basic_auth_user_name
|
16
|
+
password = config.phone_number_lookup_basic_auth_password
|
17
|
+
value = Base64.strict_encode64("#{username}:#{password}")
|
18
|
+
header_value = "Basic #{value}"
|
19
|
+
http_request.headers['Authorization'] = header_value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -11,7 +11,8 @@ module Bandwidth
|
|
11
11
|
class FaradayClient < HttpClient
|
12
12
|
# The constructor.
|
13
13
|
def initialize(timeout:, max_retries:, retry_interval:,
|
14
|
-
backoff_factor:,
|
14
|
+
backoff_factor:, retry_statuses:, retry_methods:,
|
15
|
+
cache: false, verify: true)
|
15
16
|
@connection = Faraday.new do |faraday|
|
16
17
|
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
17
18
|
faraday.use FaradayMiddleware::FollowRedirects
|
@@ -21,7 +22,9 @@ module Bandwidth
|
|
21
22
|
faraday.ssl[:ca_file] = Certifi.where
|
22
23
|
faraday.ssl[:verify] = verify
|
23
24
|
faraday.request :retry, max: max_retries, interval: retry_interval,
|
24
|
-
backoff_factor: backoff_factor
|
25
|
+
backoff_factor: backoff_factor,
|
26
|
+
retry_statuses: retry_statuses,
|
27
|
+
methods: retry_methods
|
25
28
|
faraday.adapter Faraday.default_adapter
|
26
29
|
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
27
30
|
faraday.options[:timeout] = timeout if timeout > 0
|
@@ -16,12 +16,17 @@ module Bandwidth
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
19
|
-
backoff_factor:
|
19
|
+
backoff_factor: 2,
|
20
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
21
|
+
retry_methods: %i[get put get put],
|
22
|
+
environment: Environment::PRODUCTION,
|
20
23
|
base_url: 'https://www.example.com',
|
21
24
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
22
25
|
messaging_basic_auth_password: 'TODO: Replace',
|
23
|
-
|
24
|
-
|
26
|
+
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
27
|
+
multi_factor_auth_basic_auth_password: 'TODO: Replace',
|
28
|
+
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
29
|
+
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
25
30
|
voice_basic_auth_user_name: 'TODO: Replace',
|
26
31
|
voice_basic_auth_password: 'TODO: Replace',
|
27
32
|
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
@@ -32,12 +37,16 @@ module Bandwidth
|
|
32
37
|
max_retries: max_retries,
|
33
38
|
retry_interval: retry_interval,
|
34
39
|
backoff_factor: backoff_factor,
|
40
|
+
retry_statuses: retry_statuses,
|
41
|
+
retry_methods: retry_methods,
|
35
42
|
environment: environment,
|
36
43
|
base_url: base_url,
|
37
44
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
38
45
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
39
|
-
|
40
|
-
|
46
|
+
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
|
47
|
+
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
|
48
|
+
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
49
|
+
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
41
50
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
42
51
|
voice_basic_auth_password: voice_basic_auth_password,
|
43
52
|
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
@@ -12,18 +12,18 @@ module Messaging
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# listMedia
|
15
|
-
# @param [String]
|
15
|
+
# @param [String] account_id Required parameter: User's account ID
|
16
16
|
# @param [String] continuation_token Optional parameter: Continuation token
|
17
17
|
# used to retrieve subsequent media.
|
18
18
|
# @return [List of Media] response from the API call
|
19
|
-
def list_media(
|
19
|
+
def list_media(account_id,
|
20
20
|
continuation_token: nil)
|
21
21
|
# Prepare query url.
|
22
22
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
23
|
-
_query_builder << '/users/{
|
23
|
+
_query_builder << '/users/{accountId}/media'
|
24
24
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
25
25
|
_query_builder,
|
26
|
-
'
|
26
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
27
27
|
)
|
28
28
|
_query_url = APIHelper.clean_url _query_builder
|
29
29
|
|
@@ -84,17 +84,17 @@ module Messaging
|
|
84
84
|
end
|
85
85
|
|
86
86
|
# getMedia
|
87
|
-
# @param [String]
|
87
|
+
# @param [String] account_id Required parameter: User's account ID
|
88
88
|
# @param [String] media_id Required parameter: Media ID to retrieve
|
89
89
|
# @return [Binary] response from the API call
|
90
|
-
def get_media(
|
90
|
+
def get_media(account_id,
|
91
91
|
media_id)
|
92
92
|
# Prepare query url.
|
93
93
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
94
|
-
_query_builder << '/users/{
|
94
|
+
_query_builder << '/users/{accountId}/media/{mediaId}'
|
95
95
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
96
96
|
_query_builder,
|
97
|
-
'
|
97
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
98
98
|
'mediaId' => { 'value' => media_id, 'encode' => false }
|
99
99
|
)
|
100
100
|
_query_url = APIHelper.clean_url _query_builder
|
@@ -147,11 +147,9 @@ module Messaging
|
|
147
147
|
end
|
148
148
|
|
149
149
|
# uploadMedia
|
150
|
-
# @param [String]
|
150
|
+
# @param [String] account_id Required parameter: User's account ID
|
151
151
|
# @param [String] media_id Required parameter: The user supplied custom
|
152
152
|
# media ID
|
153
|
-
# @param [Long] content_length Required parameter: The size of the
|
154
|
-
# entity-body
|
155
153
|
# @param [File | UploadIO] body Required parameter: Example:
|
156
154
|
# @param [String] content_type Optional parameter: The media type of the
|
157
155
|
# entity-body
|
@@ -159,18 +157,17 @@ module Messaging
|
|
159
157
|
# used to specify directives that MUST be obeyed by all caching mechanisms
|
160
158
|
# along the request/response chain.
|
161
159
|
# @return [void] response from the API call
|
162
|
-
def upload_media(
|
160
|
+
def upload_media(account_id,
|
163
161
|
media_id,
|
164
|
-
content_length,
|
165
162
|
body,
|
166
163
|
content_type: 'application/octet-stream',
|
167
164
|
cache_control: nil)
|
168
165
|
# Prepare query url.
|
169
166
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
170
|
-
_query_builder << '/users/{
|
167
|
+
_query_builder << '/users/{accountId}/media/{mediaId}'
|
171
168
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
172
169
|
_query_builder,
|
173
|
-
'
|
170
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
174
171
|
'mediaId' => { 'value' => media_id, 'encode' => false }
|
175
172
|
)
|
176
173
|
_query_url = APIHelper.clean_url _query_builder
|
@@ -187,7 +184,6 @@ module Messaging
|
|
187
184
|
_headers = {
|
188
185
|
'content-type' => body_content_type,
|
189
186
|
'content-length' => body_wrapper.size.to_s,
|
190
|
-
'Content-Length' => content_length,
|
191
187
|
'Cache-Control' => cache_control
|
192
188
|
}
|
193
189
|
|
@@ -239,17 +235,17 @@ module Messaging
|
|
239
235
|
end
|
240
236
|
|
241
237
|
# deleteMedia
|
242
|
-
# @param [String]
|
238
|
+
# @param [String] account_id Required parameter: User's account ID
|
243
239
|
# @param [String] media_id Required parameter: The media ID to delete
|
244
240
|
# @return [void] response from the API call
|
245
|
-
def delete_media(
|
241
|
+
def delete_media(account_id,
|
246
242
|
media_id)
|
247
243
|
# Prepare query url.
|
248
244
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
249
|
-
_query_builder << '/users/{
|
245
|
+
_query_builder << '/users/{accountId}/media/{mediaId}'
|
250
246
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
251
247
|
_query_builder,
|
252
|
-
'
|
248
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
253
249
|
'mediaId' => { 'value' => media_id, 'encode' => false }
|
254
250
|
)
|
255
251
|
_query_url = APIHelper.clean_url _query_builder
|
@@ -300,7 +296,7 @@ module Messaging
|
|
300
296
|
end
|
301
297
|
|
302
298
|
# getMessages
|
303
|
-
# @param [String]
|
299
|
+
# @param [String] account_id Required parameter: User's account ID
|
304
300
|
# @param [String] message_id Optional parameter: The ID of the message to
|
305
301
|
# search for. Special characters need to be encoded using URL encoding
|
306
302
|
# @param [String] source_tn Optional parameter: The phone number that sent
|
@@ -309,7 +305,7 @@ module Messaging
|
|
309
305
|
# received the message
|
310
306
|
# @param [String] message_status Optional parameter: The status of the
|
311
307
|
# message. One of RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED,
|
312
|
-
#
|
308
|
+
# ACCEPTED, UNDELIVERED
|
313
309
|
# @param [Integer] error_code Optional parameter: The error code of the
|
314
310
|
# message
|
315
311
|
# @param [String] from_date_time Optional parameter: The start of the date
|
@@ -324,7 +320,7 @@ module Messaging
|
|
324
320
|
# in search result. Default 100. The sum of limit and after cannot be more
|
325
321
|
# than 10000
|
326
322
|
# @return [BandwidthMessagesList] response from the API call
|
327
|
-
def get_messages(
|
323
|
+
def get_messages(account_id,
|
328
324
|
message_id: nil,
|
329
325
|
source_tn: nil,
|
330
326
|
destination_tn: nil,
|
@@ -336,10 +332,10 @@ module Messaging
|
|
336
332
|
limit: nil)
|
337
333
|
# Prepare query url.
|
338
334
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
339
|
-
_query_builder << '/users/{
|
335
|
+
_query_builder << '/users/{accountId}/messages'
|
340
336
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
341
337
|
_query_builder,
|
342
|
-
'
|
338
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
343
339
|
)
|
344
340
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
345
341
|
_query_builder,
|
@@ -410,17 +406,17 @@ module Messaging
|
|
410
406
|
end
|
411
407
|
|
412
408
|
# createMessage
|
413
|
-
# @param [String]
|
409
|
+
# @param [String] account_id Required parameter: User's account ID
|
414
410
|
# @param [MessageRequest] body Required parameter: Example:
|
415
411
|
# @return [BandwidthMessage] response from the API call
|
416
|
-
def create_message(
|
412
|
+
def create_message(account_id,
|
417
413
|
body)
|
418
414
|
# Prepare query url.
|
419
415
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
420
|
-
_query_builder << '/users/{
|
416
|
+
_query_builder << '/users/{accountId}/messages'
|
421
417
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
422
418
|
_query_builder,
|
423
|
-
'
|
419
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
424
420
|
)
|
425
421
|
_query_url = APIHelper.clean_url _query_builder
|
426
422
|
|
@@ -50,6 +50,26 @@ module Bandwidth
|
|
50
50
|
# @return [String]
|
51
51
|
attr_accessor :carrier_name
|
52
52
|
|
53
|
+
# The size of the message including message content and headers
|
54
|
+
# @return [Integer]
|
55
|
+
attr_accessor :message_size
|
56
|
+
|
57
|
+
# The length of the message content
|
58
|
+
# @return [Integer]
|
59
|
+
attr_accessor :message_length
|
60
|
+
|
61
|
+
# The number of attachments the message has
|
62
|
+
# @return [Integer]
|
63
|
+
attr_accessor :attachment_count
|
64
|
+
|
65
|
+
# The number of recipients the message has
|
66
|
+
# @return [Integer]
|
67
|
+
attr_accessor :recipient_count
|
68
|
+
|
69
|
+
# The campaign class of the message, if it has one
|
70
|
+
# @return [String]
|
71
|
+
attr_accessor :campaign_class
|
72
|
+
|
53
73
|
# A mapping from model property names to API property names.
|
54
74
|
def self.names
|
55
75
|
@_hash = {} if @_hash.nil?
|
@@ -64,6 +84,11 @@ module Bandwidth
|
|
64
84
|
@_hash['error_code'] = 'errorCode'
|
65
85
|
@_hash['receive_time'] = 'receiveTime'
|
66
86
|
@_hash['carrier_name'] = 'carrierName'
|
87
|
+
@_hash['message_size'] = 'messageSize'
|
88
|
+
@_hash['message_length'] = 'messageLength'
|
89
|
+
@_hash['attachment_count'] = 'attachmentCount'
|
90
|
+
@_hash['recipient_count'] = 'recipientCount'
|
91
|
+
@_hash['campaign_class'] = 'campaignClass'
|
67
92
|
@_hash
|
68
93
|
end
|
69
94
|
|
@@ -77,7 +102,12 @@ module Bandwidth
|
|
77
102
|
segment_count = nil,
|
78
103
|
error_code = nil,
|
79
104
|
receive_time = nil,
|
80
|
-
carrier_name = nil
|
105
|
+
carrier_name = nil,
|
106
|
+
message_size = nil,
|
107
|
+
message_length = nil,
|
108
|
+
attachment_count = nil,
|
109
|
+
recipient_count = nil,
|
110
|
+
campaign_class = nil)
|
81
111
|
@message_id = message_id
|
82
112
|
@account_id = account_id
|
83
113
|
@source_tn = source_tn
|
@@ -89,6 +119,11 @@ module Bandwidth
|
|
89
119
|
@error_code = error_code
|
90
120
|
@receive_time = receive_time
|
91
121
|
@carrier_name = carrier_name
|
122
|
+
@message_size = message_size
|
123
|
+
@message_length = message_length
|
124
|
+
@attachment_count = attachment_count
|
125
|
+
@recipient_count = recipient_count
|
126
|
+
@campaign_class = campaign_class
|
92
127
|
end
|
93
128
|
|
94
129
|
# Creates an instance of the object from a hash.
|
@@ -107,6 +142,11 @@ module Bandwidth
|
|
107
142
|
error_code = hash['errorCode']
|
108
143
|
receive_time = hash['receiveTime']
|
109
144
|
carrier_name = hash['carrierName']
|
145
|
+
message_size = hash['messageSize']
|
146
|
+
message_length = hash['messageLength']
|
147
|
+
attachment_count = hash['attachmentCount']
|
148
|
+
recipient_count = hash['recipientCount']
|
149
|
+
campaign_class = hash['campaignClass']
|
110
150
|
|
111
151
|
# Create object from extracted values.
|
112
152
|
BandwidthMessageItem.new(message_id,
|
@@ -119,7 +159,12 @@ module Bandwidth
|
|
119
159
|
segment_count,
|
120
160
|
error_code,
|
121
161
|
receive_time,
|
122
|
-
carrier_name
|
162
|
+
carrier_name,
|
163
|
+
message_size,
|
164
|
+
message_length,
|
165
|
+
attachment_count,
|
166
|
+
recipient_count,
|
167
|
+
campaign_class)
|
123
168
|
end
|
124
169
|
end
|
125
170
|
end
|
@@ -6,82 +6,33 @@
|
|
6
6
|
module Bandwidth
|
7
7
|
# Media Model.
|
8
8
|
class Media < BaseModel
|
9
|
-
# TODO: Write general description for this method
|
10
|
-
# @return [Object]
|
11
|
-
attr_accessor :input_stream
|
12
|
-
|
13
9
|
# TODO: Write general description for this method
|
14
10
|
# @return [String]
|
15
11
|
attr_accessor :content
|
16
12
|
|
17
13
|
# TODO: Write general description for this method
|
18
|
-
# @return [
|
19
|
-
attr_accessor :url
|
20
|
-
|
21
|
-
# TODO: Write general description for this method
|
22
|
-
# @return [String]
|
14
|
+
# @return [Integer]
|
23
15
|
attr_accessor :content_length
|
24
16
|
|
25
17
|
# TODO: Write general description for this method
|
26
18
|
# @return [String]
|
27
|
-
attr_accessor :content_type
|
28
|
-
|
29
|
-
# TODO: Write general description for this method
|
30
|
-
# @return [List of Tag]
|
31
|
-
attr_accessor :tags
|
32
|
-
|
33
|
-
# User's account ID
|
34
|
-
# @return [String]
|
35
|
-
attr_accessor :user_id
|
36
|
-
|
37
|
-
# User's account ID
|
38
|
-
# @return [String]
|
39
19
|
attr_accessor :media_name
|
40
20
|
|
41
|
-
# User's account ID
|
42
|
-
# @return [String]
|
43
|
-
attr_accessor :media_id
|
44
|
-
|
45
|
-
# User's account ID
|
46
|
-
# @return [String]
|
47
|
-
attr_accessor :cache_control
|
48
|
-
|
49
21
|
# A mapping from model property names to API property names.
|
50
22
|
def self.names
|
51
23
|
@_hash = {} if @_hash.nil?
|
52
|
-
@_hash['input_stream'] = 'inputStream'
|
53
24
|
@_hash['content'] = 'content'
|
54
|
-
@_hash['url'] = 'url'
|
55
25
|
@_hash['content_length'] = 'contentLength'
|
56
|
-
@_hash['content_type'] = 'contentType'
|
57
|
-
@_hash['tags'] = 'tags'
|
58
|
-
@_hash['user_id'] = 'userId'
|
59
26
|
@_hash['media_name'] = 'mediaName'
|
60
|
-
@_hash['media_id'] = 'mediaId'
|
61
|
-
@_hash['cache_control'] = 'cacheControl'
|
62
27
|
@_hash
|
63
28
|
end
|
64
29
|
|
65
|
-
def initialize(
|
66
|
-
content = nil,
|
67
|
-
url = nil,
|
30
|
+
def initialize(content = nil,
|
68
31
|
content_length = nil,
|
69
|
-
|
70
|
-
tags = nil,
|
71
|
-
user_id = nil,
|
72
|
-
media_name = nil,
|
73
|
-
media_id = nil,
|
74
|
-
cache_control = nil)
|
75
|
-
@input_stream = input_stream
|
32
|
+
media_name = nil)
|
76
33
|
@content = content
|
77
|
-
@url = url
|
78
34
|
@content_length = content_length
|
79
|
-
@content_type = content_type
|
80
|
-
@tags = tags
|
81
|
-
@user_id = user_id
|
82
35
|
@media_name = media_name
|
83
|
-
@media_id = media_id
|
84
|
-
@cache_control = cache_control
|
85
36
|
end
|
86
37
|
|
87
38
|
# Creates an instance of the object from a hash.
|
@@ -89,35 +40,14 @@ module Bandwidth
|
|
89
40
|
return nil unless hash
|
90
41
|
|
91
42
|
# Extract variables from the hash.
|
92
|
-
input_stream = hash['inputStream']
|
93
43
|
content = hash['content']
|
94
|
-
url = hash['url']
|
95
44
|
content_length = hash['contentLength']
|
96
|
-
content_type = hash['contentType']
|
97
|
-
# Parameter is an array, so we need to iterate through it
|
98
|
-
tags = nil
|
99
|
-
unless hash['tags'].nil?
|
100
|
-
tags = []
|
101
|
-
hash['tags'].each do |structure|
|
102
|
-
tags << (Tag.from_hash(structure) if structure)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
user_id = hash['userId']
|
106
45
|
media_name = hash['mediaName']
|
107
|
-
media_id = hash['mediaId']
|
108
|
-
cache_control = hash['cacheControl']
|
109
46
|
|
110
47
|
# Create object from extracted values.
|
111
|
-
Media.new(
|
112
|
-
content,
|
113
|
-
url,
|
48
|
+
Media.new(content,
|
114
49
|
content_length,
|
115
|
-
|
116
|
-
tags,
|
117
|
-
user_id,
|
118
|
-
media_name,
|
119
|
-
media_id,
|
120
|
-
cache_control)
|
50
|
+
media_name)
|
121
51
|
end
|
122
52
|
end
|
123
53
|
end
|