bandwidth-sdk 3.13.2 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +90 -13
  4. data/lib/bandwidth.rb +2 -0
  5. data/lib/bandwidth/api_helper.rb +5 -5
  6. data/lib/bandwidth/client.rb +15 -1
  7. data/lib/bandwidth/configuration.rb +40 -4
  8. data/lib/bandwidth/http/api_response.rb +2 -0
  9. data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +22 -0
  10. data/lib/bandwidth/http/faraday_client.rb +14 -4
  11. data/lib/bandwidth/messaging_lib/messaging.rb +4 -0
  12. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +135 -20
  13. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  14. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +23 -13
  15. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +125 -0
  16. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +60 -0
  17. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +4 -4
  18. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +21 -8
  19. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +62 -0
  20. data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +19 -0
  21. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +20 -0
  22. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +60 -0
  23. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +1551 -0
  24. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +49 -0
  25. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb → phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb} +5 -5
  26. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +35 -0
  27. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +45 -0
  28. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +74 -0
  29. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +107 -0
  30. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +4 -2
  31. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +4 -4
  32. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +1 -1
  33. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/{api_controller.rb → mfa_controller.rb} +65 -14
  34. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb +34 -0
  35. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/forbidden_request_exception.rb +29 -0
  36. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb +29 -0
  37. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +0 -19
  38. data/lib/bandwidth/voice_lib/voice.rb +1 -1
  39. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +51 -52
  40. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  41. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +77 -17
  42. data/lib/bandwidth/voice_lib/voice/models/{call_engine_modify_conference_request.rb → api_modify_conference_request.rb} +14 -14
  43. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +3 -3
  44. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +1 -0
  45. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +10 -1
  46. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +24 -24
  47. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +1 -1
  48. data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +17 -0
  49. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +11 -2
  50. data/test/controllers/controller_test_base.rb +21 -0
  51. data/test/http_response_catcher.rb +19 -0
  52. data/test/integration/test_integration.rb +583 -0
  53. data/test/test_helper.rb +94 -0
  54. metadata +66 -11
@@ -11,16 +11,20 @@ module Bandwidth
11
11
  class FaradayClient < HttpClient
12
12
  # The constructor.
13
13
  def initialize(timeout:, max_retries:, retry_interval:,
14
- backoff_factor:, cache: false, verify: true)
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
19
+ faraday.use :gzip
18
20
  faraday.request :multipart
19
21
  faraday.request :url_encoded
20
22
  faraday.ssl[:ca_file] = Certifi.where
21
23
  faraday.ssl[:verify] = verify
22
24
  faraday.request :retry, max: max_retries, interval: retry_interval,
23
- backoff_factor: backoff_factor
25
+ backoff_factor: backoff_factor,
26
+ retry_statuses: retry_statuses,
27
+ methods: retry_methods
24
28
  faraday.adapter Faraday.default_adapter
25
29
  faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
26
30
  faraday.options[:timeout] = timeout if timeout > 0
@@ -34,7 +38,10 @@ module Bandwidth
34
38
  http_request.query_url
35
39
  ) do |request|
36
40
  request.headers = http_request.headers
37
- request.body = http_request.parameters
41
+ unless http_request.http_method == HttpMethodEnum::GET &&
42
+ http_request.parameters.empty?
43
+ request.body = http_request.parameters
44
+ end
38
45
  end
39
46
  convert_response(response, http_request)
40
47
  end
@@ -46,7 +53,10 @@ module Bandwidth
46
53
  http_request.query_url
47
54
  ) do |request|
48
55
  request.headers = http_request.headers
49
- request.body = http_request.parameters
56
+ unless http_request.http_method == HttpMethodEnum::GET &&
57
+ http_request.parameters.empty?
58
+ request.body = http_request.parameters
59
+ end
50
60
  end
51
61
  convert_response(response, http_request)
52
62
  end
@@ -7,12 +7,16 @@
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'
13
16
  require_relative 'messaging/models/bandwidth_callback_message.rb'
