bandwidth-sdk 2.2.2 → 3.12.1

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bandwidth.rb +28 -2
  3. data/lib/bandwidth/api_helper.rb +14 -9
  4. data/lib/bandwidth/client.rb +22 -2
  5. data/lib/bandwidth/configuration.rb +67 -12
  6. data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
  7. data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
  8. data/lib/bandwidth/messaging_lib/messaging.rb +1 -3
  9. data/lib/bandwidth/messaging_lib/messaging/client.rb +13 -2
  10. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +48 -95
  11. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  12. data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
  13. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +20 -0
  14. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +51 -0
  15. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +158 -0
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
  17. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb +29 -0
  18. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +88 -0
  19. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
  20. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
  21. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +94 -0
  22. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
  23. data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +28 -0
  24. data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +32 -0
  25. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +13 -1
  26. data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +5 -1
  27. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +6 -1
  28. data/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +5 -1
  29. data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +15 -0
  30. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
  31. data/lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb +20 -0
  32. data/lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb +14 -0
  33. data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +5 -1
  34. data/lib/bandwidth/voice_lib/voice.rb +8 -0
  35. data/lib/bandwidth/voice_lib/voice/client.rb +13 -2
  36. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +768 -131
  37. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  38. data/lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb +17 -0
  39. data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +45 -0
  40. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +65 -2
  41. data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +36 -0
  42. data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +11 -2
  43. data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +107 -0
  44. data/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +108 -0
  45. data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +35 -0
  46. data/lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb +80 -0
  47. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb +126 -0
  48. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +4 -1
  49. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +33 -5
  50. data/lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb +17 -0
  51. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +3 -3
  52. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +10 -13
  53. data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +32 -0
  54. data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +4 -13
  55. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +1 -1
  56. data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +13 -0
  57. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +21 -0
  58. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +51 -0
  59. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +692 -0
  60. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
  61. data/lib/bandwidth/{messaging_lib/messaging/exceptions/path_client_exception.rb → web_rtc_lib/web_rtc/exceptions/error_exception.rb} +4 -19
  62. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
  63. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +83 -0
  64. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
  66. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
  67. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
  68. metadata +60 -13
  69. data/lib/bandwidth/messaging_lib/messaging/models/field_error.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a0d3a06b7e019a1602f4a796f096c7ac408e66395b10ff9088f26393c028acf
4
- data.tar.gz: 67d9cfdf43befba134e4dabc3abddc1317821db91d0ac18c9d2a92456da270d8
3
+ metadata.gz: 957c708a64fbff873ec8eabc221cd4832deaf4d68ac4d29c1200104ddf1a9320
4
+ data.tar.gz: dff8ddef5916e696798d712f257be3f9ef471ec2fadc42567ffa248b119e9e3d
5
5
  SHA512:
6
- metadata.gz: 94fef92c336e12b4c6bcfc29b51048fbd5f00493ce1868c4baaf539f58f89b5024bc65bc8426aac36eae1c0c04930234e4ed57878bd7d049a719a6b8c96f05e9
7
- data.tar.gz: 5d058ccd30dc7b4efa01397d346247a75d81101da1e981d011f00ec437c1e7d12e97651462111861880135e7c56e776a369a11fd7c6b90712038645dbf19f5b3
6
+ metadata.gz: ef6d3e69a46cf27463b1bc72cea88a0a2e4dd78558758ca6c72eceedd99c48c5c304e08914cecd8e3f5919bb617d501930dc81d8fc28aeba47148ecf0a214f7f
7
+ data.tar.gz: 487a7c3d36817d419e482ac89d98927803789b03b3be3148eeeb246f7fbfdae1da74bf500918b4eac1f8a7c7cce890290be1da843ca632c9ee26719d232e6b12
@@ -35,8 +35,34 @@ require_relative 'bandwidth/configuration.rb'
35
35
  # Namespaces
36
36
  require_relative 'bandwidth/messaging_lib/messaging'
37
37
  require_relative 'bandwidth/http/auth/messaging_basic_auth.rb'
