bandwidth-sdk 3.13.0 → 6.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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/lib/bandwidth/configuration.rb +1 -1
  4. data/lib/bandwidth/http/api_response.rb +2 -0
  5. data/lib/bandwidth/http/faraday_client.rb +9 -2
  6. data/lib/bandwidth/messaging_lib/messaging.rb +4 -0
  7. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +138 -23
  8. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  9. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +23 -13
  10. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +125 -0
  11. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +60 -0
  12. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +4 -4
  13. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +21 -8
  14. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +62 -0
  15. data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +19 -0
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +4 -2
  17. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +4 -4
  18. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +1 -1
  19. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/{api_controller.rb → mfa_controller.rb} +65 -14
  20. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb +34 -0
  21. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/{invalid_request_exception.rb → forbidden_request_exception.rb} +5 -5
  22. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb +29 -0
  23. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +0 -19
  24. data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +8 -4
  25. data/lib/bandwidth/voice_lib/voice.rb +1 -1
  26. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +51 -52
  27. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  28. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +77 -17
  29. data/lib/bandwidth/voice_lib/voice/models/{call_engine_modify_conference_request.rb → api_modify_conference_request.rb} +14 -14
  30. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +3 -3
  31. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +24 -24
  32. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +1 -1
  33. data/test/controllers/controller_test_base.rb +21 -0
  34. data/test/http_response_catcher.rb +19 -0
  35. data/test/test_helper.rb +94 -0
  36. metadata +50 -7
@@ -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
- # TODO: Write general description for this method
33
+ # User's account ID
34
34
  # @return [String]
35
35
  attr_accessor :user_id
36
36
 
37
- # TODO: Write general description for this method
37
+ # User's account ID
38
38
  # @return [String]
39
39
  attr_accessor :media_name
40
40
 
41
- # TODO: Write general description for this method
41
+ # User's account ID
42
42
  # @return [String]
43
43
  attr_accessor :media_id
44
44
 
45
- # TODO: Write general description for this method
45
+ # User's account ID
46
46
  # @return [String]
47
47
  attr_accessor :cache_control
48
48
 
@@ -6,30 +6,38 @@
6
6
  module Bandwidth
7
7
  # MessageRequest Model.
8
8
  class MessageRequest < BaseModel
9
- # TODO: Write general description for this method
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
- # TODO: Write general description for this method
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
- # TODO: Write general description for this method
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
- # TODO: Write general description for this method
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
- # TODO: Write general description for this method
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
- # TODO: Write general description for this method
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
 
35
+ # The message's priority, currently for toll-free or short code SMS only.
36
+ # Messages with a priority value of `"high"` are given preference over your
37
+ # other traffic.
38
+ # @return [PriorityEnum]
39
+ attr_accessor :priority
40
+
33
41
  # A mapping from model property names to API property names.
34
42
  def self.names
35
43
  @_hash = {} if @_hash.nil?
@@ -39,6 +47,7 @@ module Bandwidth
39
47
  @_hash['text'] = 'text'
40
48
  @_hash['media'] = 'media'
41
49
  @_hash['tag'] = 'tag'
50
+ @_hash['priority'] = 'priority'
42
51
  @_hash
43
52
  end
44
53
 
@@ -47,13 +56,15 @@ module Bandwidth
47
56
  from = nil,
48
57
  text = nil,
49
58
  media = nil,
50
- tag = nil)
59
+ tag = nil,
60
+ priority = nil)
51
61
  @application_id = application_id
52
62
  @to = to
53
63
  @from = from
54
64
  @text = text
55
65
  @media = media
56
66
  @tag = tag
67
+ @priority = priority
57
68
  end
58
69
 
59
70
  # Creates an instance of the object from a hash.
@@ -67,6 +78,7 @@ module Bandwidth
67
78
  text = hash['text']
68
79
  media = hash['media']
69
80
  tag = hash['tag']
81
+ priority = hash['priority']
70
82
 
71
83
  # Create object from extracted values.
72
84
  MessageRequest.new(application_id,
@@ -74,7 +86,8 @@ module Bandwidth
74
86
  from,
75
87
  text,
76
88
  media,
77
- tag)
89
+ tag,
90
+ priority)
78
91
  end
79
92
  end
80
93
  end
