Skip to content

Commit

Permalink
MFA package renaming, voice class and method renaming, body parameter…
Browse files Browse the repository at this point in the history
… definition set to required, and messaging upload media removal of content length parameter (breaking changes) (#24)

* New deploy

* version bump, import fixes

* updated tests

* fixed parameters and errors

* jacob cannot read

Co-authored-by: jmulford-bw <[email protected]>
  • Loading branch information
jmulford-bw and DX-Bandwidth authored Jul 15, 2021
1 parent b91eb4d commit 8bf0706
Show file tree
Hide file tree
Showing 53 changed files with 1,138 additions and 1,032 deletions.
2 changes: 1 addition & 1 deletion bandwidth.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'bandwidth-sdk'
s.version = '6.2.0'
s.version = '7.0.0'
s.summary = 'bandwidth'
s.description = 'Bandwidth\'s set of APIs'
s.authors = ['APIMatic SDK Generator']
Expand Down
5 changes: 3 additions & 2 deletions lib/bandwidth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# Utilities
require_relative 'bandwidth/utilities/file_wrapper.rb'
require_relative 'bandwidth/utilities/date_time_helper.rb'

# Http
require_relative 'bandwidth/http/api_response.rb'
Expand All @@ -35,8 +36,8 @@
# Namespaces
require_relative 'bandwidth/messaging_lib/messaging'
require_relative 'bandwidth/http/auth/messaging_basic_auth.rb'
require_relative 'bandwidth/two_factor_auth_lib/two_factor_auth'
require_relative 'bandwidth/http/auth/two_factor_auth_basic_auth.rb'
require_relative 'bandwidth/multi_factor_auth_lib/multi_factor_auth'
require_relative 'bandwidth/http/auth/multi_factor_auth_basic_auth.rb'
require_relative 'bandwidth/phone_number_lookup_lib/phone_number_lookup'
require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth.rb'
require_relative 'bandwidth/voice_lib/voice'
Expand Down
12 changes: 0 additions & 12 deletions lib/bandwidth/api_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,5 @@ def self.map_response(obj, keys)
end
val
end

# Safely converts a string into an rfc3339 DateTime object
# @param [String] The datetime string
# @return [DateTime] A DateTime object of rfc3339 format
def self.rfc3339(date_time)
# missing timezone information
if date_time.end_with?('Z') || date_time.index('+')
DateTime.rfc3339(date_time)
else
DateTime.rfc3339(date_time + 'Z')
end
end
end
end
16 changes: 8 additions & 8 deletions lib/bandwidth/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class Client
def messaging_client
@messaging_client ||= Messaging::Client.new(config: config)
end
# Access to two_factor_auth_client controller.
# @return [TwoFactorAuth::Client] Returns the client instance.
def two_factor_auth_client
@two_factor_auth_client ||= TwoFactorAuth::Client.new(config: config)
# Access to multi_factor_auth_client controller.
# @return [MultiFactorAuth::Client] Returns the client instance.
def multi_factor_auth_client
@multi_factor_auth_client ||= MultiFactorAuth::Client.new(config: config)
end
# Access to phone_number_lookup_client controller.
# @return [PhoneNumberLookup::Client] Returns the client instance.
Expand All @@ -41,8 +41,8 @@ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
base_url: 'https://www.example.com',
messaging_basic_auth_user_name: 'TODO: Replace',
messaging_basic_auth_password: 'TODO: Replace',
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
two_factor_auth_basic_auth_password: 'TODO: Replace',
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
multi_factor_auth_basic_auth_password: 'TODO: Replace',
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
phone_number_lookup_basic_auth_password: 'TODO: Replace',
voice_basic_auth_user_name: 'TODO: Replace',
Expand All @@ -59,8 +59,8 @@ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
base_url: base_url,
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
messaging_basic_auth_password: messaging_basic_auth_password,
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
voice_basic_auth_user_name: voice_basic_auth_user_name,
Expand Down
30 changes: 15 additions & 15 deletions lib/bandwidth/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Server
SERVER = [
DEFAULT = 'default'.freeze,
MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.freeze,
MULTIFACTORAUTHDEFAULT = 'MultiFactorAuthDefault'.freeze,
PHONENUMBERLOOKUPDEFAULT = 'PhoneNumberLookupDefault'.freeze,
VOICEDEFAULT = 'VoiceDefault'.freeze,
WEBRTCDEFAULT = 'WebRtcDefault'.freeze
Expand All @@ -39,8 +39,8 @@ class Configuration
attr_reader :base_url
attr_reader :messaging_basic_auth_user_name
attr_reader :messaging_basic_auth_password
attr_reader :two_factor_auth_basic_auth_user_name
attr_reader :two_factor_auth_basic_auth_password
attr_reader :multi_factor_auth_basic_auth_user_name
attr_reader :multi_factor_auth_basic_auth_password
attr_reader :phone_number_lookup_basic_auth_user_name
attr_reader :phone_number_lookup_basic_auth_password
attr_reader :voice_basic_auth_user_name
Expand All @@ -60,8 +60,8 @@ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
base_url: 'https://www.example.com',
messaging_basic_auth_user_name: 'TODO: Replace',
messaging_basic_auth_password: 'TODO: Replace',
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
two_factor_auth_basic_auth_password: 'TODO: Replace',
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
multi_factor_auth_basic_auth_password: 'TODO: Replace',
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
phone_number_lookup_basic_auth_password: 'TODO: Replace',
voice_basic_auth_user_name: 'TODO: Replace',
Expand Down Expand Up @@ -100,10 +100,10 @@ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
@messaging_basic_auth_password = messaging_basic_auth_password

# The username to use with basic authentication
@two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name
@multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name

# The password to use with basic authentication
@two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
@multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password

# The username to use with basic authentication
@phone_number_lookup_basic_auth_user_name = phone_number_lookup_basic_auth_user_name
Expand Down Expand Up @@ -132,8 +132,8 @@ def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
environment: nil, base_url: nil,
messaging_basic_auth_user_name: nil,
messaging_basic_auth_password: nil,
two_factor_auth_basic_auth_user_name: nil,
two_factor_auth_basic_auth_password: nil,
multi_factor_auth_basic_auth_user_name: nil,
multi_factor_auth_basic_auth_password: nil,
phone_number_lookup_basic_auth_user_name: nil,
phone_number_lookup_basic_auth_password: nil,
voice_basic_auth_user_name: nil,
Expand All @@ -150,8 +150,8 @@ def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
base_url ||= self.base_url
messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
messaging_basic_auth_password ||= self.messaging_basic_auth_password
two_factor_auth_basic_auth_user_name ||= self.two_factor_auth_basic_auth_user_name
two_factor_auth_basic_auth_password ||= self.two_factor_auth_basic_auth_password
multi_factor_auth_basic_auth_user_name ||= self.multi_factor_auth_basic_auth_user_name
multi_factor_auth_basic_auth_password ||= self.multi_factor_auth_basic_auth_password
phone_number_lookup_basic_auth_user_name ||= self.phone_number_lookup_basic_auth_user_name
phone_number_lookup_basic_auth_password ||= self.phone_number_lookup_basic_auth_password
voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
Expand All @@ -166,8 +166,8 @@ def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
environment: environment, base_url: base_url,
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
messaging_basic_auth_password: messaging_basic_auth_password,
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
voice_basic_auth_user_name: voice_basic_auth_user_name,
Expand All @@ -190,15 +190,15 @@ def create_http_client
Environment::PRODUCTION => {
Server::DEFAULT => 'api.bandwidth.com',
Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
Server::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1',
Server::MULTIFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1',
Server::PHONENUMBERLOOKUPDEFAULT => 'https://numbers.bandwidth.com/api/v1',
Server::VOICEDEFAULT => 'https://voice.bandwidth.com',
Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
},
Environment::CUSTOM => {
Server::DEFAULT => '{base_url}',
Server::MESSAGINGDEFAULT => '{base_url}',
Server::TWOFACTORAUTHDEFAULT => '{base_url}',
Server::MULTIFACTORAUTHDEFAULT => '{base_url}',
Server::PHONENUMBERLOOKUPDEFAULT => '{base_url}',
Server::VOICEDEFAULT => '{base_url}',
Server::WEBRTCDEFAULT => '{base_url}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

module Bandwidth
# Utility class for basic authorization.
class TwoFactorAuthBasicAuth
class MultiFactorAuthBasicAuth
# Add basic authentication to the request.
# @param [HttpRequest] The HttpRequest object to which authentication will
# be added.
def self.apply(config, http_request)
username = config.two_factor_auth_basic_auth_user_name
password = config.two_factor_auth_basic_auth_password
username = config.multi_factor_auth_basic_auth_user_name
password = config.multi_factor_auth_basic_auth_password
value = Base64.strict_encode64("#{username}:#{password}")
header_value = "Basic #{value}"
http_request.headers['Authorization'] = header_value
Expand Down
19 changes: 14 additions & 5 deletions lib/bandwidth/messaging_lib/messaging/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ def client
end

def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
backoff_factor: 1, environment: Environment::PRODUCTION,
backoff_factor: 2,
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
retry_methods: %i[get put get put],
environment: Environment::PRODUCTION,
base_url: 'https://www.example.com',
messaging_basic_auth_user_name: 'TODO: Replace',
messaging_basic_auth_password: 'TODO: Replace',
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
two_factor_auth_basic_auth_password: 'TODO: Replace',
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
multi_factor_auth_basic_auth_password: 'TODO: Replace',
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
phone_number_lookup_basic_auth_password: 'TODO: Replace',
voice_basic_auth_user_name: 'TODO: Replace',
voice_basic_auth_password: 'TODO: Replace',
web_rtc_basic_auth_user_name: 'TODO: Replace',
Expand All @@ -32,12 +37,16 @@ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
max_retries: max_retries,
retry_interval: retry_interval,
backoff_factor: backoff_factor,
retry_statuses: retry_statuses,
retry_methods: retry_methods,
environment: environment,
base_url: base_url,
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
messaging_basic_auth_password: messaging_basic_auth_password,
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
voice_basic_auth_user_name: voice_basic_auth_user_name,
voice_basic_auth_password: voice_basic_auth_password,
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
Expand Down
Loading

0 comments on commit 8bf0706

Please sign in to comment.