38
+ require_relative 'bandwidth/two_factor_auth_lib/two_factor_auth'
39
+ require_relative 'bandwidth/http/auth/two_factor_auth_basic_auth.rb'
38
40
  require_relative 'bandwidth/voice_lib/voice'
39
41
  require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
42
+ require_relative 'bandwidth/web_rtc_lib/web_rtc'
43
+ require_relative 'bandwidth/http/auth/web_rtc_basic_auth.rb'
40
44
 
41
-
42
- # Controllers
45
+ # External Files
46
+ require_relative 'bandwidth/voice_lib/bxml/bxml.rb'
47
+ require_relative 'bandwidth/voice_lib/bxml/verbs/bridge.rb'
48
+ require_relative 'bandwidth/voice_lib/bxml/verbs/conference.rb'
49
+ require_relative 'bandwidth/voice_lib/bxml/verbs/forward.rb'
50
+ require_relative 'bandwidth/voice_lib/bxml/verbs/gather.rb'
51
+ require_relative 'bandwidth/voice_lib/bxml/verbs/hangup.rb'
52
+ require_relative 'bandwidth/voice_lib/bxml/verbs/pause.rb'
53
+ require_relative 'bandwidth/voice_lib/bxml/verbs/pause_recording.rb'
54
+ require_relative 'bandwidth/voice_lib/bxml/verbs/phone_number.rb'
55
+ require_relative 'bandwidth/voice_lib/bxml/verbs/play_audio.rb'
56
+ require_relative 'bandwidth/voice_lib/bxml/verbs/record.rb'
57
+ require_relative 'bandwidth/voice_lib/bxml/verbs/redirect.rb'
58
+ require_relative 'bandwidth/voice_lib/bxml/verbs/resume_recording.rb'
59
+ require_relative 'bandwidth/voice_lib/bxml/verbs/ring.rb'
60
+ require_relative 'bandwidth/voice_lib/bxml/verbs/send_dtmf.rb'
61
+ require_relative 'bandwidth/voice_lib/bxml/verbs/speak_sentence.rb'
62
+ require_relative 'bandwidth/voice_lib/bxml/verbs/start_gather.rb'
63
+ require_relative 'bandwidth/voice_lib/bxml/verbs/start_recording.rb'
64
+ require_relative 'bandwidth/voice_lib/bxml/verbs/stop_gather.rb'
65
+ require_relative 'bandwidth/voice_lib/bxml/verbs/stop_recording.rb'
66
+ require_relative 'bandwidth/voice_lib/bxml/verbs/transfer.rb'
67
+ require_relative 'bandwidth/voice_lib/bxml/verbs/xml_verb.rb'
68
+ require_relative 'bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb'
@@ -41,17 +41,22 @@ module Bandwidth
41
41
  # Return if there are no parameters to replace.
42
42
  return query_builder if parameters.nil?
43
43
 
44
- # Iterate and append parameters.
45
- parameters.each do |key, value|
46
- replace_value = ''
47
-
48
- if value.nil?
44
+ parameters.each do |key, val|
45
+ if val.nil?
49
46
  replace_value = ''
50
- elsif value.instance_of? Array
51
- value.map! { |element| CGI.escape(element.to_s) }
52
- replace_value = value.join('/')
47
+ elsif val['value'].instance_of? Array
48
+ if val['encode'] == true
49
+ val['value'].map! { |element| CGI.escape(element.to_s) }
50
+ else
51
+ val['value'].map!(&:to_s)
52
+ end
53
+ replace_value = val['value'].join('/')
53
54
  else
54
- replace_value = CGI.escape(value.to_s)
55
+ replace_value = if val['encode'] == true
56
+ CGI.escape(val['value'].to_s)
57
+ else
58
+ val['value'].to_s
59
+ end
55
60
  end
56
61
 
57
62
  # Find the template parameter and replace it with its value.
@@ -12,27 +12,47 @@ module Bandwidth
12
12
  def messaging_client
13
13
  @messaging_client ||= Messaging::Client.new(config: config)
14
14
  end
15
+ # Access to two_factor_auth_client controller.
16
+ # @return [TwoFactorAuth::Client] Returns the client instance.
17
+ def two_factor_auth_client
18
+ @two_factor_auth_client ||= TwoFactorAuth::Client.new(config: config)
19
+ end
15
20
  # Access to voice_client controller.