@@ -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,19 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # The message's priority, currently for toll-free or short code SMS only.
8
+ # Messages with a priority value of `"high"` are given preference over your
9
+ # other traffic.
10
+ class PriorityEnum
11
+ PRIORITY_ENUM = [
12
+ # TODO: Write general description for DEFAULT
13
+ DEFAULT = 'default'.freeze,
14
+
15
+ # TODO: Write general description for HIGH
16
+ HIGH = 'high'.freeze
17
+ ].freeze
18
+ end
19
+ end
@@ -14,7 +14,9 @@ require_relative 'two_factor_auth/models/two_factor_verify_request_schema.rb'
14
14
  require_relative 'two_factor_auth/models/two_factor_verify_code_response.rb'
15
15
 
16
16
  # Exceptions
17
- require_relative 'two_factor_auth/exceptions/invalid_request_exception.rb'
17
+ require_relative 'two_factor_auth/exceptions/error_with_request_exception.rb'
18
+ require_relative 'two_factor_auth/exceptions/unauthorized_request_exception.rb'
19
+ require_relative 'two_factor_auth/exceptions/forbidden_request_exception.rb'
18
20
  # Controllers
19
21
  require_relative 'two_factor_auth/controllers/base_controller.rb'
20
- require_relative 'two_factor_auth/controllers/api_controller.rb'
22
+ require_relative 'two_factor_auth/controllers/mfa_controller.rb'
@@ -9,10 +9,10 @@ module Bandwidth
9
9
  class Client
10
10
  attr_reader :config
11
11
 
12
- # Access to client controller.
13
- # @return [APIController] Returns the controller instance.
14
- def client
15
- @client ||= APIController.new config
12
+ # Access to mfa controller.
13
+ # @return [MFAController] Returns the controller instance.
14
+ def mfa
15
+ @mfa ||= MFAController.new config
16
16
  end
17
17
 
18
18
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
@@ -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
 
@@ -5,13 +5,13 @@
5
5
 
6
6
  module Bandwidth
7
7
  module TwoFactorAuth
8
- # APIController
9
- class APIController < BaseController
8
+ # MFAController
9
+ class MFAController < BaseController
10
10
  def initialize(config, http_call_back: nil)
11
11
  super(config, http_call_back: http_call_back)
12
12
  end
13
13
 
14
- # Two-Factor authentication with Bandwidth Voice services
14
+ # Allows a user to send a MFA code through a phone call
15
15
  # @param [String] account_id Required parameter: Bandwidth Account ID with
16
16
  # Voice service enabled
17
17
  # @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
@@ -23,7 +23,7 @@ module TwoFactorAuth
23
23
  _query_builder << '/accounts/{accountId}/code/voice'
24
24
  _query_builder = APIHelper.append_url_with_template_parameters(
25
25
  _query_builder,
26
- 'accountId' => { 'value' => account_id, 'encode' => true }
26
+ 'accountId' => { 'value' => account_id, 'encode' => false }
27
27
  )
28
28
  _query_url = APIHelper.clean_url _query_builder
29
29
 
@@ -44,8 +44,23 @@ module TwoFactorAuth
44
44
 
45
45
  # Validate response against endpoint and global error codes.
46
46
  if _response.status_code == 400
47
- raise InvalidRequestException.new(
48
- 'client request error',
47
+ raise ErrorWithRequestException.new(
48
+ 'If there is any issue with values passed in by the user',
49
+ _response
50
+ )
51
+ elsif _response.status_code == 401
52
+ raise UnauthorizedRequestException.new(
53
+ 'Authentication is either incorrect or not present',
54
+ _response
55
+ )
56
+ elsif _response.status_code == 403
57
+ raise ForbiddenRequestException.new(
58
+ 'The user is not authorized to access this resource',
59
+ _response
60
+ )
61
+ elsif _response.status_code == 500
62
+ raise ErrorWithRequestException.new(
63
+ 'An internal server error occurred',
49
64
  _response
50
65
  )
51
66
  end
@@ -58,7 +73,7 @@ module TwoFactorAuth
58
73
  )
59
74
  end
60
75
 
61
- # Two-Factor authentication with Bandwidth messaging services
76
+ # Allows a user to send a MFA code through a text message (SMS)
62
77
  # @param [String] account_id Required parameter: Bandwidth Account ID with
63
78
  # Messaging service enabled
64
79
  # @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
@@ -70,7 +85,7 @@ module TwoFactorAuth
70
85
  _query_builder << '/accounts/{accountId}/code/messaging'
