bandwidth-sdk 2.1.1 → 3.7.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +85 -70
  3. data/lib/bandwidth.rb +7 -1
  4. data/lib/bandwidth/client.rb +20 -2
  5. data/lib/bandwidth/configuration.rb +45 -9
  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/http/faraday_client.rb +2 -6
  9. data/lib/bandwidth/messaging_lib/messaging.rb +1 -3
  10. data/lib/bandwidth/messaging_lib/messaging/client.rb +11 -2
  11. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +45 -88
  12. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  13. data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
  14. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +20 -0
  15. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +49 -0
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +153 -0
  17. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
  18. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb +29 -0
  19. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +88 -0
  20. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
  21. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
  22. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +94 -0
  23. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
  24. data/lib/bandwidth/utilities/file_wrapper.rb +17 -0
  25. data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +22 -0
  26. data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
  27. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +8 -0
  28. data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +2 -0
  29. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +5 -1
  30. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
  31. data/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +4 -1
  32. data/lib/bandwidth/voice_lib/voice.rb +13 -4
  33. data/lib/bandwidth/voice_lib/voice/client.rb +11 -2
  34. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +629 -112
  35. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  36. data/lib/bandwidth/voice_lib/voice/exceptions/{error_response_exception.rb → api_error_response_exception.rb} +3 -3
  37. data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +11 -2
  38. data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +164 -0
  39. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
  40. data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +1 -1
  41. data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +71 -0
  42. data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
  43. data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +35 -0
  44. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +47 -0
  45. data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb +1 -1
  46. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +35 -25
  47. data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +4 -7
  48. data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +20 -0
  49. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +7 -4
  50. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +26 -0
  51. data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
  52. data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +17 -0
  53. data/lib/bandwidth/{messaging_lib/messaging/models/field_error.rb → voice_lib/voice/models/transcript.rb} +15 -15
  54. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +62 -0
  55. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +42 -0
  56. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +21 -0
  57. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +49 -0
  58. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +682 -0
  59. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
  60. data/lib/bandwidth/{messaging_lib/messaging/exceptions/path_client_exception.rb → web_rtc_lib/web_rtc/exceptions/error_exception.rb} +4 -19
  61. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
  62. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +83 -0
  63. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
  64. data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
  66. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
  67. metadata +58 -11
  68. data/lib/bandwidth/voice_lib/voice/models/api_get_account_recordings_metadata_request.rb +0 -65
  69. data/lib/bandwidth/voice_lib/voice/models/transcription_status_enum.rb +0 -20
  70. data/lib/bandwidth/voice_lib/voice/models/type_enum.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d875d4483cba8ab212869295640686010de4dfe22fc576c9ab76fcea68d270b
4
- data.tar.gz: 0aeb54d8f7b3f17a723059d9e7fc823b1e717d749f4e76319f6f07690be1ac66
3
+ metadata.gz: e10eadbf6902f10e74e9e2574332439ce256b7b8a57d8c7e87f6a776857376c0
4
+ data.tar.gz: 585279582d7e65c7a88dbb284d72a05f399be1a4c36dbc169fdeecd8a5317e61
5
5
  SHA512:
6
- metadata.gz: 741d727da5bf655ae535c62a4a0eb8479a95ac6e5464550d5bbda26f504df0b1ccc51ff1e15e6f60881a22957a81406295a20eec3a8f98145a23f4a617364ccb
7
- data.tar.gz: 8ef95f432381be68a58135bd354d181790db79aebb8e04a822abbf7ecfcb1b4183c6157b73b6f46dd213e590be79bedc86794d80f6c8045eb0479cc9be2af083
6
+ metadata.gz: e2c78bbe4acf58b05f186547b72e39f10cd198e68fe22051ab268027177544e51111b95af0f3a44b9ec1d1e038ca8420ef2a871c537fbb17138e430fc8cab1d1
7
+ data.tar.gz: ad3b16633b516c60e14c8a9469acb912f74bc36c5e737fa636d4f2c32808636e76e718a1e3bcd7f30e7dcf2d93b278e31fdd1a71c08e5fe1574d16a484a0d184
data/README.md CHANGED
@@ -1,70 +1,85 @@
1
- # Getting Started with bandwidth
2
-
3
- Bandwidth's set of APIs
4
-
5
- ## Install the Package
6
-
7
- Install the gem from the command line:
8
-
9
- ```ruby
10
- gem install bandwidth-sdk -v 2.1.1
11
- ```
12
-
13
- Or add the gem to your Gemfile and run `bundle`:
14
-
15
- ```ruby
16
- gem 'bandwidth-sdk', '2.1.1'
17
- ```
18
-
19
- For additional gem details, see the [RubyGems page for the bandwidth-sdk gem](https://rubygems.org/gems/bandwidth-sdk/versions/2.1.1).
20
-
21
- ## Initialize the API Client
22
-
23
- The following parameters are configurable for the API Client.
24
-
25
- | Parameter | Type | Description |
26
- | --- | --- | --- |
27
- | `messaging_basic_auth_user_name` | `String` | The username to use with basic authentication |
28
- | `messaging_basic_auth_password` | `String` | The password to use with basic authentication |
29
- | `voice_basic_auth_user_name` | `String` | The username to use with basic authentication |
30
- | `voice_basic_auth_password` | `String` | The password to use with basic authentication |
31
- | `environment` | Environment | The API environment. <br> **Default: `Environment.PRODUCTION`** |
32
- | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
33
- | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
34
- | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
35
- | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 1** |
36
-
37
- The API client can be initialized as following.
38
-
39
- ```ruby
40
- client = Bandwidth::Client.new(
41
- messaging_basic_auth_user_name: 'MessagingBasicAuthUserName',
42
- messaging_basic_auth_password: 'MessagingBasicAuthPassword',
43
- voice_basic_auth_user_name: 'VoiceBasicAuthUserName',
44
- voice_basic_auth_password: 'VoiceBasicAuthPassword',
45
- environment: Environment::PRODUCTION,
46
- )
47
- ```
48
-
49
- API calls return an `ApiResponse` object that includes the following fields:
50
-
51
- | Field | Description |
52
- | --- | --- |
53
- | `status_code` | Status code of the HTTP response |
54
- | `reason_phrase` | Reason phrase of the HTTP response |
55
- | `headers` | Headers of the HTTP response as a Hash |
56
- | `raw_body` | The body of the HTTP response as a String |
57
- | `request` | HTTP request info |
58
- | `errors` | Errors, if they exist |
59
- | `data` | The deserialized body of the HTTP response |
60
-
61
- ## Authorization
62
-
63
- This API does not require authentication.
64
-
65
- ## API Reference
66
-
67
- ### List of APIs
68
-
69
- *
70
-
1
+ # Bandwidth Ruby SDK
2
+
3
+ Bandwidth's API docs can be found at https://dev.bandwidth.com
4
+
5
+ Ruby specific docs can be found at https://dev.bandwidth.com/sdks/ruby.html
6
+
7
+ ## Download & Install
8
+
9
+ ```
10
+ gem install bandwidth-sdk
11
+ ```
12
+
13
+ ## Initialize Bandwidth Client
14
+
15
+ ```ruby
16
+ require 'bandwidth'
17
+
18
+ include Bandwidth
19
+ include Bandwidth::Voice
20
+ include Bandwidth::Messaging
21
+
22
+ bandwidth_client = Bandwidth::Client.new(
23
+ voice_basic_auth_user_name: 'username',
24
+ voice_basic_auth_password: 'password',
25
+ messaging_basic_auth_user_name: 'token',
26
+ messaging_basic_auth_password: 'secret',
27
+ )
28
+ ```
29
+
30
+ ## Create Phone Call
31
+
32
+ ```ruby
33
+ voice_client = bandwidth_client.voice_client.client
34
+
35
+ account_id = '1'
36
+ body = ApiCreateCallRequest.new
37
+ body.from = '+16666666666'
38
+ body.to = '+17777777777'
39
+ body.answer_url = 'https://test.com'
40
+ body.application_id = '3-d-4-b-5'
41
+
42
+ begin
43
+ response = voice_client.create_call(account_id,:body => body)
44
+ puts response.data.call_id #c-d45a41e5-bcb12581-b18e-4bdc-9874-6r3235dfweao
45
+ puts response.status_code #201
46
+ rescue Bandwidth::ErrorResponseException => e
47
+ puts e.description #Invalid to: must be an E164 telephone number
48
+ puts e.response_code #400
49
+ end
50
+ ```
51
+
52
+ ## Generate BXML
53
+
54
+ ```ruby
55
+ response = Bandwidth::Voice::Response.new()
56
+ hangup = Bandwidth::Voice::Hangup.new()
57
+
58
+ response.push(hangup)
59
+ puts response.to_bxml()
60
+ ```
61
+
62
+ ## Send Text Message
63
+
64
+ ```ruby
65
+ messaging_client = bandwidth_client.messaging_client.client
66
+
67
+ account_id = '1'
68
+ body = MessageRequest.new
69
+ body.application_id = '1-2-3'
70
+ body.to = ['+17777777777']
71
+ body.from = '+18888888888'
72
+ body.text = 'Hello from Bandwidth'
73
+
74
+ begin
75
+ response = messaging_client.create_message(account_id, :body => body)
76
+ puts response.data.id #1570740275373xbn7mbhsfewasdr
77
+ puts response.status_code #202
78
+ rescue Bandwidth::GenericClientException => e
79
+ puts e.description #Access is denied
80
+ puts e.response_code #403
81
+ rescue Bandwidth::PathClientException => e
82
+ puts e.message #Your request could not be accepted.
83
+ puts e.response_code #400
84
+ end
85
+ ```
data/lib/bandwidth.rb CHANGED
@@ -12,6 +12,9 @@ require 'logging'
12
12
  require_relative 'bandwidth/api_helper.rb'
13
13
  require_relative 'bandwidth/client.rb'
14
14
 
15
+ # Utilities
16
+ require_relative 'bandwidth/utilities/file_wrapper.rb'
17
+
15
18
  # Http
16
19
  require_relative 'bandwidth/http/api_response.rb'
17
20
  require_relative 'bandwidth/http/http_call_back.rb'
@@ -32,8 +35,11 @@ require_relative 'bandwidth/configuration.rb'
32
35
  # Namespaces
33
36
  require_relative 'bandwidth/messaging_lib/messaging'
34
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'
35
40
  require_relative 'bandwidth/voice_lib/voice'
36
41
  require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
37
-
42
+ require_relative 'bandwidth/web_rtc_lib/web_rtc'
43
+ require_relative 'bandwidth/http/auth/web_rtc_basic_auth.rb'
38
44
 
39
45
  # Controllers
@@ -12,18 +12,32 @@ 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,
23
33
  messaging_basic_auth_user_name: 'TODO: Replace',
24
34
  messaging_basic_auth_password: 'TODO: Replace',
35
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
36
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
25
37
  voice_basic_auth_user_name: 'TODO: Replace',
26
- voice_basic_auth_password: 'TODO: Replace', config: nil)
38
+ voice_basic_auth_password: 'TODO: Replace',
39
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
40
+ web_rtc_basic_auth_password: 'TODO: Replace', config: nil)
27
41
  @config = if config.nil?