16
21
  # @return [Voice::Client] Returns the client instance.
17
22
  def voice_client
18
23
  @voice_client ||= Voice::Client.new(config: config)
19
24
  end
25
+ # Access to web_rtc_client controller.
26
+ # @return [WebRtc::Client] Returns the client instance.
27
+ def web_rtc_client
28
+ @web_rtc_client ||= WebRtc::Client.new(config: config)
29
+ end
20
30
 
21
31
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
22
32
  backoff_factor: 1, environment: Environment::PRODUCTION,
33
+ base_url: 'https://www.example.com',
23
34
  messaging_basic_auth_user_name: 'TODO: Replace',
24
35
  messaging_basic_auth_password: 'TODO: Replace',
36
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
37
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
25
38
  voice_basic_auth_user_name: 'TODO: Replace',
26
- voice_basic_auth_password: 'TODO: Replace', config: nil)
39
+ voice_basic_auth_password: 'TODO: Replace',
40
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
41
+ web_rtc_basic_auth_password: 'TODO: Replace', config: nil)
27
42
  @config = if config.nil?
28
43
  Configuration.new(timeout: timeout, max_retries: max_retries,
29
44
  retry_interval: retry_interval,
30
45
  backoff_factor: backoff_factor,
31
46
  environment: environment,
47
+ base_url: base_url,
32
48
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
33
49
  messaging_basic_auth_password: messaging_basic_auth_password,
50
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
51
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
34
52
  voice_basic_auth_user_name: voice_basic_auth_user_name,
35
- voice_basic_auth_password: voice_basic_auth_password)
53
+ voice_basic_auth_password: voice_basic_auth_password,
54
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
55
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password)
36
56
  else
37
57
  config
38
58
  end
@@ -7,7 +7,8 @@ module Bandwidth
7
7
  # An enum for SDK environments.
8
8
  class Environment
9
9
  ENVIRONMENT = [
10
- PRODUCTION = 'production'.freeze
10
+ PRODUCTION = 'production'.freeze,
11
+ CUSTOM = 'custom'.freeze
11
12
  ].freeze
12
13
  end
13
14
 
@@ -16,7 +17,9 @@ module Bandwidth
16
17
  SERVER = [
17
18
  DEFAULT = 'default'.freeze,
18
19
  MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
19
- VOICEDEFAULT = 'VoiceDefault'.freeze
20
+ TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.freeze,
21
+ VOICEDEFAULT = 'VoiceDefault'.freeze,
22
+ WEBRTCDEFAULT = 'WebRtcDefault'.freeze
20
23
  ].freeze
21
24
  end
22
25
 
@@ -30,10 +33,15 @@ module Bandwidth
30
33
  attr_reader :retry_interval
31
34
  attr_reader :backoff_factor
32
35
  attr_reader :environment
36
+ attr_reader :base_url
33
37
  attr_reader :messaging_basic_auth_user_name
34
38
  attr_reader :messaging_basic_auth_password
39
+ attr_reader :two_factor_auth_basic_auth_user_name
40
+ attr_reader :two_factor_auth_basic_auth_password
35
41
  attr_reader :voice_basic_auth_user_name
36
42
  attr_reader :voice_basic_auth_password
43
+ attr_reader :web_rtc_basic_auth_user_name
44
+ attr_reader :web_rtc_basic_auth_password
37
45
 
38
46
  class << self
39
47
  attr_reader :environments
@@ -41,10 +49,15 @@ module Bandwidth
41
49
 
42
50
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
43
51
  backoff_factor: 1, environment: Environment::PRODUCTION,
52
+ base_url: 'https://www.example.com',
44
53
  messaging_basic_auth_user_name: 'TODO: Replace',
45
54
  messaging_basic_auth_password: 'TODO: Replace',
55
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
56
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
46
57
  voice_basic_auth_user_name: 'TODO: Replace',