71
86
  _query_builder = APIHelper.append_url_with_template_parameters(
72
87
  _query_builder,
73
- 'accountId' => { 'value' => account_id, 'encode' => true }
88
+ 'accountId' => { 'value' => account_id, 'encode' => false }
74
89
  )
75
90
  _query_url = APIHelper.clean_url _query_builder
76
91
 
@@ -91,8 +106,23 @@ module TwoFactorAuth
91
106
 
92
107
  # Validate response against endpoint and global error codes.
93
108
  if _response.status_code == 400
94
- raise InvalidRequestException.new(
95
- 'client request error',
109
+ raise ErrorWithRequestException.new(
110
+ 'If there is any issue with values passed in by the user',
111
+ _response
112
+ )
113
+ elsif _response.status_code == 401
114
+ raise UnauthorizedRequestException.new(
115
+ 'Authentication is either incorrect or not present',
116
+ _response
117
+ )
118
+ elsif _response.status_code == 403
119
+ raise ForbiddenRequestException.new(
120
+ 'The user is not authorized to access this resource',
121
+ _response
122
+ )
123
+ elsif _response.status_code == 500
124
+ raise ErrorWithRequestException.new(
125
+ 'An internal server error occurred',
96
126
  _response
97
127
  )
98
128
  end
@@ -106,7 +136,7 @@ module TwoFactorAuth
106
136
  )
107
137
  end
108
138
 
109
- # Verify a previously sent two-factor authentication code
139
+ # Allows a user to verify an MFA code
110
140
  # @param [String] account_id Required parameter: Bandwidth Account ID with
111
141
  # Two-Factor enabled
112
142
  # @param [TwoFactorVerifyRequestSchema] body Required parameter: Example:
@@ -118,7 +148,7 @@ module TwoFactorAuth
118
148
  _query_builder << '/accounts/{accountId}/code/verify'
119
149
  _query_builder = APIHelper.append_url_with_template_parameters(
120
150
  _query_builder,
121
- 'accountId' => { 'value' => account_id, 'encode' => true }
151
+ 'accountId' => { 'value' => account_id, 'encode' => false }
122
152
  )
123
153
  _query_url = APIHelper.clean_url _query_builder
124
154
 
@@ -139,8 +169,29 @@ module TwoFactorAuth
139
169
 
140
170
  # Validate response against endpoint and global error codes.
141
171
  if _response.status_code == 400
142
- raise InvalidRequestException.new(
143
- 'client request error',
172
+ raise ErrorWithRequestException.new(
173
+ 'If there is any issue with values passed in by the user',
174
+ _response
175
+ )
176
+ elsif _response.status_code == 401
177
+ raise UnauthorizedRequestException.new(
178
+ 'Authentication is either incorrect or not present',
179
+ _response
180
+ )
181
+ elsif _response.status_code == 403
182
+ raise ForbiddenRequestException.new(
183
+ 'The user is not authorized to access this resource',
184
+ _response
185
+ )
186
+ elsif _response.status_code == 429
187
+ raise ErrorWithRequestException.new(
188
+ 'The user has made too many bad requests and is temporarily locked' \
189
+ ' out',
190
+ _response
191
+ )
192
+ elsif _response.status_code == 500
193
+ raise ErrorWithRequestException.new(
194
+ 'An internal server error occurred',
144
195
  _response
145
196
  )
146
197
  end
@@ -0,0 +1,34 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # ErrorWithRequest class.
8
+ class ErrorWithRequestException < APIException
9
+ # An error message pertaining to what the issue could be
10
+ # @return [String]
11
+ attr_accessor :error
12
+
13
+ # The associated requestId from AWS
14
+ # @return [String]
15
+ attr_accessor :request_id
16
+
17
+ # The constructor.
18
+ # @param [String] The reason for raising an exception.
19
+ # @param [HttpResponse] The HttpReponse of the API call.
20
+ def initialize(reason, response)
21
+ super(reason, response)
22
+ hash = APIHelper.json_deserialize(@response.raw_body)
23
+ unbox(hash)
24
+ end
25
+
26
+ # Populates this object by extracting properties from a hash.
27
+ # @param [Hash] The deserialized response sent by the server in the
28
+ # response body.
29
+ def unbox(hash)
30
+ @error = hash['error']
31
+ @request_id = hash['requestId']
32
+ end
33
+ end
34
+ end