28
42
  Configuration.new(timeout: timeout, max_retries: max_retries,
29
43
  retry_interval: retry_interval,
@@ -31,8 +45,12 @@ module Bandwidth
31
45
  environment: environment,
32
46
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
33
47
  messaging_basic_auth_password: messaging_basic_auth_password,
48
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
49
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
34
50
  voice_basic_auth_user_name: voice_basic_auth_user_name,
35
- voice_basic_auth_password: voice_basic_auth_password)
51
+ voice_basic_auth_password: voice_basic_auth_password,
52
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
53
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password)
36
54
  else
37
55
  config
38
56
  end
@@ -16,7 +16,9 @@ module Bandwidth
16
16
  SERVER = [
17
17
  DEFAULT = 'default'.freeze,
18
18
  MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
19
- VOICEDEFAULT = 'VoiceDefault'.freeze
19
+ TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.freeze,
20
+ VOICEDEFAULT = 'VoiceDefault'.freeze,
21
+ WEBRTCDEFAULT = 'WebRtcDefault'.freeze
20
22
  ].freeze
21
23
  end
22
24
 
@@ -32,8 +34,12 @@ module Bandwidth
32
34
  attr_reader :environment
33
35
  attr_reader :messaging_basic_auth_user_name
34
36
  attr_reader :messaging_basic_auth_password
37
+ attr_reader :two_factor_auth_basic_auth_user_name
38
+ attr_reader :two_factor_auth_basic_auth_password
35
39
  attr_reader :voice_basic_auth_user_name
36
40
  attr_reader :voice_basic_auth_password
41
+ attr_reader :web_rtc_basic_auth_user_name
42
+ attr_reader :web_rtc_basic_auth_password
37
43
 
38
44
  class << self
39
45
  attr_reader :environments
@@ -43,8 +49,12 @@ module Bandwidth
43
49
  backoff_factor: 1, environment: Environment::PRODUCTION,
44
50
  messaging_basic_auth_user_name: 'TODO: Replace',
45
51
  messaging_basic_auth_password: 'TODO: Replace',
52
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
53
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
46
54
  voice_basic_auth_user_name: 'TODO: Replace',
47
- voice_basic_auth_password: 'TODO: Replace')
55
+ voice_basic_auth_password: 'TODO: Replace',
56
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
57
+ web_rtc_basic_auth_password: 'TODO: Replace')
48
58
  # The value to use for connection timeout
49
59
  @timeout = timeout
50
60
 
@@ -59,7 +69,7 @@ module Bandwidth
59
69
  @backoff_factor = backoff_factor
60
70
 
61
71
  # Current API environment
62
- @environment = environment
72
+ @environment = String(environment)
63
73
 
64
74
  # The username to use with basic authentication
65
75
  @messaging_basic_auth_user_name = messaging_basic_auth_user_name
@@ -67,12 +77,24 @@ module Bandwidth
67
77
  # The password to use with basic authentication