47
- voice_basic_auth_password: 'TODO: Replace')
58
+ voice_basic_auth_password: 'TODO: Replace',
59
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
60
+ web_rtc_basic_auth_password: 'TODO: Replace')
48
61
  # The value to use for connection timeout
49
62
  @timeout = timeout
50
63
 
@@ -59,7 +72,10 @@ module Bandwidth
59
72
  @backoff_factor = backoff_factor
60
73
 
61
74
  # Current API environment
62
- @environment = environment
75
+ @environment = String(environment)
76
+
77
+ # baseUrl value
78
+ @base_url = base_url
63
79
 
64
80
  # The username to use with basic authentication
65
81
  @messaging_basic_auth_user_name = messaging_basic_auth_user_name
@@ -67,40 +83,65 @@ module Bandwidth
67
83
  # The password to use with basic authentication
68
84
  @messaging_basic_auth_password = messaging_basic_auth_password
69
85
 
86
+ # The username to use with basic authentication
87
+ @two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name
88
+
89
+ # The password to use with basic authentication
90
+ @two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
91
+
70
92
  # The username to use with basic authentication
71
93
  @voice_basic_auth_user_name = voice_basic_auth_user_name
72
94
 
73
95
  # The password to use with basic authentication
74
96
  @voice_basic_auth_password = voice_basic_auth_password
75
97
 
98
+ # The username to use with basic authentication
99
+ @web_rtc_basic_auth_user_name = web_rtc_basic_auth_user_name
100
+
101
+ # The password to use with basic authentication
102
+ @web_rtc_basic_auth_password = web_rtc_basic_auth_password
103
+
76
104
  # The Http Client to use for making requests.
77
105
  @http_client = create_http_client
78
106
  end
79
107
 
80
108
  def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
81
- backoff_factor: nil, environment: nil,
109
+ backoff_factor: nil, environment: nil, base_url: nil,
82
110
  messaging_basic_auth_user_name: nil,
83
111
  messaging_basic_auth_password: nil,
112
+ two_factor_auth_basic_auth_user_name: nil,
113
+ two_factor_auth_basic_auth_password: nil,
84
114
  voice_basic_auth_user_name: nil,
85
- voice_basic_auth_password: nil)
115
+ voice_basic_auth_password: nil,
116
+ web_rtc_basic_auth_user_name: nil,
117
+ web_rtc_basic_auth_password: nil)
86
118
  timeout ||= self.timeout
87
119
  max_retries ||= self.max_retries
88
120
  retry_interval ||= self.retry_interval
89
121
  backoff_factor ||= self.backoff_factor
90
122
  environment ||= self.environment
123
+ base_url ||= self.base_url
91
124
  messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
92
125
  messaging_basic_auth_password ||= self.messaging_basic_auth_password
126
+ two_factor_auth_basic_auth_user_name ||= self.two_factor_auth_basic_auth_user_name
127
+ two_factor_auth_basic_auth_password ||= self.two_factor_auth_basic_auth_password
93
128
  voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
94
129
  voice_basic_auth_password ||= self.voice_basic_auth_password
130
+ web_rtc_basic_auth_user_name ||= self.web_rtc_basic_auth_user_name
131
+ web_rtc_basic_auth_password ||= self.web_rtc_basic_auth_password
95
132
 
96
133
  Configuration.new(
97
134
  timeout: timeout, max_retries: max_retries,
98
135
  retry_interval: retry_interval, backoff_factor: backoff_factor,
99
- environment: environment,
136
+ environment: environment, base_url: base_url,
100
137
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
101
138
  messaging_basic_auth_password: messaging_basic_auth_password,
139
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
140
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
102
141
  voice_basic_auth_user_name: voice_basic_auth_user_name,
103
- voice_basic_auth_password: voice_basic_auth_password
142
+ voice_basic_auth_password: voice_basic_auth_password,
143
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
144
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password
104
145
  )
105
146
  end
106
147
 
@@ -111,20 +152,34 @@ module Bandwidth
111
152
  end
112
153
 
113
154
  # All the environments the SDK can run in.