14
17
  require_relative 'messaging/models/bandwidth_message.rb'
15
18
  require_relative 'messaging/models/message_request.rb'
19
+ require_relative 'messaging/models/priority_enum.rb'
16
20
 
17
21
  # Exceptions
18
22
  require_relative 'messaging/exceptions/messaging_exception.rb'
@@ -12,8 +12,9 @@ module Messaging
12
12
  end
13
13
 
14
14
  # listMedia
15
- # @param [String] user_id Required parameter: Example:
16
- # @param [String] continuation_token Optional parameter: Example:
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)
@@ -22,7 +23,7 @@ module Messaging
22
23
  _query_builder << '/users/{userId}/media'
23
24
  _query_builder = APIHelper.append_url_with_template_parameters(
24
25
  _query_builder,
25
- 'userId' => { 'value' => user_id, 'encode' => true }
26
+ 'userId' => { 'value' => user_id, 'encode' => false }
26
27
  )
27
28
  _query_url = APIHelper.clean_url _query_builder
28
29
 
@@ -83,8 +84,8 @@ module Messaging
83
84
  end
84
85
 
85
86
  # getMedia
86
- # @param [String] user_id Required parameter: Example:
87
- # @param [String] media_id Required parameter: Example:
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)
@@ -93,7 +94,7 @@ module Messaging
93
94
  _query_builder << '/users/{userId}/media/{mediaId}'
94
95
  _query_builder = APIHelper.append_url_with_template_parameters(
95
96
  _query_builder,
96
- 'userId' => { 'value' => user_id, 'encode' => true },
97
+ 'userId' => { 'value' => user_id, 'encode' => false },
97
98
  'mediaId' => { 'value' => media_id, 'encode' => false }
98
99
  )
99
100
  _query_url = APIHelper.clean_url _query_builder
@@ -146,13 +147,17 @@ module Messaging
146
147
  end
147
148
 
148
149
  # uploadMedia
149
- # @param [String] user_id Required parameter: Example:
150
- # @param [String] media_id Required parameter: Example:
151
- # @param [Long] content_length Required parameter: Example:
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
- # Example:application/octet-stream
155
- # @param [String] cache_control Optional parameter: Example:
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,
@@ -165,7 +170,7 @@ module Messaging
165
170
  _query_builder << '/users/{userId}/media/{mediaId}'
166
171
  _query_builder = APIHelper.append_url_with_template_parameters(
167
172
  _query_builder,
168
- 'userId' => { 'value' => user_id, 'encode' => true },
173
+ 'userId' => { 'value' => user_id, 'encode' => false },
169
174
  'mediaId' => { 'value' => media_id, 'encode' => false }
170
175
  )
171
176
  _query_url = APIHelper.clean_url _query_builder
@@ -234,8 +239,8 @@ module Messaging
234
239
  end
235
240
 
236
241
  # deleteMedia
237
- # @param [String] user_id Required parameter: Example:
238
- # @param [String] media_id Required parameter: Example:
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)
@@ -244,7 +249,7 @@ module Messaging
244
249
  _query_builder << '/users/{userId}/media/{mediaId}'
245
250
  _query_builder = APIHelper.append_url_with_template_parameters(
246
251
  _query_builder,
247
- 'userId' => { 'value' => user_id, 'encode' => true },
252
+ 'userId' => { 'value' => user_id, 'encode' => false },
248
253
  'mediaId' => { 'value' => media_id, 'encode' => false }
249
254
  )
250
255
  _query_url = APIHelper.clean_url _query_builder
@@ -294,18 +299,128 @@ 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: Example:
299
- # @param [MessageRequest] body Optional parameter: Example:
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: nil)
417
+ body)
303
418
  # Prepare query url.
304
419
  _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
305
420
  _query_builder << '/users/{userId}/messages'
306
421
  _query_builder = APIHelper.append_url_with_template_parameters(
307
422
  _query_builder,
308
- 'userId' => { 'value' => user_id, 'encode' => true }
423
+ 'userId' => { 'value' => user_id, 'encode' => false }
309
424
  )