68
78
  @messaging_basic_auth_password = messaging_basic_auth_password
69
79
 
80
+ # The username to use with basic authentication
81
+ @two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name
82
+
83
+ # The password to use with basic authentication
84
+ @two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
85
+
70
86
  # The username to use with basic authentication
71
87
  @voice_basic_auth_user_name = voice_basic_auth_user_name
72
88
 
73
89
  # The password to use with basic authentication
74
90
  @voice_basic_auth_password = voice_basic_auth_password
75
91
 
92
+ # The username to use with basic authentication
93
+ @web_rtc_basic_auth_user_name = web_rtc_basic_auth_user_name
94
+
95
+ # The password to use with basic authentication
96
+ @web_rtc_basic_auth_password = web_rtc_basic_auth_password
97
+
76
98
  # The Http Client to use for making requests.
77
99
  @http_client = create_http_client
78
100
  end
@@ -81,8 +103,12 @@ module Bandwidth
81
103
  backoff_factor: nil, environment: nil,
82
104
  messaging_basic_auth_user_name: nil,
83
105
  messaging_basic_auth_password: nil,
106
+ two_factor_auth_basic_auth_user_name: nil,
107
+ two_factor_auth_basic_auth_password: nil,
84
108
  voice_basic_auth_user_name: nil,
85
- voice_basic_auth_password: nil)
109
+ voice_basic_auth_password: nil,
110
+ web_rtc_basic_auth_user_name: nil,
111
+ web_rtc_basic_auth_password: nil)
86
112
  timeout ||= self.timeout
87
113
  max_retries ||= self.max_retries
88
114
  retry_interval ||= self.retry_interval
@@ -90,8 +116,12 @@ module Bandwidth
90
116
  environment ||= self.environment
91
117
  messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
92
118
  messaging_basic_auth_password ||= self.messaging_basic_auth_password
119
+ two_factor_auth_basic_auth_user_name ||= self.two_factor_auth_basic_auth_user_name
120
+ two_factor_auth_basic_auth_password ||= self.two_factor_auth_basic_auth_password
93
121
  voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
94
122
  voice_basic_auth_password ||= self.voice_basic_auth_password
123
+ web_rtc_basic_auth_user_name ||= self.web_rtc_basic_auth_user_name
124
+ web_rtc_basic_auth_password ||= self.web_rtc_basic_auth_password
95
125
 
96
126
  Configuration.new(
97
127
  timeout: timeout, max_retries: max_retries,
@@ -99,8 +129,12 @@ module Bandwidth
99
129
  environment: environment,
100
130
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
101
131
  messaging_basic_auth_password: messaging_basic_auth_password,
132
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
133
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
102
134
  voice_basic_auth_user_name: voice_basic_auth_user_name,
103
- voice_basic_auth_password: voice_basic_auth_password
135
+ voice_basic_auth_password: voice_basic_auth_password,
136
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
137
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password
104
138
  )
105
139
  end
106
140
 
@@ -111,20 +145,22 @@ module Bandwidth
111
145
  end
112
146
 
113
147
  # All the environments the SDK can run in.
114
- @environments = {
148
+ ENVIRONMENTS = {
115
149
  Environment::PRODUCTION => {
116
150
  Server::DEFAULT => 'api.bandwidth.com',
117
151
  Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
118
- Server::VOICEDEFAULT => 'https://voice.bandwidth.com'
152
+ Server::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1/',
153
+ Server::VOICEDEFAULT => 'https://voice.bandwidth.com',
154
+ Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
119
155
  }
120
- }
156
+ }.freeze
121
157
 
122
158
  # Generates the appropriate base URI for the environment and the server.
123
159
  # @param [Configuration::Server] The server enum for which the base URI is
124
160
  # required.
125
161
  # @return [String] The base URI.
126
162
  def get_base_uri(server = Server::DEFAULT)
127
- self.class.environments[environment][server].clone
163
+ ENVIRONMENTS[environment][server].clone
128
164
  end
129
165
  end
130
166
  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
@@ -34,9 +34,7 @@ module Bandwidth
34
34
  http_request.query_url
35
35
  ) do |request|
36
36
  request.headers = http_request.headers
37
- unless http_request.parameters.empty?
38
- request.body = http_request.parameters
39
- end
37
+ request.body = http_request.parameters
40
38
  end
41
39
  convert_response(response, http_request)
42
40
  end
@@ -48,9 +46,7 @@ module Bandwidth
48
46
  http_request.query_url
49
47
  ) do |request|
50
48
  request.headers = http_request.headers
51
- unless http_request.parameters.empty?
52
- request.body = http_request.parameters
53
- end
49
+ request.body = http_request.parameters
54
50
  end
55
51
  convert_response(response, http_request)
56
52
  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'