114
- @environments = {
155
+ ENVIRONMENTS = {
115
156
  Environment::PRODUCTION => {
116
157
  Server::DEFAULT => 'api.bandwidth.com',
117
158
  Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
118
- Server::VOICEDEFAULT => 'https://voice.bandwidth.com'
159
+ Server::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1/',
160
+ Server::VOICEDEFAULT => 'https://voice.bandwidth.com',
161
+ Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
162
+ },
163
+ Environment::CUSTOM => {
164
+ Server::DEFAULT => '{base_url}',
165
+ Server::MESSAGINGDEFAULT => '{base_url}',
166
+ Server::TWOFACTORAUTHDEFAULT => '{base_url}',
167
+ Server::VOICEDEFAULT => '{base_url}',
168
+ Server::WEBRTCDEFAULT => '{base_url}'
119
169
  }
120
- }
170
+ }.freeze
121
171
 
122
172
  # Generates the appropriate base URI for the environment and the server.
123
173
  # @param [Configuration::Server] The server enum for which the base URI is
124
174
  # required.
125
175
  # @return [String] The base URI.
126
176
  def get_base_uri(server = Server::DEFAULT)
127
- self.class.environments[environment][server].clone
177
+ parameters = {
178
+ 'base_url' => { 'value' => base_url, 'encode' => false }
179
+ }
180
+ APIHelper.append_url_with_template_parameters(
181
+ ENVIRONMENTS[environment][server], parameters
182
+ )
128
183
  end
129
184
  end
130
185
  end
@@ -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 TwoFactorAuthBasicAuth
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.two_factor_auth_basic_auth_user_name
16
+ password = config.two_factor_auth_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
@@ -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 WebRtcBasicAuth
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.web_rtc_basic_auth_user_name
16
+ password = config.web_rtc_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
@@ -7,7 +7,6 @@
7
7
  require_relative 'messaging/client.rb'
8
8
 
9
9
  # Models
10
- require_relative 'messaging/models/field_error.rb'
11
10
  require_relative 'messaging/models/media.rb'
12
11
  require_relative 'messaging/models/tag.rb'
13
12
  require_relative 'messaging/models/deferred_result.rb'
@@ -16,8 +15,7 @@ require_relative 'messaging/models/bandwidth_message.rb'
16
15
  require_relative 'messaging/models/message_request.rb'
17
16
 
18
17
  # Exceptions
19
- require_relative 'messaging/exceptions/generic_client_exception.rb'
20
- require_relative 'messaging/exceptions/path_client_exception.rb'
18
+ require_relative 'messaging/exceptions/messaging_exception.rb'
21
19
  # Controllers
22
20
  require_relative 'messaging/controllers/base_controller.rb'
23
21
  require_relative 'messaging/controllers/api_controller.rb'
@@ -17,20 +17,31 @@ module Bandwidth
17
17
 
18
18
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
19
19
  backoff_factor: 1, environment: Environment::PRODUCTION,
20
+ base_url: 'https://www.example.com',
20
21
  messaging_basic_auth_user_name: 'TODO: Replace',
21
22
  messaging_basic_auth_password: 'TODO: Replace',
23
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
24
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
22
25
  voice_basic_auth_user_name: 'TODO: Replace',
23
- voice_basic_auth_password: 'TODO: Replace', config: nil)
26
+ voice_basic_auth_password: 'TODO: Replace',
27
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
28
+ web_rtc_basic_auth_password: 'TODO: Replace',
29
+ config: nil)
24
30
  @config = if config.nil?
25
31
  Configuration.new(timeout: timeout,
26
32
  max_retries: max_retries,
27
33
  retry_interval: retry_interval,
28
34
  backoff_factor: backoff_factor,
29
35
  environment: environment,
36
+ base_url: base_url,
30
37
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
31
38
  messaging_basic_auth_password: messaging_basic_auth_password,
39
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
40
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
32
41
  voice_basic_auth_user_name: voice_basic_auth_user_name,
33
- voice_basic_auth_password: voice_basic_auth_password)
42
+ voice_basic_auth_password: voice_basic_auth_password,
43
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
44
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password)
34
45
  else
35
46
  config
36
47
  end
@@ -11,59 +11,6 @@ module Messaging
11
11
  super(config, http_call_back: http_call_back)