310
425
  _query_url = APIHelper.clean_url _query_builder
311
426
 
@@ -13,7 +13,7 @@ module Bandwidth
13
13
  @http_call_back = http_call_back
14
14
 
15
15
  @global_headers = {
16
- 'user-agent' => 'ruby-sdk-refs/tags/ruby3.12.1'
16
+ 'user-agent' => 'ruby-sdk'
17
17
  }
18
18
  end
19
19
 
@@ -6,50 +6,55 @@
6
6
  module Bandwidth
7
7
  # BandwidthMessage Model.
8
8
  class BandwidthMessage < BaseModel
9
- # TODO: Write general description for this method
9
+ # The id of the message
10
10
  # @return [String]
11
11
  attr_accessor :id
12
12
 
13
- # TODO: Write general description for this method
13
+ # The Bandwidth phone number associated with the message
14
14
  # @return [String]
15
15
  attr_accessor :owner
16
16
 
17
- # TODO: Write general description for this method
17
+ # The application ID associated with the message
18
18
  # @return [String]
19
19
  attr_accessor :application_id
20
20
 
21
- # TODO: Write general description for this method
21
+ # The datetime stamp of the message in ISO 8601
22
22
  # @return [String]
23
23
  attr_accessor :time
24
24
 
25
- # TODO: Write general description for this method
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
- # TODO: Write general description for this method
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
- # TODO: Write general description for this method
34
+ # The phone number recipients of the message
34
35
  # @return [List of String]
35
36
  attr_accessor :to
36
37
 
37
- # TODO: Write general description for this method
38
+ # The phone number the message was sent from
38
39
  # @return [String]
39
40
  attr_accessor :from
40
41
 
41
- # TODO: Write general description for this method
42
+ # The list of media URLs sent in the message
42
43
  # @return [List of String]
43
44
  attr_accessor :media
44
45
 
45
- # TODO: Write general description for this method
46
+ # The contents of the message
46
47
  # @return [String]
47
48
  attr_accessor :text
48
49
 
49
- # TODO: Write general description for this method
50
+ # The custom string set by the user
50
51
  # @return [String]
51
52
  attr_accessor :tag
52
53
 
54
+ # The priority specified by the user
55
+ # @return [String]
56
+ attr_accessor :priority
57
+
53
58
  # A mapping from model property names to API property names.
54
59
  def self.names
55
60
  @_hash = {} if @_hash.nil?
@@ -64,6 +69,7 @@ module Bandwidth
64
69
  @_hash['media'] = 'media'
65
70
  @_hash['text'] = 'text'
66
71
  @_hash['tag'] = 'tag'
72
+ @_hash['priority'] = 'priority'
67
73
  @_hash
68
74
  end
69
75
 
@@ -77,7 +83,8 @@ module Bandwidth
77
83
  from = nil,
78
84
  media = nil,
79
85
  text = nil,
80
- tag = nil)
86
+ tag = nil,
87
+ priority = nil)
81
88
  @id = id
82
89
  @owner = owner
83
90
  @application_id = application_id
@@ -89,6 +96,7 @@ module Bandwidth
89
96
  @media = media
90
97
  @text = text
91
98
  @tag = tag
99
+ @priority = priority
92
100
  end
93
101
 
94
102
  # Creates an instance of the object from a hash.
@@ -107,6 +115,7 @@ module Bandwidth
107
115
  media = hash['media']
108
116
  text = hash['text']
109
117
  tag = hash['tag']
118
+ priority = hash['priority']
110
119
 
111
120
  # Create object from extracted values.
112
121
  BandwidthMessage.new(id,
@@ -119,7 +128,8 @@ module Bandwidth
119
128
  from,
120
129
  media,
121
130
  text,
122
- tag)
131
+ tag,
132
+ priority)
123
133
  end
124
134
  end
125
135
  end
@@ -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