12
12
  end
13
13
 
14
- # getMessage
15
- # @return [void] response from the API call
16
- def get_message
17
- # Prepare query url.
18
- _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
19
- _query_builder << '/ping'
20
- _query_url = APIHelper.clean_url _query_builder
21
-
22
- # Prepare and execute HttpRequest.
23
- _request = config.http_client.get(
24
- _query_url
25
- )
26
- MessagingBasicAuth.apply(config, _request)
27
- _response = execute_request(_request)
28
-
29
- # Validate response against endpoint and global error codes.
30
- if _response.status_code == 400
31
- raise GenericClientException.new(
32
- '400 Request is malformed or invalid',
33
- _response
34
- )
35
- elsif _response.status_code == 401
36
- raise PathClientException.new(
37
- '401 The specified user does not have access to the account',
38
- _response
39
- )
40
- elsif _response.status_code == 403
41
- raise PathClientException.new(
42
- '403 The user does not have access to this API',
43
- _response
44
- )
45
- elsif _response.status_code == 404
46
- raise PathClientException.new(
47
- '404 Path not found',
48
- _response
49
- )
50
- elsif _response.status_code == 415
51
- raise GenericClientException.new(
52
- '415 The content-type of the request is incorrect',
53
- _response
54
- )
55
- elsif _response.status_code == 429
56
- raise GenericClientException.new(
57
- '429 The rate limit has been reached',
58
- _response
59
- )
60
- end
61
- validate_response(_response)
62
-
63
- # Return appropriate response type.
64
- ApiResponse.new(_response)
65
- end
66
-
67
14
  # listMedia
68
15
  # @param [String] user_id Required parameter: Example:
69
16
  # @param [String] continuation_token Optional parameter: Example:
@@ -75,7 +22,7 @@ module Messaging
75
22
  _query_builder << '/users/{userId}/media'
76
23
  _query_builder = APIHelper.append_url_with_template_parameters(
77
24
  _query_builder,
78
- 'userId' => user_id
25
+ 'userId' => { 'value' => user_id, 'encode' => true }
79
26
  )
80
27
  _query_url = APIHelper.clean_url _query_builder
81
28
 
@@ -95,32 +42,32 @@ module Messaging
95
42
 
96
43
  # Validate response against endpoint and global error codes.
97
44
  if _response.status_code == 400
98
- raise GenericClientException.new(
45
+ raise MessagingException.new(
99
46
  '400 Request is malformed or invalid',
100
47
  _response
101
48
  )
102
49
  elsif _response.status_code == 401
103
- raise PathClientException.new(
50
+ raise MessagingException.new(
104
51
  '401 The specified user does not have access to the account',
105
52
  _response
106
53
  )
107
54
  elsif _response.status_code == 403
108
- raise PathClientException.new(
55
+ raise MessagingException.new(
109
56
  '403 The user does not have access to this API',
110
57
  _response
111
58
  )
112
59
  elsif _response.status_code == 404
113
- raise PathClientException.new(
60
+ raise MessagingException.new(
114
61
  '404 Path not found',
115
62
  _response
116
63
  )
117
64
  elsif _response.status_code == 415
118
- raise GenericClientException.new(
65
+ raise MessagingException.new(
119
66
  '415 The content-type of the request is incorrect',
120
67
  _response
121
68
  )
122
69
  elsif _response.status_code == 429
123
- raise GenericClientException.new(
70
+ raise MessagingException.new(
124
71
  '429 The rate limit has been reached',
125
72
  _response
126
73
  )
@@ -129,8 +76,10 @@ module Messaging
129
76
 
130
77
  # Return appropriate response type.
131
78
  decoded = APIHelper.json_deserialize(_response.raw_body)
132
- ApiResponse.new(_response,
133
- data: decoded.map { |element| Media.from_hash(element) })
79
+ ApiResponse.new(
80
+ _response,
81
+ data: decoded.map { |element| Media.from_hash(element) }
82
+ )
134
83
  end
135
84
 
136
85
  # getMedia
@@ -144,8 +93,8 @@ module Messaging
144
93
  _query_builder << '/users/{userId}/media/{mediaId}'
145
94
  _query_builder = APIHelper.append_url_with_template_parameters(
146
95
  _query_builder,
147
- 'userId' => user_id,
148
- 'mediaId' => media_id
96
+ 'userId' => { 'value' => user_id, 'encode' => true },
97
+ 'mediaId' => { 'value' => media_id, 'encode' => true }
149
98
  )
150
99
  _query_url = APIHelper.clean_url _query_builder
151
100
 
@@ -158,32 +107,32 @@ module Messaging
158
107
 
159
108
  # Validate response against endpoint and global error codes.
160
109
  if _response.status_code == 400
161
- raise GenericClientException.new(
110
+ raise MessagingException.new(
162
111
  '400 Request is malformed or invalid',
163
112
  _response
164
113
  )
165
114
  elsif _response.status_code == 401
166
- raise PathClientException.new(
115
+ raise MessagingException.new(
167
116
  '401 The specified user does not have access to the account',
168
117
  _response
169
118
  )
170
119
  elsif _response.status_code == 403
171
- raise PathClientException.new(
120
+ raise MessagingException.new(
172
121
  '403 The user does not have access to this API',
173
122
  _response
174
123
  )
175
124
  elsif _response.status_code == 404
176
- raise PathClientException.new(
125
+ raise MessagingException.new(
177
126
  '404 Path not found',
178
127
  _response
179
128
  )
180
129
  elsif _response.status_code == 415
181
- raise GenericClientException.new(
130
+ raise MessagingException.new(
182
131
  '415 The content-type of the request is incorrect',
183
132
  _response
184
133
  )
185
134
  elsif _response.status_code == 429
186
- raise GenericClientException.new(
135
+ raise MessagingException.new(
187
136
  '429 The rate limit has been reached',
188
137
  _response
189
138
  )
@@ -191,7 +140,9 @@ module Messaging
191
140
  validate_response(_response)
192
141
 
193
142
  # Return appropriate response type.
194
- ApiResponse.new(_response, data: _response.raw_body)
143
+ ApiResponse.new(
144
+ _response, data: _response.raw_body
145
+ )
195
146
  end
196
147
 
197
148
  # uploadMedia
@@ -214,8 +165,8 @@ module Messaging
214
165
  _query_builder << '/users/{userId}/media/{mediaId}'
215
166
  _query_builder = APIHelper.append_url_with_template_parameters(
216
167
  _query_builder,
217
- 'userId' => user_id,
218
- 'mediaId' => media_id
168
+ 'userId' => { 'value' => user_id, 'encode' => true },
169
+ 'mediaId' => { 'value' => media_id, 'encode' => true }
219
170
  )
220
171
  _query_url = APIHelper.clean_url _query_builder
221
172
 
@@ -246,32 +197,32 @@ module Messaging
246
197
 
247
198
  # Validate response against endpoint and global error codes.
248
199
  if _response.status_code == 400
249
- raise GenericClientException.new(
200
+ raise MessagingException.new(
250
201
  '400 Request is malformed or invalid',
251
202
  _response
252
203
  )
253
204
  elsif _response.status_code == 401
254
- raise PathClientException.new(
205
+ raise MessagingException.new(
255
206
  '401 The specified user does not have access to the account',
256
207
  _response
257
208
  )
258
209
  elsif _response.status_code == 403
259
- raise PathClientException.new(
210
+ raise MessagingException.new(
260
211
  '403 The user does not have access to this API',
261
212
  _response
262
213
  )
263
214
  elsif _response.status_code == 404
264
- raise PathClientException.new(
215
+ raise MessagingException.new(
265
216
  '404 Path not found',
266
217
  _response
267
218
  )
268
219
  elsif _response.status_code == 415
269
- raise GenericClientException.new(
220
+ raise MessagingException.new(
270
221
  '415 The content-type of the request is incorrect',
271
222
  _response
272
223
  )
273
224
  elsif _response.status_code == 429
274
- raise GenericClientException.new(
225
+ raise MessagingException.new(
275
226
  '429 The rate limit has been reached',
276
227
  _response
277
228
  )
@@ -293,8 +244,8 @@ module Messaging
293
244
  _query_builder << '/users/{userId}/media/{mediaId}'
294
245
  _query_builder = APIHelper.append_url_with_template_parameters(
295
246
  _query_builder,
296
- 'userId' => user_id,
297
- 'mediaId' => media_id
247
+ 'userId' => { 'value' => user_id, 'encode' => true },
248
+ 'mediaId' => { 'value' => media_id, 'encode' => true }
298
249
  )
299
250
  _query_url = APIHelper.clean_url _query_builder
300
251
 
@@ -307,32 +258,32 @@ module Messaging
307
258
 
308
259
  # Validate response against endpoint and global error codes.
309
260
  if _response.status_code == 400
310
- raise GenericClientException.new(
261
+ raise MessagingException.new(
311
262
  '400 Request is malformed or invalid',
312
263
  _response
313
264
  )
314
265
  elsif _response.status_code == 401
315
- raise PathClientException.new(
266
+ raise MessagingException.new(
316
267
  '401 The specified user does not have access to the account',
317
268
  _response
318
269
  )
319
270
  elsif _response.status_code == 403
320
- raise PathClientException.new(
271
+ raise MessagingException.new(
321
272
  '403 The user does not have access to this API',
322
273
  _response
323
274
  )
324
275
  elsif _response.status_code == 404
325
- raise PathClientException.new(
276
+ raise MessagingException.new(
326
277
  '404 Path not found',
327
278
  _response
328
279
  )
329
280
  elsif _response.status_code == 415
330
- raise GenericClientException.new(
281
+ raise MessagingException.new(
331
282
  '415 The content-type of the request is incorrect',
332
283
  _response
333
284
  )
334
285
  elsif _response.status_code == 429
335
- raise GenericClientException.new(
286
+ raise MessagingException.new(
336
287
  '429 The rate limit has been reached',
337
288
  _response
338
289
  )
@@ -354,7 +305,7 @@ module Messaging
354
305
  _query_builder << '/users/{userId}/messages'
355
306
  _query_builder = APIHelper.append_url_with_template_parameters(
356
307
  _query_builder,
357
- 'userId' => user_id
308
+ 'userId' => { 'value' => user_id, 'encode' => true }
358
309
  )
359
310
  _query_url = APIHelper.clean_url _query_builder
360
311
 
@@ -375,32 +326,32 @@ module Messaging
375
326
 
376
327
  # Validate response against endpoint and global error codes.
377
328
  if _response.status_code == 400
378
- raise GenericClientException.new(
329
+ raise MessagingException.new(
379
330
  '400 Request is malformed or invalid',
380
331
  _response
381
332
  )
382
333
  elsif _response.status_code == 401
383
- raise PathClientException.new(
334
+ raise MessagingException.new(
384
335
  '401 The specified user does not have access to the account',
385
336
  _response
386
337
  )
387
338
  elsif _response.status_code == 403
388
- raise PathClientException.new(
339
+ raise MessagingException.new(
389
340
  '403 The user does not have access to this API',
390
341
  _response
391
342
  )
392
343
  elsif _response.status_code == 404
393
- raise PathClientException.new(
344
+ raise MessagingException.new(
394
345
  '404 Path not found',
395
346
  _response
396
347
  )
397
348
  elsif _response.status_code == 415
398
- raise GenericClientException.new(
349
+ raise MessagingException.new(
399
350
  '415 The content-type of the request is incorrect',
400
351
  _response
401
352
  )
402
353
  elsif _response.status_code == 429
403
- raise GenericClientException.new(
354
+ raise MessagingException.new(
404
355
  '429 The rate limit has been reached',
405
356
  _response
406
357
  )
@@ -409,7 +360,9 @@ module Messaging
409
360
 
410
361
  # Return appropriate response type.
411
362
  decoded = APIHelper.json_deserialize(_response.raw_body)
412
- ApiResponse.new(_response, data: BandwidthMessage.from_hash(decoded))
363
+ ApiResponse.new(
364
+ _response, data: BandwidthMessage.from_hash(decoded)
365
+ )
413
366
  end
414
367
  end
415
368
  end