diff --git a/bandwidth.gemspec b/bandwidth.gemspec index 41260578..d701ffd1 100644 --- a/bandwidth.gemspec +++ b/bandwidth.gemspec @@ -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'] diff --git a/lib/bandwidth.rb b/lib/bandwidth.rb index 8c0e1f11..c92ce8d8 100644 --- a/lib/bandwidth.rb +++ b/lib/bandwidth.rb @@ -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' @@ -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' diff --git a/lib/bandwidth/api_helper.rb b/lib/bandwidth/api_helper.rb index 4fcb37a4..51a7fbca 100644 --- a/lib/bandwidth/api_helper.rb +++ b/lib/bandwidth/api_helper.rb @@ -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 diff --git a/lib/bandwidth/client.rb b/lib/bandwidth/client.rb index 5da64e21..da27ae0f 100644 --- a/lib/bandwidth/client.rb +++ b/lib/bandwidth/client.rb @@ -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. @@ -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', @@ -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, diff --git a/lib/bandwidth/configuration.rb b/lib/bandwidth/configuration.rb index 4d5c1812..af977e47 100644 --- a/lib/bandwidth/configuration.rb +++ b/lib/bandwidth/configuration.rb @@ -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 @@ -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 @@ -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', @@ -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 @@ -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, @@ -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 @@ -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, @@ -190,7 +190,7 @@ 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' @@ -198,7 +198,7 @@ def create_http_client 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}' diff --git a/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb b/lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb similarity index 74% rename from lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb rename to lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb index 11a4f0ad..0498e099 100644 --- a/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +++ b/lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb @@ -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 diff --git a/lib/bandwidth/messaging_lib/messaging/client.rb b/lib/bandwidth/messaging_lib/messaging/client.rb index 2179aa6e..bb34f7d8 100644 --- a/lib/bandwidth/messaging_lib/messaging/client.rb +++ b/lib/bandwidth/messaging_lib/messaging/client.rb @@ -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', @@ -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, diff --git a/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb b/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb index 09612223..f9e49af2 100644 --- a/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +++ b/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb @@ -12,18 +12,18 @@ def initialize(config, http_call_back: nil) end # listMedia - # @param [String] user_id Required parameter: User's account ID + # @param [String] account_id Required parameter: User's account ID # @param [String] continuation_token Optional parameter: Continuation token # used to retrieve subsequent media. # @return [List of Media] response from the API call - def list_media(user_id, + def list_media(account_id, continuation_token: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{userId}/media' + _query_builder << '/users/{accountId}/media' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, - 'userId' => { 'value' => user_id, 'encode' => false } + 'accountId' => { 'value' => account_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder @@ -84,17 +84,17 @@ def list_media(user_id, end # getMedia - # @param [String] user_id Required parameter: User's account ID + # @param [String] account_id Required parameter: User's account ID # @param [String] media_id Required parameter: Media ID to retrieve # @return [Binary] response from the API call - def get_media(user_id, + def get_media(account_id, media_id) # Prepare query url. _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{userId}/media/{mediaId}' + _query_builder << '/users/{accountId}/media/{mediaId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, - 'userId' => { 'value' => user_id, 'encode' => false }, + 'accountId' => { 'value' => account_id, 'encode' => false }, 'mediaId' => { 'value' => media_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder @@ -147,11 +147,9 @@ def get_media(user_id, end # uploadMedia - # @param [String] user_id Required parameter: User's account ID + # @param [String] account_id Required parameter: User's account ID # @param [String] media_id Required parameter: The user supplied custom # media ID - # @param [Long] content_length Required parameter: The size of the - # entity-body # @param [File | UploadIO] body Required parameter: Example: # @param [String] content_type Optional parameter: The media type of the # entity-body @@ -159,18 +157,17 @@ def get_media(user_id, # used to specify directives that MUST be obeyed by all caching mechanisms # along the request/response chain. # @return [void] response from the API call - def upload_media(user_id, + def upload_media(account_id, media_id, - content_length, body, content_type: 'application/octet-stream', cache_control: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{userId}/media/{mediaId}' + _query_builder << '/users/{accountId}/media/{mediaId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, - 'userId' => { 'value' => user_id, 'encode' => false }, + 'accountId' => { 'value' => account_id, 'encode' => false }, 'mediaId' => { 'value' => media_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder @@ -187,7 +184,6 @@ def upload_media(user_id, _headers = { 'content-type' => body_content_type, 'content-length' => body_wrapper.size.to_s, - 'Content-Length' => content_length, 'Cache-Control' => cache_control } @@ -239,17 +235,17 @@ def upload_media(user_id, end # deleteMedia - # @param [String] user_id Required parameter: User's account ID + # @param [String] account_id Required parameter: User's account ID # @param [String] media_id Required parameter: The media ID to delete # @return [void] response from the API call - def delete_media(user_id, + def delete_media(account_id, media_id) # Prepare query url. _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{userId}/media/{mediaId}' + _query_builder << '/users/{accountId}/media/{mediaId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, - 'userId' => { 'value' => user_id, 'encode' => false }, + 'accountId' => { 'value' => account_id, 'encode' => false }, 'mediaId' => { 'value' => media_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder @@ -300,7 +296,7 @@ def delete_media(user_id, end # getMessages - # @param [String] user_id Required parameter: User's account ID + # @param [String] account_id Required parameter: User's account ID # @param [String] message_id Optional parameter: The ID of the message to # search for. Special characters need to be encoded using URL encoding # @param [String] source_tn Optional parameter: The phone number that sent @@ -309,7 +305,7 @@ def delete_media(user_id, # received the message # @param [String] message_status Optional parameter: The status of the # message. One of RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED, - # DLR_EXPIRED + # ACCEPTED, UNDELIVERED # @param [Integer] error_code Optional parameter: The error code of the # message # @param [String] from_date_time Optional parameter: The start of the date @@ -324,7 +320,7 @@ def delete_media(user_id, # in search result. Default 100. The sum of limit and after cannot be more # than 10000 # @return [BandwidthMessagesList] response from the API call - def get_messages(user_id, + def get_messages(account_id, message_id: nil, source_tn: nil, destination_tn: nil, @@ -336,10 +332,10 @@ def get_messages(user_id, limit: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{userId}/messages' + _query_builder << '/users/{accountId}/messages' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, - 'userId' => { 'value' => user_id, 'encode' => false } + 'accountId' => { 'value' => account_id, 'encode' => false } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, @@ -410,17 +406,17 @@ def get_messages(user_id, end # createMessage - # @param [String] user_id Required parameter: User's account ID + # @param [String] account_id Required parameter: User's account ID # @param [MessageRequest] body Required parameter: Example: # @return [BandwidthMessage] response from the API call - def create_message(user_id, + def create_message(account_id, body) # Prepare query url. _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{userId}/messages' + _query_builder << '/users/{accountId}/messages' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, - 'userId' => { 'value' => user_id, 'encode' => false } + 'accountId' => { 'value' => account_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder diff --git a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb b/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb index bda17985..84334220 100644 --- a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +++ b/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb @@ -50,6 +50,26 @@ class BandwidthMessageItem < BaseModel # @return [String] attr_accessor :carrier_name + # The size of the message including message content and headers + # @return [Integer] + attr_accessor :message_size + + # The length of the message content + # @return [Integer] + attr_accessor :message_length + + # The number of attachments the message has + # @return [Integer] + attr_accessor :attachment_count + + # The number of recipients the message has + # @return [Integer] + attr_accessor :recipient_count + + # The campaign class of the message, if it has one + # @return [String] + attr_accessor :campaign_class + # A mapping from model property names to API property names. def self.names @_hash = {} if @_hash.nil? @@ -64,6 +84,11 @@ def self.names @_hash['error_code'] = 'errorCode' @_hash['receive_time'] = 'receiveTime' @_hash['carrier_name'] = 'carrierName' + @_hash['message_size'] = 'messageSize' + @_hash['message_length'] = 'messageLength' + @_hash['attachment_count'] = 'attachmentCount' + @_hash['recipient_count'] = 'recipientCount' + @_hash['campaign_class'] = 'campaignClass' @_hash end @@ -77,7 +102,12 @@ def initialize(message_id = nil, segment_count = nil, error_code = nil, receive_time = nil, - carrier_name = nil) + carrier_name = nil, + message_size = nil, + message_length = nil, + attachment_count = nil, + recipient_count = nil, + campaign_class = nil) @message_id = message_id @account_id = account_id @source_tn = source_tn @@ -89,6 +119,11 @@ def initialize(message_id = nil, @error_code = error_code @receive_time = receive_time @carrier_name = carrier_name + @message_size = message_size + @message_length = message_length + @attachment_count = attachment_count + @recipient_count = recipient_count + @campaign_class = campaign_class end # Creates an instance of the object from a hash. @@ -107,6 +142,11 @@ def self.from_hash(hash) error_code = hash['errorCode'] receive_time = hash['receiveTime'] carrier_name = hash['carrierName'] + message_size = hash['messageSize'] + message_length = hash['messageLength'] + attachment_count = hash['attachmentCount'] + recipient_count = hash['recipientCount'] + campaign_class = hash['campaignClass'] # Create object from extracted values. BandwidthMessageItem.new(message_id, @@ -119,7 +159,12 @@ def self.from_hash(hash) segment_count, error_code, receive_time, - carrier_name) + carrier_name, + message_size, + message_length, + attachment_count, + recipient_count, + campaign_class) end end end diff --git a/lib/bandwidth/messaging_lib/messaging/models/media.rb b/lib/bandwidth/messaging_lib/messaging/models/media.rb index e3f38c2d..9a02d2c8 100644 --- a/lib/bandwidth/messaging_lib/messaging/models/media.rb +++ b/lib/bandwidth/messaging_lib/messaging/models/media.rb @@ -6,82 +6,33 @@ module Bandwidth # Media Model. class Media < BaseModel - # TODO: Write general description for this method - # @return [Object] - attr_accessor :input_stream - # TODO: Write general description for this method # @return [String] attr_accessor :content # TODO: Write general description for this method - # @return [String] - attr_accessor :url - - # TODO: Write general description for this method - # @return [String] + # @return [Integer] attr_accessor :content_length # TODO: Write general description for this method # @return [String] - attr_accessor :content_type - - # TODO: Write general description for this method - # @return [List of Tag] - attr_accessor :tags - - # User's account ID - # @return [String] - attr_accessor :user_id - - # User's account ID - # @return [String] attr_accessor :media_name - # User's account ID - # @return [String] - attr_accessor :media_id - - # User's account ID - # @return [String] - attr_accessor :cache_control - # A mapping from model property names to API property names. def self.names @_hash = {} if @_hash.nil? - @_hash['input_stream'] = 'inputStream' @_hash['content'] = 'content' - @_hash['url'] = 'url' @_hash['content_length'] = 'contentLength' - @_hash['content_type'] = 'contentType' - @_hash['tags'] = 'tags' - @_hash['user_id'] = 'userId' @_hash['media_name'] = 'mediaName' - @_hash['media_id'] = 'mediaId' - @_hash['cache_control'] = 'cacheControl' @_hash end - def initialize(input_stream = nil, - content = nil, - url = nil, + def initialize(content = nil, content_length = nil, - content_type = nil, - tags = nil, - user_id = nil, - media_name = nil, - media_id = nil, - cache_control = nil) - @input_stream = input_stream + media_name = nil) @content = content - @url = url @content_length = content_length - @content_type = content_type - @tags = tags - @user_id = user_id @media_name = media_name - @media_id = media_id - @cache_control = cache_control end # Creates an instance of the object from a hash. @@ -89,35 +40,14 @@ def self.from_hash(hash) return nil unless hash # Extract variables from the hash. - input_stream = hash['inputStream'] content = hash['content'] - url = hash['url'] content_length = hash['contentLength'] - content_type = hash['contentType'] - # Parameter is an array, so we need to iterate through it - tags = nil - unless hash['tags'].nil? - tags = [] - hash['tags'].each do |structure| - tags << (Tag.from_hash(structure) if structure) - end - end - user_id = hash['userId'] media_name = hash['mediaName'] - media_id = hash['mediaId'] - cache_control = hash['cacheControl'] # Create object from extracted values. - Media.new(input_stream, - content, - url, + Media.new(content, content_length, - content_type, - tags, - user_id, - media_name, - media_id, - cache_control) + media_name) end end end diff --git a/lib/bandwidth/models/base_model.rb b/lib/bandwidth/models/base_model.rb index ff7e1832..f9040659 100644 --- a/lib/bandwidth/models/base_model.rb +++ b/lib/bandwidth/models/base_model.rb @@ -13,15 +13,26 @@ def to_hash value = instance_variable_get(name) name = name[1..-1] key = self.class.names.key?(name) ? self.class.names[name] : name - if value.instance_of? Array - hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v } - elsif value.instance_of? Hash - hash[key] = {} - value.each do |k, v| - hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v + + hash[key] = nil + unless value.nil? + if respond_to?("to_#{name}") + if (value.instance_of? Array) || (value.instance_of? Hash) + params = [hash, key] + hash[key] = send("to_#{name}", *params) + else + hash[key] = send("to_#{name}") + end + elsif value.instance_of? Array + hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v } + elsif value.instance_of? Hash + hash[key] = {} + value.each do |k, v| + hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v + end + else + hash[key] = value.is_a?(BaseModel) ? value.to_hash : value end - else - hash[key] = value.is_a?(BaseModel) ? value.to_hash : value end end hash diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb new file mode 100644 index 00000000..e7fe82c1 --- /dev/null +++ b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb @@ -0,0 +1,23 @@ +# bandwidth +# +# This file was automatically generated by APIMATIC v2.0 +# ( https://apimatic.io ). + + +require_relative 'multi_factor_auth/client.rb' + +# Models +require_relative 'multi_factor_auth/models/two_factor_code_request_schema.rb' +require_relative 'multi_factor_auth/models/two_factor_voice_response.rb' +require_relative 'multi_factor_auth/models/two_factor_messaging_response.rb' +require_relative 'multi_factor_auth/models/two_factor_verify_request_schema.rb' +require_relative 'multi_factor_auth/models/two_factor_verify_code_response.rb' + +# Exceptions +require_relative 'multi_factor_auth/exceptions/error_with_request_exception.rb' +require_relative 'multi_factor_auth/exceptions/unauthorized_request' \ + '_exception.rb' +require_relative 'multi_factor_auth/exceptions/forbidden_request_exception.rb' +# Controllers +require_relative 'multi_factor_auth/controllers/base_controller.rb' +require_relative 'multi_factor_auth/controllers/mfa_controller.rb' diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb similarity index 60% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb index ea6797e2..9bf860c5 100644 --- a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +++ b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb @@ -4,7 +4,7 @@ # ( https://apimatic.io ). module Bandwidth - module TwoFactorAuth + module MultiFactorAuth # bandwidth client class. class Client attr_reader :config @@ -16,12 +16,17 @@ def mfa 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', @@ -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, diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/mfa_controller.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb similarity index 91% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/mfa_controller.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb index 038ec807..863294e3 100644 --- a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/mfa_controller.rb +++ b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb @@ -4,7 +4,7 @@ # ( https://apimatic.io ). module Bandwidth -module TwoFactorAuth +module MultiFactorAuth # MFAController class MFAController < BaseController def initialize(config, http_call_back: nil) @@ -19,7 +19,7 @@ def initialize(config, http_call_back: nil) def create_voice_two_factor(account_id, body) # Prepare query url. - _query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT) + _query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT) _query_builder << '/accounts/{accountId}/code/voice' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, @@ -39,7 +39,7 @@ def create_voice_two_factor(account_id, headers: _headers, parameters: body.to_json ) - TwoFactorAuthBasicAuth.apply(config, _request) + MultiFactorAuthBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. @@ -81,7 +81,7 @@ def create_voice_two_factor(account_id, def create_messaging_two_factor(account_id, body) # Prepare query url. - _query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT) + _query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT) _query_builder << '/accounts/{accountId}/code/messaging' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, @@ -101,7 +101,7 @@ def create_messaging_two_factor(account_id, headers: _headers, parameters: body.to_json ) - TwoFactorAuthBasicAuth.apply(config, _request) + MultiFactorAuthBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. @@ -144,7 +144,7 @@ def create_messaging_two_factor(account_id, def create_verify_two_factor(account_id, body) # Prepare query url. - _query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT) + _query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT) _query_builder << '/accounts/{accountId}/code/verify' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, @@ -164,7 +164,7 @@ def create_verify_two_factor(account_id, headers: _headers, parameters: body.to_json ) - TwoFactorAuthBasicAuth.apply(config, _request) + MultiFactorAuthBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/forbidden_request_exception.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/forbidden_request_exception.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb similarity index 100% rename from lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb rename to lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb diff --git a/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb b/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb deleted file mode 100644 index 44f55c23..00000000 --- a/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +++ /dev/null @@ -1,22 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - - -require_relative 'two_factor_auth/client.rb' - -# Models -require_relative 'two_factor_auth/models/two_factor_code_request_schema.rb' -require_relative 'two_factor_auth/models/two_factor_voice_response.rb' -require_relative 'two_factor_auth/models/two_factor_messaging_response.rb' -require_relative 'two_factor_auth/models/two_factor_verify_request_schema.rb' -require_relative 'two_factor_auth/models/two_factor_verify_code_response.rb' - -# Exceptions -require_relative 'two_factor_auth/exceptions/error_with_request_exception.rb' -require_relative 'two_factor_auth/exceptions/unauthorized_request_exception.rb' -require_relative 'two_factor_auth/exceptions/forbidden_request_exception.rb' -# Controllers -require_relative 'two_factor_auth/controllers/base_controller.rb' -require_relative 'two_factor_auth/controllers/mfa_controller.rb' diff --git a/lib/bandwidth/utilities/date_time_helper.rb b/lib/bandwidth/utilities/date_time_helper.rb new file mode 100644 index 00000000..f82c2bf4 --- /dev/null +++ b/lib/bandwidth/utilities/date_time_helper.rb @@ -0,0 +1,156 @@ +# bandwidth +# +# This file was automatically generated by APIMATIC v2.0 +# ( https://apimatic.io ). + +require 'date' +module Bandwidth + # A utility that supports dateTime conversion to different formats + class DateTimeHelper + # Safely converts a DateTime object into a rfc1123 format string + # @param [DateTime] The DateTime object + # @return [String] The rfc1123 formatted datetime string + def self.to_rfc1123(date_time) + date_time.httpdate unless date_time.nil? + end + + # Safely converts a map of DateTime objects into a map of rfc1123 format string + # @param [hash] a map of DateTime objects + # @return [hash] a map of rfc1123 formatted datetime string + def self.to_rfc1123_map(date_time, hash, key) + return if date_time.nil? + + hash[key] = {} + date_time.each do |k, v| + hash[key][k] = + if v.is_a?(BaseModel) + v.to_hash + else + v.is_a?(DateTime) ? DateTimeHelper.to_rfc1123(v) : v + end + end + hash[key] + end + + # Safely converts an array of DateTime objects into an array of rfc1123 format string + # @param [Array] an array of DateTime objects + # @return [Array] an array of rfc1123 formatted datetime string + def self.to_rfc1123_array(date_time, hash, key) + return if date_time.nil? + + hash[key] = date_time.map do |v| + if v.is_a?(BaseModel) + v.to_hash + else + v.is_a?(DateTime) ? DateTimeHelper.to_rfc1123(v) : v + end + end + end + + # Safely converts a DateTime object into a unix format string + # @param [DateTime] The DateTime object + # @return [String] The unix formatted datetime string + def self.to_unix(date_time) + date_time.to_time.utc.to_i unless date_time.nil? + end + + # Safely converts a map of DateTime objects into a map of unix format string + # @param [hash] a map of DateTime objects + # @return [hash] a map of unix formatted datetime string + def self.to_unix_map(date_time, hash, key) + return if date_time.nil? + + hash[key] = {} + date_time.each do |k, v| + hash[key][k] = + if v.is_a?(BaseModel) + v.to_hash + else + v.is_a?(DateTime) ? DateTimeHelper.to_unix(v) : v + end + end + hash[key] + end + + # Safely converts an array of DateTime objects into a map of unix format string + # @param [hash] an array of DateTime objects + # @return [hash] an array of unix formatted datetime string + def self.to_unix_array(date_time, hash, key) + return if date_time.nil? + + hash[key] = date_time.map do |v| + if v.is_a?(BaseModel) + v.to_hash + else + v.is_a?(DateTime) ? DateTimeHelper.to_unix(v) : v + end + end + end + + # Safely converts a DateTime object into a rfc3339 format string + # @param [DateTime] The DateTime object + # @return [String] The rfc3339 formatted datetime string + def self.to_rfc3339(date_time) + date_time.rfc3339 unless date_time.nil? + end + + # Safely converts a map of DateTime objects into a map of rfc1123 format string + # @param [hash] a map of DateTime objects + # @return [hash] a map of rfc1123 formatted datetime string + def self.to_rfc3339_map(date_time, hash, key) + return if date_time.nil? + + hash[key] = {} + date_time.each do |k, v| + hash[key][k] = + if v.is_a?(BaseModel) + v.to_hash + else + v.is_a?(DateTime) ? DateTimeHelper.to_rfc3339(v) : v + end + end + hash[key] + end + + # Safely converts an array of DateTime objects into an array of rfc1123 format string + # @param [Array] an array of DateTime objects + # @return [Array] an array of rfc1123 formatted datetime string + def self.to_rfc3339_array(date_time, hash, key) + return if date_time.nil? + + hash[key] = date_time.map do |v| + if v.is_a?(BaseModel) + v.to_hash + else + v.is_a?(DateTime) ? DateTimeHelper.to_rfc3339(v) : v + end + end + end + + # Safely converts a rfc1123 format string into a DateTime object + # @param [String] The rfc1123 formatted datetime string + # @return [DateTime] A DateTime object + def self.from_rfc1123(date_time) + DateTime.httpdate(date_time) + end + + # Safely converts a unix format string into a DateTime object + # @param [String] The unix formatted datetime string + # @return [DateTime] A DateTime object + def self.from_unix(date_time) + Time.at(date_time.to_i).utc.to_datetime + end + + # Safely converts a rfc3339 format string into a DateTime object + # @param [String] The rfc3339 formatted datetime string + # @return [DateTime] A DateTime object + def self.from_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 diff --git a/lib/bandwidth/voice_lib/voice.rb b/lib/bandwidth/voice_lib/voice.rb index 46a58e54..42112da4 100644 --- a/lib/bandwidth/voice_lib/voice.rb +++ b/lib/bandwidth/voice_lib/voice.rb @@ -7,39 +7,35 @@ require_relative 'voice/client.rb' # Models -require_relative 'voice/models/api_call_response.rb' -require_relative 'voice/models/api_call_state_response.rb' -require_relative 'voice/models/api_create_call_request.rb' -require_relative 'voice/models/api_modify_call_request.rb' -require_relative 'voice/models/api_modify_conference_request.rb' -require_relative 'voice/models/api_transcribe_recording_request.rb' -require_relative 'voice/models/conference_detail.rb' -require_relative 'voice/models/conference_member_detail.rb' -require_relative 'voice/models/conference_recording_metadata_response.rb' -require_relative 'voice/models/modify_call_recording_state.rb' -require_relative 'voice/models/recording_metadata_response.rb' -require_relative 'voice/models/transcript.rb' -require_relative 'voice/models/transcription.rb' +require_relative 'voice/models/create_call_request.rb' +require_relative 'voice/models/create_call_response.rb' +require_relative 'voice/models/call_state.rb' +require_relative 'voice/models/modify_call_request.rb' +require_relative 'voice/models/modify_call_recording_request.rb' +require_relative 'voice/models/call_recording_metadata.rb' +require_relative 'voice/models/modify_conference_request.rb' +require_relative 'voice/models/conference_state.rb' +require_relative 'voice/models/conference_member_state.rb' +require_relative 'voice/models/conference_recording_metadata.rb' +require_relative 'voice/models/transcribe_recording_request.rb' require_relative 'voice/models/transcription_response.rb' +require_relative 'voice/models/transcription_metadata.rb' +require_relative 'voice/models/transcript.rb' require_relative 'voice/models/answer_fallback_method_enum.rb' require_relative 'voice/models/answer_method_enum.rb' require_relative 'voice/models/callback_method_enum.rb' require_relative 'voice/models/conference_event_method_enum.rb' require_relative 'voice/models/direction_enum.rb' -require_relative 'voice/models/disconnect_cause_enum.rb' require_relative 'voice/models/disconnect_method_enum.rb' require_relative 'voice/models/file_format_enum.rb' require_relative 'voice/models/redirect_fallback_method_enum.rb' require_relative 'voice/models/redirect_method_enum.rb' require_relative 'voice/models/state_enum.rb' require_relative 'voice/models/state1_enum.rb' -require_relative 'voice/models/state2_enum.rb' require_relative 'voice/models/status_enum.rb' -require_relative 'voice/models/status1_enum.rb' -require_relative 'voice/models/status3_enum.rb' # Exceptions -require_relative 'voice/exceptions/api_error_response_exception.rb' +require_relative 'voice/exceptions/api_error_exception.rb' # Controllers require_relative 'voice/controllers/base_controller.rb' require_relative 'voice/controllers/api_controller.rb' diff --git a/lib/bandwidth/voice_lib/voice/client.rb b/lib/bandwidth/voice_lib/voice/client.rb index 8e1c9b8e..a4324203 100644 --- a/lib/bandwidth/voice_lib/voice/client.rb +++ b/lib/bandwidth/voice_lib/voice/client.rb @@ -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', @@ -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, diff --git a/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb b/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb index c1dcc16c..374bb834 100644 --- a/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +++ b/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb @@ -11,12 +11,12 @@ def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end - # Creates an outbound call + # Creates an outbound call. # @param [String] account_id Required parameter: Example: - # @param [ApiCreateCallRequest] body Optional parameter: Example: - # @return [ApiCallResponse] response from the API call + # @param [CreateCallRequest] body Required parameter: Example: + # @return [CreateCallResponse] response from the API call def create_call(account_id, - body: nil) + body) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls' @@ -43,7 +43,7 @@ def create_call(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -55,29 +55,29 @@ def create_call(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -87,16 +87,16 @@ def create_call(account_id, # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( - _response, data: ApiCallResponse.from_hash(decoded) + _response, data: CreateCallResponse.from_hash(decoded) ) end - # Returns near-realtime metadata about the specified call + # Returns near-realtime metadata about the specified call. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: - # @return [ApiCallStateResponse] response from the API call - def get_call_state(account_id, - call_id) + # @return [CallState] response from the API call + def get_call(account_id, + call_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}' @@ -122,7 +122,7 @@ def get_call_state(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -134,29 +134,29 @@ def get_call_state(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -166,18 +166,18 @@ def get_call_state(account_id, # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( - _response, data: ApiCallStateResponse.from_hash(decoded) + _response, data: CallState.from_hash(decoded) ) end - # Interrupts and replaces an active call's BXML document + # Interrupts and replaces an active call's BXML document. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: - # @param [ApiModifyCallRequest] body Optional parameter: Example: + # @param [ModifyCallRequest] body Required parameter: Example: # @return [void] response from the API call def modify_call(account_id, call_id, - body: nil) + body) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}' @@ -204,7 +204,7 @@ def modify_call(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -216,29 +216,29 @@ def modify_call(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -249,14 +249,14 @@ def modify_call(account_id, ApiResponse.new(_response) end - # Pauses or resumes a recording + # Pauses or resumes a recording. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: - # @param [ModifyCallRecordingState] body Optional parameter: Example: + # @param [ModifyCallRecordingRequest] body Required parameter: Example: # @return [void] response from the API call def modify_call_recording_state(account_id, call_id, - body: nil) + body) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recording' @@ -283,7 +283,7 @@ def modify_call_recording_state(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -295,29 +295,29 @@ def modify_call_recording_state(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -332,9 +332,9 @@ def modify_call_recording_state(account_id, # took place during the specified call # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: - # @return [List of RecordingMetadataResponse] response from the API call - def get_query_metadata_for_account_and_call(account_id, - call_id) + # @return [List of CallRecordingMetadata] response from the API call + def get_call_recordings(account_id, + call_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings' @@ -360,7 +360,7 @@ def get_query_metadata_for_account_and_call(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -372,29 +372,29 @@ def get_query_metadata_for_account_and_call(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -405,18 +405,18 @@ def get_query_metadata_for_account_and_call(account_id, decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, - data: decoded.map { |element| RecordingMetadataResponse.from_hash(element) } + data: decoded.map { |element| CallRecordingMetadata.from_hash(element) } ) end - # Returns metadata for the specified recording + # Returns metadata for the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: - # @return [RecordingMetadataResponse] response from the API call - def get_metadata_for_recording(account_id, - call_id, - recording_id) + # @return [CallRecordingMetadata] response from the API call + def get_call_recording(account_id, + call_id, + recording_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}' @@ -443,7 +443,7 @@ def get_metadata_for_recording(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -455,29 +455,29 @@ def get_metadata_for_recording(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -487,11 +487,11 @@ def get_metadata_for_recording(account_id, # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( - _response, data: RecordingMetadataResponse.from_hash(decoded) + _response, data: CallRecordingMetadata.from_hash(decoded) ) end - # Deletes the specified recording + # Deletes the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: @@ -519,7 +519,7 @@ def delete_recording(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -531,29 +531,29 @@ def delete_recording(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -564,14 +564,14 @@ def delete_recording(account_id, ApiResponse.new(_response) end - # Downloads the specified recording + # Downloads the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: - # @return [Binary] response from the API call - def get_stream_recording_media(account_id, - call_id, - recording_id) + # @return [Mixed] response from the API call + def get_download_call_recording(account_id, + call_id, + recording_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media' @@ -583,16 +583,22 @@ def get_stream_recording_media(account_id, ) _query_url = APIHelper.clean_url _query_builder + # Prepare headers. + _headers = { + 'accept' => 'application/json' + } + # Prepare and execute HttpRequest. _request = config.http_client.get( - _query_url + _query_url, + headers: _headers ) VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request, binary: true) + _response = execute_request(_request) # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -604,29 +610,29 @@ def get_stream_recording_media(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -634,12 +640,15 @@ def get_stream_recording_media(account_id, validate_response(_response) # Return appropriate response type. + decoded = APIHelper.json_deserialize(_response.raw_body) unless + _response.raw_body.nil? || + _response.raw_body.to_s.strip.empty? ApiResponse.new( - _response, data: _response.raw_body + _response, data: decoded ) end - # Deletes the specified recording's media + # Deletes the specified recording's media. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: @@ -667,7 +676,7 @@ def delete_recording_media(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -679,29 +688,29 @@ def delete_recording_media(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -712,14 +721,14 @@ def delete_recording_media(account_id, ApiResponse.new(_response) end - # Downloads the specified transcription + # Downloads the specified transcription. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [TranscriptionResponse] response from the API call - def get_recording_transcription(account_id, - call_id, - recording_id) + def get_call_transcription(account_id, + call_id, + recording_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription' @@ -746,7 +755,7 @@ def get_recording_transcription(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -758,29 +767,29 @@ def get_recording_transcription(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -794,16 +803,16 @@ def get_recording_transcription(account_id, ) end - # Requests that the specified recording be transcribed + # Requests that the specified recording be transcribed. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: - # @param [ApiTranscribeRecordingRequest] body Optional parameter: Example: + # @param [TranscribeRecordingRequest] body Required parameter: Example: # @return [void] response from the API call - def create_transcribe_recording(account_id, - call_id, - recording_id, - body: nil) + def create_transcribe_call_recording(account_id, + call_id, + recording_id, + body) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription' @@ -831,7 +840,7 @@ def create_transcribe_recording(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -843,35 +852,35 @@ def create_transcribe_recording(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 410 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The media for this recording has been deleted, so we can\'t' \ ' transcribe it', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -882,14 +891,14 @@ def create_transcribe_recording(account_id, ApiResponse.new(_response) end - # Deletes the specified recording's transcription + # Deletes the specified recording's transcription. # @param [String] account_id Required parameter: Example: # @param [String] call_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: # @return [void] response from the API call - def delete_recording_transcription(account_id, - call_id, - recording_id) + def delete_call_transcription(account_id, + call_id, + recording_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription' @@ -910,7 +919,7 @@ def delete_recording_transcription(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -922,29 +931,29 @@ def delete_recording_transcription(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -955,20 +964,20 @@ def delete_recording_transcription(account_id, ApiResponse.new(_response) end - # Returns information about the conferences in the account + # Returns information about the conferences in the account. # @param [String] account_id Required parameter: Example: - # @param [Integer] page_size Optional parameter: Example:1000 - # @param [String] page_token Optional parameter: Example: # @param [String] name Optional parameter: Example: # @param [String] min_created_time Optional parameter: Example: # @param [String] max_created_time Optional parameter: Example: - # @return [List of ConferenceDetail] response from the API call - def get_conferences_by_account(account_id, - page_size: 1000, - page_token: nil, - name: nil, - min_created_time: nil, - max_created_time: nil) + # @param [Integer] page_size Optional parameter: Example:1000 + # @param [String] page_token Optional parameter: Example: + # @return [List of ConferenceState] response from the API call + def get_conferences(account_id, + name: nil, + min_created_time: nil, + max_created_time: nil, + page_size: 1000, + page_token: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences' @@ -978,11 +987,11 @@ def get_conferences_by_account(account_id, ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, - 'pageSize' => page_size, - 'pageToken' => page_token, 'name' => name, 'minCreatedTime' => min_created_time, - 'maxCreatedTime' => max_created_time + 'maxCreatedTime' => max_created_time, + 'pageSize' => page_size, + 'pageToken' => page_token ) _query_url = APIHelper.clean_url _query_builder @@ -1001,7 +1010,7 @@ def get_conferences_by_account(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1013,29 +1022,29 @@ def get_conferences_by_account(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1046,16 +1055,16 @@ def get_conferences_by_account(account_id, decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, - data: decoded.map { |element| ConferenceDetail.from_hash(element) } + data: decoded.map { |element| ConferenceState.from_hash(element) } ) end - # Returns information about the specified conference + # Returns information about the specified conference. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: - # @return [ConferenceDetail] response from the API call - def get_conference_by_id(account_id, - conference_id) + # @return [ConferenceState] response from the API call + def get_conference(account_id, + conference_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}' @@ -1081,7 +1090,7 @@ def get_conference_by_id(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1093,29 +1102,29 @@ def get_conference_by_id(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1125,18 +1134,18 @@ def get_conference_by_id(account_id, # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( - _response, data: ConferenceDetail.from_hash(decoded) + _response, data: ConferenceState.from_hash(decoded) ) end - # Modify the conference state + # Modify the conference state. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: - # @param [ApiModifyConferenceRequest] body Optional parameter: Example: + # @param [ModifyConferenceRequest] body Required parameter: Example: # @return [void] response from the API call def modify_conference(account_id, conference_id, - body: nil) + body) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}' @@ -1163,7 +1172,7 @@ def modify_conference(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1175,29 +1184,29 @@ def modify_conference(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1208,16 +1217,16 @@ def modify_conference(account_id, ApiResponse.new(_response) end - # Updates settings for a particular conference member + # Updates settings for a particular conference member. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [String] call_id Required parameter: Example: - # @param [ConferenceMemberDetail] body Optional parameter: Example: + # @param [ConferenceMemberState] body Required parameter: Example: # @return [void] response from the API call def modify_conference_member(account_id, conference_id, call_id, - body: nil) + body) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/members/{callId}' @@ -1245,7 +1254,7 @@ def modify_conference_member(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1257,29 +1266,29 @@ def modify_conference_member(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1290,11 +1299,11 @@ def modify_conference_member(account_id, ApiResponse.new(_response) end - # Returns information about the specified conference member + # Returns information about the specified conference member. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [String] member_id Required parameter: Example: - # @return [ConferenceMemberDetail] response from the API call + # @return [ConferenceMemberState] response from the API call def get_conference_member(account_id, conference_id, member_id) @@ -1324,7 +1333,7 @@ def get_conference_member(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1336,29 +1345,29 @@ def get_conference_member(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1368,7 +1377,7 @@ def get_conference_member(account_id, # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( - _response, data: ConferenceMemberDetail.from_hash(decoded) + _response, data: ConferenceMemberState.from_hash(decoded) ) end @@ -1376,9 +1385,9 @@ def get_conference_member(account_id, # took place during the specified conference # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: - # @return [List of ConferenceRecordingMetadataResponse] response from the API call - def get_query_metadata_for_account_and_conference(account_id, - conference_id) + # @return [List of ConferenceRecordingMetadata] response from the API call + def get_conference_recordings(account_id, + conference_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings' @@ -1404,7 +1413,7 @@ def get_query_metadata_for_account_and_conference(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1416,29 +1425,29 @@ def get_query_metadata_for_account_and_conference(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1449,18 +1458,18 @@ def get_query_metadata_for_account_and_conference(account_id, decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, - data: decoded.map { |element| ConferenceRecordingMetadataResponse.from_hash(element) } + data: decoded.map { |element| ConferenceRecordingMetadata.from_hash(element) } ) end - # Returns metadata for the specified recording + # Returns metadata for the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: - # @return [RecordingMetadataResponse] response from the API call - def get_metadata_for_conference_recording(account_id, - conference_id, - recording_id) + # @return [CallRecordingMetadata] response from the API call + def get_conference_recording(account_id, + conference_id, + recording_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}' @@ -1487,7 +1496,7 @@ def get_metadata_for_conference_recording(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1499,29 +1508,29 @@ def get_metadata_for_conference_recording(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1531,18 +1540,18 @@ def get_metadata_for_conference_recording(account_id, # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( - _response, data: RecordingMetadataResponse.from_hash(decoded) + _response, data: CallRecordingMetadata.from_hash(decoded) ) end - # Downloads the specified recording + # Downloads the specified recording. # @param [String] account_id Required parameter: Example: # @param [String] conference_id Required parameter: Example: # @param [String] recording_id Required parameter: Example: - # @return [Binary] response from the API call - def get_stream_conference_recording_media(account_id, - conference_id, - recording_id) + # @return [Mixed] response from the API call + def get_download_conference_recording(account_id, + conference_id, + recording_id) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media' @@ -1554,16 +1563,22 @@ def get_stream_conference_recording_media(account_id, ) _query_url = APIHelper.clean_url _query_builder + # Prepare headers. + _headers = { + 'accept' => 'application/json' + } + # Prepare and execute HttpRequest. _request = config.http_client.get( - _query_url + _query_url, + headers: _headers ) VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request, binary: true) + _response = execute_request(_request) # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1575,29 +1590,29 @@ def get_stream_conference_recording_media(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1605,8 +1620,11 @@ def get_stream_conference_recording_media(account_id, validate_response(_response) # Return appropriate response type. + decoded = APIHelper.json_deserialize(_response.raw_body) unless + _response.raw_body.nil? || + _response.raw_body.to_s.strip.empty? ApiResponse.new( - _response, data: _response.raw_body + _response, data: decoded ) end @@ -1619,12 +1637,12 @@ def get_stream_conference_recording_media(account_id, # @param [String] to Optional parameter: Example: # @param [String] min_start_time Optional parameter: Example: # @param [String] max_start_time Optional parameter: Example: - # @return [List of RecordingMetadataResponse] response from the API call - def get_query_metadata_for_account(account_id, - from: nil, - to: nil, - min_start_time: nil, - max_start_time: nil) + # @return [List of CallRecordingMetadata] response from the API call + def get_query_call_recordings(account_id, + from: nil, + to: nil, + min_start_time: nil, + max_start_time: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/recordings' @@ -1656,7 +1674,7 @@ def get_query_metadata_for_account(account_id, # Validate response against endpoint and global error codes. if _response.status_code == 400 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response @@ -1668,29 +1686,29 @@ def get_query_metadata_for_account(account_id, _response ) elsif _response.status_code == 403 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) elsif _response.status_code == 404 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) elsif _response.status_code == 415 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) elsif _response.status_code == 429 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) elsif _response.status_code == 500 - raise ApiErrorResponseException.new( + raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) @@ -1701,7 +1719,7 @@ def get_query_metadata_for_account(account_id, decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, - data: decoded.map { |element| RecordingMetadataResponse.from_hash(element) } + data: decoded.map { |element| CallRecordingMetadata.from_hash(element) } ) end end diff --git a/lib/bandwidth/voice_lib/voice/exceptions/api_error_response_exception.rb b/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb similarity index 89% rename from lib/bandwidth/voice_lib/voice/exceptions/api_error_response_exception.rb rename to lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb index 8d748724..17978bc5 100644 --- a/lib/bandwidth/voice_lib/voice/exceptions/api_error_response_exception.rb +++ b/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb @@ -4,8 +4,8 @@ # ( https://apimatic.io ). module Bandwidth - # ApiErrorResponse class. - class ApiErrorResponseException < APIException + # ApiError class. + class ApiErrorException < APIException # TODO: Write general description for this method # @return [String] attr_accessor :type diff --git a/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb b/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb deleted file mode 100644 index 81e1a430..00000000 --- a/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +++ /dev/null @@ -1,164 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'date' -module Bandwidth - # ApiCallStateResponse Model. - class ApiCallStateResponse < BaseModel - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :parent_call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :application_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :account_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :to - - # TODO: Write general description for this method - # @return [String] - attr_accessor :from - - # TODO: Write general description for this method - # @return [String] - attr_accessor :direction - - # TODO: Write general description for this method - # @return [StateEnum] - attr_accessor :state - - # TODO: Write general description for this method - # @return [DateTime] - attr_accessor :start_time - - # TODO: Write general description for this method - # @return [DateTime] - attr_accessor :answer_time - - # TODO: Write general description for this method - # @return [DateTime] - attr_accessor :end_time - - # TODO: Write general description for this method - # @return [DisconnectCauseEnum] - attr_accessor :disconnect_cause - - # TODO: Write general description for this method - # @return [String] - attr_accessor :error_message - - # TODO: Write general description for this method - # @return [String] - attr_accessor :error_id - - # TODO: Write general description for this method - # @return [DateTime] - attr_accessor :last_update - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['call_id'] = 'callId' - @_hash['parent_call_id'] = 'parentCallId' - @_hash['application_id'] = 'applicationId' - @_hash['account_id'] = 'accountId' - @_hash['to'] = 'to' - @_hash['from'] = 'from' - @_hash['direction'] = 'direction' - @_hash['state'] = 'state' - @_hash['start_time'] = 'startTime' - @_hash['answer_time'] = 'answerTime' - @_hash['end_time'] = 'endTime' - @_hash['disconnect_cause'] = 'disconnectCause' - @_hash['error_message'] = 'errorMessage' - @_hash['error_id'] = 'errorId' - @_hash['last_update'] = 'lastUpdate' - @_hash - end - - def initialize(call_id = nil, - parent_call_id = nil, - application_id = nil, - account_id = nil, - to = nil, - from = nil, - direction = nil, - state = nil, - start_time = nil, - answer_time = nil, - end_time = nil, - disconnect_cause = nil, - error_message = nil, - error_id = nil, - last_update = nil) - @call_id = call_id - @parent_call_id = parent_call_id - @application_id = application_id - @account_id = account_id - @to = to - @from = from - @direction = direction - @state = state - @start_time = start_time - @answer_time = answer_time - @end_time = end_time - @disconnect_cause = disconnect_cause - @error_message = error_message - @error_id = error_id - @last_update = last_update - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - call_id = hash['callId'] - parent_call_id = hash['parentCallId'] - application_id = hash['applicationId'] - account_id = hash['accountId'] - to = hash['to'] - from = hash['from'] - direction = hash['direction'] - state = hash['state'] - start_time = APIHelper.rfc3339(hash['startTime']) if hash['startTime'] - answer_time = APIHelper.rfc3339(hash['answerTime']) if - hash['answerTime'] - end_time = APIHelper.rfc3339(hash['endTime']) if hash['endTime'] - disconnect_cause = hash['disconnectCause'] - error_message = hash['errorMessage'] - error_id = hash['errorId'] - last_update = APIHelper.rfc3339(hash['lastUpdate']) if - hash['lastUpdate'] - - # Create object from extracted values. - ApiCallStateResponse.new(call_id, - parent_call_id, - application_id, - account_id, - to, - from, - direction, - state, - start_time, - answer_time, - end_time, - disconnect_cause, - error_message, - error_id, - last_update) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb b/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb similarity index 66% rename from lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb rename to lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb index f52aeeaa..aaa8a3c9 100644 --- a/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +++ b/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb @@ -5,8 +5,8 @@ require 'date' module Bandwidth - # RecordingMetadataResponse Model. - class RecordingMetadataResponse < BaseModel + # CallRecordingMetadata Model. + class CallRecordingMetadata < BaseModel # TODO: Write general description for this method # @return [String] attr_accessor :application_id @@ -67,16 +67,25 @@ class RecordingMetadataResponse < BaseModel # @return [FileFormatEnum] attr_accessor :file_format - # Format is ISO-8601 - # @return [Status1Enum] + # The current status of the recording. Current values are 'processing', + # 'partial', 'complete', 'deleted' and 'error'. Additional states may be + # added in the future, so your application must be tolerant of unknown + # values. + # @return [String] attr_accessor :status - # Format is ISO-8601 + # The current status of the recording. Current values are 'processing', + # 'partial', 'complete', 'deleted' and 'error'. Additional states may be + # added in the future, so your application must be tolerant of unknown + # values. # @return [String] attr_accessor :media_url - # Format is ISO-8601 - # @return [Transcription] + # The current status of the recording. Current values are 'processing', + # 'partial', 'complete', 'deleted' and 'error'. Additional states may be + # added in the future, so your application must be tolerant of unknown + # values. + # @return [TranscriptionMetadata] attr_accessor :transcription # A mapping from model property names to API property names. @@ -158,33 +167,43 @@ def self.from_hash(hash) duration = hash['duration'] direction = hash['direction'] channels = hash['channels'] - start_time = APIHelper.rfc3339(hash['startTime']) if hash['startTime'] - end_time = APIHelper.rfc3339(hash['endTime']) if hash['endTime'] + start_time = DateTimeHelper.from_rfc3339(hash['startTime']) if + hash['startTime'] + end_time = DateTimeHelper.from_rfc3339(hash['endTime']) if + hash['endTime'] file_format = hash['fileFormat'] status = hash['status'] media_url = hash['mediaUrl'] - transcription = Transcription.from_hash(hash['transcription']) if + transcription = TranscriptionMetadata.from_hash(hash['transcription']) if hash['transcription'] # Create object from extracted values. - RecordingMetadataResponse.new(application_id, - account_id, - call_id, - parent_call_id, - recording_id, - to, - from, - transfer_caller_id, - transfer_to, - duration, - direction, - channels, - start_time, - end_time, - file_format, - status, - media_url, - transcription) + CallRecordingMetadata.new(application_id, + account_id, + call_id, + parent_call_id, + recording_id, + to, + from, + transfer_caller_id, + transfer_to, + duration, + direction, + channels, + start_time, + end_time, + file_format, + status, + media_url, + transcription) + end + + def to_start_time + DateTimeHelper.to_rfc3339(start_time) + end + + def to_end_time + DateTimeHelper.to_rfc3339(end_time) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/call_state.rb b/lib/bandwidth/voice_lib/voice/models/call_state.rb new file mode 100644 index 00000000..e9909ba3 --- /dev/null +++ b/lib/bandwidth/voice_lib/voice/models/call_state.rb @@ -0,0 +1,232 @@ +# bandwidth +# +# This file was automatically generated by APIMATIC v2.0 +# ( https://apimatic.io ). + +require 'date' +module Bandwidth + # CallState Model. + class CallState < BaseModel + # TODO: Write general description for this method + # @return [String] + attr_accessor :call_id + + # TODO: Write general description for this method + # @return [String] + attr_accessor :parent_call_id + + # TODO: Write general description for this method + # @return [String] + attr_accessor :application_id + + # TODO: Write general description for this method + # @return [String] + attr_accessor :account_id + + # TODO: Write general description for this method + # @return [String] + attr_accessor :to + + # TODO: Write general description for this method + # @return [String] + attr_accessor :from + + # TODO: Write general description for this method + # @return [String] + attr_accessor :direction + + # The current state of the call. Current possible values are 'initiated', + # 'answered' and 'disconnected'. Additional states may be added in the + # future, so your application must be tolerant of unknown values. + # @return [String] + attr_accessor :state + + # The current state of the call. Current possible values are 'initiated', + # 'answered' and 'disconnected'. Additional states may be added in the + # future, so your application must be tolerant of unknown values. + # @return [String] + attr_accessor :identity + + # The current state of the call. Current possible values are 'initiated', + # 'answered' and 'disconnected'. Additional states may be added in the + # future, so your application must be tolerant of unknown values. + # @return [Hash] + attr_accessor :pai + + # The current state of the call. Current possible values are 'initiated', + # 'answered' and 'disconnected'. Additional states may be added in the + # future, so your application must be tolerant of unknown values. + # @return [DateTime] + attr_accessor :start_time + + # The current state of the call. Current possible values are 'initiated', + # 'answered' and 'disconnected'. Additional states may be added in the + # future, so your application must be tolerant of unknown values. + # @return [DateTime] + attr_accessor :answer_time + + # The current state of the call. Current possible values are 'initiated', + # 'answered' and 'disconnected'. Additional states may be added in the + # future, so your application must be tolerant of unknown values. + # @return [DateTime] + attr_accessor :end_time + + # The reason the call was disconnected, or null if the call is still active. + # Current values are 'cancel', 'timeout', 'busy', 'rejected', 'hangup', + # 'invalid-bxml', 'callback-error', 'application-error', 'error', + # 'account-limit', 'node-capacity-exceeded' and 'unknown'. Additional causes + # may be added in the future, so your application must be tolerant of + # unknown values. + # @return [String] + attr_accessor :disconnect_cause + + # The reason the call was disconnected, or null if the call is still active. + # Current values are 'cancel', 'timeout', 'busy', 'rejected', 'hangup', + # 'invalid-bxml', 'callback-error', 'application-error', 'error', + # 'account-limit', 'node-capacity-exceeded' and 'unknown'. Additional causes + # may be added in the future, so your application must be tolerant of + # unknown values. + # @return [String] + attr_accessor :error_message + + # The reason the call was disconnected, or null if the call is still active. + # Current values are 'cancel', 'timeout', 'busy', 'rejected', 'hangup', + # 'invalid-bxml', 'callback-error', 'application-error', 'error', + # 'account-limit', 'node-capacity-exceeded' and 'unknown'. Additional causes + # may be added in the future, so your application must be tolerant of + # unknown values. + # @return [String] + attr_accessor :error_id + + # The reason the call was disconnected, or null if the call is still active. + # Current values are 'cancel', 'timeout', 'busy', 'rejected', 'hangup', + # 'invalid-bxml', 'callback-error', 'application-error', 'error', + # 'account-limit', 'node-capacity-exceeded' and 'unknown'. Additional causes + # may be added in the future, so your application must be tolerant of + # unknown values. + # @return [DateTime] + attr_accessor :last_update + + # A mapping from model property names to API property names. + def self.names + @_hash = {} if @_hash.nil? + @_hash['call_id'] = 'callId' + @_hash['parent_call_id'] = 'parentCallId' + @_hash['application_id'] = 'applicationId' + @_hash['account_id'] = 'accountId' + @_hash['to'] = 'to' + @_hash['from'] = 'from' + @_hash['direction'] = 'direction' + @_hash['state'] = 'state' + @_hash['identity'] = 'identity' + @_hash['pai'] = 'pai' + @_hash['start_time'] = 'startTime' + @_hash['answer_time'] = 'answerTime' + @_hash['end_time'] = 'endTime' + @_hash['disconnect_cause'] = 'disconnectCause' + @_hash['error_message'] = 'errorMessage' + @_hash['error_id'] = 'errorId' + @_hash['last_update'] = 'lastUpdate' + @_hash + end + + def initialize(call_id = nil, + parent_call_id = nil, + application_id = nil, + account_id = nil, + to = nil, + from = nil, + direction = nil, + state = nil, + identity = nil, + pai = nil, + start_time = nil, + answer_time = nil, + end_time = nil, + disconnect_cause = nil, + error_message = nil, + error_id = nil, + last_update = nil) + @call_id = call_id + @parent_call_id = parent_call_id + @application_id = application_id + @account_id = account_id + @to = to + @from = from + @direction = direction + @state = state + @identity = identity + @pai = pai + @start_time = start_time + @answer_time = answer_time + @end_time = end_time + @disconnect_cause = disconnect_cause + @error_message = error_message + @error_id = error_id + @last_update = last_update + end + + # Creates an instance of the object from a hash. + def self.from_hash(hash) + return nil unless hash + + # Extract variables from the hash. + call_id = hash['callId'] + parent_call_id = hash['parentCallId'] + application_id = hash['applicationId'] + account_id = hash['accountId'] + to = hash['to'] + from = hash['from'] + direction = hash['direction'] + state = hash['state'] + identity = hash['identity'] + pai = hash['pai'] + start_time = DateTimeHelper.from_rfc3339(hash['startTime']) if + hash['startTime'] + answer_time = DateTimeHelper.from_rfc3339(hash['answerTime']) if + hash['answerTime'] + end_time = DateTimeHelper.from_rfc3339(hash['endTime']) if + hash['endTime'] + disconnect_cause = hash['disconnectCause'] + error_message = hash['errorMessage'] + error_id = hash['errorId'] + last_update = DateTimeHelper.from_rfc3339(hash['lastUpdate']) if + hash['lastUpdate'] + + # Create object from extracted values. + CallState.new(call_id, + parent_call_id, + application_id, + account_id, + to, + from, + direction, + state, + identity, + pai, + start_time, + answer_time, + end_time, + disconnect_cause, + error_message, + error_id, + last_update) + end + + def to_start_time + DateTimeHelper.to_rfc3339(start_time) + end + + def to_answer_time + DateTimeHelper.to_rfc3339(answer_time) + end + + def to_end_time + DateTimeHelper.to_rfc3339(end_time) + end + + def to_last_update + DateTimeHelper.to_rfc3339(last_update) + end + end +end diff --git a/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb index 1034c123..f20ffa77 100644 --- a/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +++ b/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb @@ -7,29 +7,11 @@ module Bandwidth # CallbackMethod. class CallbackMethodEnum CALLBACK_METHOD_ENUM = [ - # TODO: Write general description for GET - GET = 'GET'.freeze, - - # TODO: Write general description for HEAD - HEAD = 'HEAD'.freeze, - # TODO: Write general description for POST POST = 'POST'.freeze, - # TODO: Write general description for PUT - PUT = 'PUT'.freeze, - - # TODO: Write general description for PATCH - PATCH = 'PATCH'.freeze, - - # TODO: Write general description for DELETE - DELETE = 'DELETE'.freeze, - - # TODO: Write general description for OPTIONS - OPTIONS = 'OPTIONS'.freeze, - - # TODO: Write general description for TRACE - TRACE = 'TRACE'.freeze + # TODO: Write general description for GET + GET = 'GET'.freeze ].freeze end end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb index 18488084..5d1cdc6e 100644 --- a/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +++ b/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb @@ -7,29 +7,11 @@ module Bandwidth # ConferenceEventMethod. class ConferenceEventMethodEnum CONFERENCE_EVENT_METHOD_ENUM = [ - # TODO: Write general description for GET - GET = 'GET'.freeze, - - # TODO: Write general description for HEAD - HEAD = 'HEAD'.freeze, - # TODO: Write general description for POST POST = 'POST'.freeze, - # TODO: Write general description for PUT - PUT = 'PUT'.freeze, - - # TODO: Write general description for PATCH - PATCH = 'PATCH'.freeze, - - # TODO: Write general description for DELETE - DELETE = 'DELETE'.freeze, - - # TODO: Write general description for OPTIONS - OPTIONS = 'OPTIONS'.freeze, - - # TODO: Write general description for TRACE - TRACE = 'TRACE'.freeze + # TODO: Write general description for GET + GET = 'GET'.freeze ].freeze end end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb b/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb similarity index 82% rename from lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb rename to lib/bandwidth/voice_lib/voice/models/conference_member_state.rb index 0c787555..efbd70f6 100644 --- a/lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb +++ b/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb @@ -4,8 +4,8 @@ # ( https://apimatic.io ). module Bandwidth - # ConferenceMemberDetail Model. - class ConferenceMemberDetail < BaseModel + # ConferenceMemberState Model. + class ConferenceMemberState < BaseModel # TODO: Write general description for this method # @return [String] attr_accessor :call_id @@ -69,12 +69,12 @@ def self.from_hash(hash) call_ids_to_coach = hash['callIdsToCoach'] # Create object from extracted values. - ConferenceMemberDetail.new(call_id, - conference_id, - member_url, - mute, - hold, - call_ids_to_coach) + ConferenceMemberState.new(call_id, + conference_id, + member_url, + mute, + hold, + call_ids_to_coach) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb b/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb similarity index 63% rename from lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb rename to lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb index 57d57a5c..cf58ac30 100644 --- a/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb +++ b/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb @@ -5,8 +5,8 @@ require 'date' module Bandwidth - # ConferenceRecordingMetadataResponse Model. - class ConferenceRecordingMetadataResponse < BaseModel + # ConferenceRecordingMetadata Model. + class ConferenceRecordingMetadata < BaseModel # TODO: Write general description for this method # @return [String] attr_accessor :account_id @@ -43,11 +43,17 @@ class ConferenceRecordingMetadataResponse < BaseModel # @return [FileFormatEnum] attr_accessor :file_format - # Format is ISO-8601 - # @return [Status1Enum] + # The current status of the recording. Current possible values are + # 'processing', 'partial', 'complete', 'deleted', and 'error'. Additional + # states may be added in the future, so your application must be tolerant of + # unknown values. + # @return [String] attr_accessor :status - # Format is ISO-8601 + # The current status of the recording. Current possible values are + # 'processing', 'partial', 'complete', 'deleted', and 'error'. Additional + # states may be added in the future, so your application must be tolerant of + # unknown values. # @return [String] attr_accessor :media_url @@ -103,24 +109,34 @@ def self.from_hash(hash) recording_id = hash['recordingId'] duration = hash['duration'] channels = hash['channels'] - start_time = APIHelper.rfc3339(hash['startTime']) if hash['startTime'] - end_time = APIHelper.rfc3339(hash['endTime']) if hash['endTime'] + start_time = DateTimeHelper.from_rfc3339(hash['startTime']) if + hash['startTime'] + end_time = DateTimeHelper.from_rfc3339(hash['endTime']) if + hash['endTime'] file_format = hash['fileFormat'] status = hash['status'] media_url = hash['mediaUrl'] # Create object from extracted values. - ConferenceRecordingMetadataResponse.new(account_id, - conference_id, - name, - recording_id, - duration, - channels, - start_time, - end_time, - file_format, - status, - media_url) + ConferenceRecordingMetadata.new(account_id, + conference_id, + name, + recording_id, + duration, + channels, + start_time, + end_time, + file_format, + status, + media_url) + end + + def to_start_time + DateTimeHelper.to_rfc3339(start_time) + end + + def to_end_time + DateTimeHelper.to_rfc3339(end_time) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_detail.rb b/lib/bandwidth/voice_lib/voice/models/conference_state.rb similarity index 74% rename from lib/bandwidth/voice_lib/voice/models/conference_detail.rb rename to lib/bandwidth/voice_lib/voice/models/conference_state.rb index f7518cf1..945548b3 100644 --- a/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +++ b/lib/bandwidth/voice_lib/voice/models/conference_state.rb @@ -5,8 +5,8 @@ require 'date' module Bandwidth - # ConferenceDetail Model. - class ConferenceDetail < BaseModel + # ConferenceState Model. + class ConferenceState < BaseModel # TODO: Write general description for this method # @return [String] attr_accessor :id @@ -36,7 +36,7 @@ class ConferenceDetail < BaseModel attr_accessor :tag # TODO: Write general description for this method - # @return [List of ConferenceMemberDetail] + # @return [List of ConferenceMemberState] attr_accessor :active_members # A mapping from model property names to API property names. @@ -78,9 +78,9 @@ def self.from_hash(hash) # Extract variables from the hash. id = hash['id'] name = hash['name'] - created_time = APIHelper.rfc3339(hash['createdTime']) if + created_time = DateTimeHelper.from_rfc3339(hash['createdTime']) if hash['createdTime'] - completed_time = APIHelper.rfc3339(hash['completedTime']) if + completed_time = DateTimeHelper.from_rfc3339(hash['completedTime']) if hash['completedTime'] conference_event_url = hash['conferenceEventUrl'] conference_event_method = hash['conferenceEventMethod'] @@ -90,19 +90,27 @@ def self.from_hash(hash) unless hash['activeMembers'].nil? active_members = [] hash['activeMembers'].each do |structure| - active_members << (ConferenceMemberDetail.from_hash(structure) if structure) + active_members << (ConferenceMemberState.from_hash(structure) if structure) end end # Create object from extracted values. - ConferenceDetail.new(id, - name, - created_time, - completed_time, - conference_event_url, - conference_event_method, - tag, - active_members) + ConferenceState.new(id, + name, + created_time, + completed_time, + conference_event_url, + conference_event_method, + tag, + active_members) + end + + def to_created_time + DateTimeHelper.to_rfc3339(created_time) + end + + def to_completed_time + DateTimeHelper.to_rfc3339(completed_time) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb b/lib/bandwidth/voice_lib/voice/models/create_call_request.rb similarity index 68% rename from lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb rename to lib/bandwidth/voice_lib/voice/models/create_call_request.rb index 27029885..9640d07f 100644 --- a/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +++ b/lib/bandwidth/voice_lib/voice/models/create_call_request.rb @@ -4,8 +4,8 @@ # ( https://apimatic.io ). module Bandwidth - # ApiCreateCallRequest Model. - class ApiCreateCallRequest < BaseModel + # CreateCallRequest Model. + class CreateCallRequest < BaseModel # Format is E164 # @return [String] attr_accessor :from @@ -15,124 +15,110 @@ class ApiCreateCallRequest < BaseModel attr_accessor :to # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :uui # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [Float] attr_accessor :call_timeout # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [Float] attr_accessor :callback_timeout # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :answer_url # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :answer_fallback_url # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :username # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :password # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :fallback_username # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :fallback_password # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [AnswerMethodEnum] attr_accessor :answer_method # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [AnswerFallbackMethodEnum] attr_accessor :answer_fallback_method # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :disconnect_url # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [DisconnectMethodEnum] attr_accessor :disconnect_method # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :tag # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as + # within the initial INVITE. It must end with an 'encoding' parameter as # described in https://tools.ietf.org/html/rfc7433. This header cannot # exceed 256 characters, including the encoding parameter. # @return [String] attr_accessor :application_id - # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as - # described in https://tools.ietf.org/html/rfc7433. This header cannot - # exceed 256 characters, including the encoding parameter. - # @return [String] - attr_accessor :obfuscated_to - - # When calling a SIP URI, this will be sent as the 'User-To-User' header - # within the initial INVITE. An 'encoding' parameter must be specified as - # described in https://tools.ietf.org/html/rfc7433. This header cannot - # exceed 256 characters, including the encoding parameter. - # @return [String] - attr_accessor :obfuscated_from - # A mapping from model property names to API property names. def self.names @_hash = {} if @_hash.nil? @@ -153,8 +139,6 @@ def self.names @_hash['disconnect_method'] = 'disconnectMethod' @_hash['tag'] = 'tag' @_hash['application_id'] = 'applicationId' - @_hash['obfuscated_to'] = 'obfuscatedTo' - @_hash['obfuscated_from'] = 'obfuscatedFrom' @_hash end @@ -174,9 +158,7 @@ def initialize(from = nil, answer_fallback_method = nil, disconnect_url = nil, disconnect_method = nil, - tag = nil, - obfuscated_to = nil, - obfuscated_from = nil) + tag = nil) @from = from @to = to @uui = uui @@ -194,8 +176,6 @@ def initialize(from = nil, @disconnect_method = disconnect_method @tag = tag @application_id = application_id - @obfuscated_to = obfuscated_to - @obfuscated_from = obfuscated_from end # Creates an instance of the object from a hash. @@ -220,29 +200,25 @@ def self.from_hash(hash) disconnect_url = hash['disconnectUrl'] disconnect_method = hash['disconnectMethod'] tag = hash['tag'] - obfuscated_to = hash['obfuscatedTo'] - obfuscated_from = hash['obfuscatedFrom'] # Create object from extracted values. - ApiCreateCallRequest.new(from, - to, - answer_url, - application_id, - uui, - call_timeout, - callback_timeout, - answer_fallback_url, - username, - password, - fallback_username, - fallback_password, - answer_method, - answer_fallback_method, - disconnect_url, - disconnect_method, - tag, - obfuscated_to, - obfuscated_from) + CreateCallRequest.new(from, + to, + answer_url, + application_id, + uui, + call_timeout, + callback_timeout, + answer_fallback_url, + username, + password, + fallback_username, + fallback_password, + answer_method, + answer_fallback_method, + disconnect_url, + disconnect_method, + tag) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/api_call_response.rb b/lib/bandwidth/voice_lib/voice/models/create_call_response.rb similarity index 81% rename from lib/bandwidth/voice_lib/voice/models/api_call_response.rb rename to lib/bandwidth/voice_lib/voice/models/create_call_response.rb index d68bd6f1..45913265 100644 --- a/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +++ b/lib/bandwidth/voice_lib/voice/models/create_call_response.rb @@ -5,8 +5,8 @@ require 'date' module Bandwidth - # ApiCallResponse Model. - class ApiCallResponse < BaseModel + # CreateCallResponse Model. + class CreateCallResponse < BaseModel # TODO: Write general description for this method # @return [String] attr_accessor :account_id @@ -169,7 +169,8 @@ def self.from_hash(hash) answer_url = hash['answerUrl'] answer_method = hash['answerMethod'] disconnect_method = hash['disconnectMethod'] - start_time = APIHelper.rfc3339(hash['startTime']) if hash['startTime'] + start_time = DateTimeHelper.from_rfc3339(hash['startTime']) if + hash['startTime'] call_timeout = hash['callTimeout'] callback_timeout = hash['callbackTimeout'] answer_fallback_url = hash['answerFallbackUrl'] @@ -182,26 +183,30 @@ def self.from_hash(hash) tag = hash['tag'] # Create object from extracted values. - ApiCallResponse.new(account_id, - call_id, - application_id, - to, - from, - call_url, - answer_url, - answer_method, - disconnect_method, - start_time, - call_timeout, - callback_timeout, - answer_fallback_url, - answer_fallback_method, - disconnect_url, - username, - password, - fallback_username, - fallback_password, - tag) + CreateCallResponse.new(account_id, + call_id, + application_id, + to, + from, + call_url, + answer_url, + answer_method, + disconnect_method, + start_time, + call_timeout, + callback_timeout, + answer_fallback_url, + answer_fallback_method, + disconnect_url, + username, + password, + fallback_username, + fallback_password, + tag) + end + + def to_start_time + DateTimeHelper.to_rfc3339(start_time) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb b/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb deleted file mode 100644 index be54ff5a..00000000 --- a/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +++ /dev/null @@ -1,47 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # DisconnectCause. - class DisconnectCauseEnum - DISCONNECT_CAUSE_ENUM = [ - # TODO: Write general description for BUSY - BUSY = 'busy'.freeze, - - # TODO: Write general description for CALLBACKERROR - CALLBACKERROR = 'callback-error'.freeze, - - # TODO: Write general description for CANCEL - CANCEL = 'cancel'.freeze, - - # TODO: Write general description for ERROR - ERROR = 'error'.freeze, - - # TODO: Write general description for HANGUP - HANGUP = 'hangup'.freeze, - - # TODO: Write general description for INVALIDBXML - INVALIDBXML = 'invalid-bxml'.freeze, - - # TODO: Write general description for REJECTED - REJECTED = 'rejected'.freeze, - - # TODO: Write general description for TIMEOUT - TIMEOUT = 'timeout'.freeze, - - # TODO: Write general description for ACCOUNTLIMIT - ACCOUNTLIMIT = 'account-limit'.freeze, - - # TODO: Write general description for NODECAPACITYEXCEEDED - NODECAPACITYEXCEEDED = 'node-capacity-exceeded'.freeze, - - # TODO: Write general description for UNKNOWN - UNKNOWN = 'unknown'.freeze, - - # TODO: Write general description for APPLICATIONERROR - APPLICATIONERROR = 'application-error'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb b/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb similarity index 77% rename from lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb rename to lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb index 2da5f870..022c04fd 100644 --- a/lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb +++ b/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb @@ -4,10 +4,10 @@ # ( https://apimatic.io ). module Bandwidth - # ModifyCallRecordingState Model. - class ModifyCallRecordingState < BaseModel + # ModifyCallRecordingRequest Model. + class ModifyCallRecordingRequest < BaseModel # TODO: Write general description for this method - # @return [State2Enum] + # @return [State1Enum] attr_accessor :state # A mapping from model property names to API property names. @@ -29,7 +29,7 @@ def self.from_hash(hash) state = hash['state'] # Create object from extracted values. - ModifyCallRecordingState.new(state) + ModifyCallRecordingRequest.new(state) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb b/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb similarity index 68% rename from lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb rename to lib/bandwidth/voice_lib/voice/models/modify_call_request.rb index 27c32c3c..af6280b3 100644 --- a/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +++ b/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb @@ -4,45 +4,45 @@ # ( https://apimatic.io ). module Bandwidth - # ApiModifyCallRequest Model. - class ApiModifyCallRequest < BaseModel + # ModifyCallRequest Model. + class ModifyCallRequest < BaseModel # TODO: Write general description for this method - # @return [State1Enum] + # @return [StateEnum] attr_accessor :state - # TODO: Write general description for this method + # Required if state is 'active' # @return [String] attr_accessor :redirect_url - # TODO: Write general description for this method + # Required if state is 'active' # @return [String] attr_accessor :redirect_fallback_url - # TODO: Write general description for this method + # Required if state is 'active' # @return [RedirectMethodEnum] attr_accessor :redirect_method - # TODO: Write general description for this method + # Required if state is 'active' # @return [RedirectFallbackMethodEnum] attr_accessor :redirect_fallback_method - # TODO: Write general description for this method + # Required if state is 'active' # @return [String] attr_accessor :username - # TODO: Write general description for this method + # Required if state is 'active' # @return [String] attr_accessor :password - # TODO: Write general description for this method + # Required if state is 'active' # @return [String] attr_accessor :fallback_username - # TODO: Write general description for this method + # Required if state is 'active' # @return [String] attr_accessor :fallback_password - # TODO: Write general description for this method + # Required if state is 'active' # @return [String] attr_accessor :tag @@ -62,8 +62,8 @@ def self.names @_hash end - def initialize(redirect_url = nil, - state = nil, + def initialize(state = StateEnum::ACTIVE, + redirect_url = nil, redirect_fallback_url = nil, redirect_method = nil, redirect_fallback_method = nil, @@ -89,8 +89,8 @@ def self.from_hash(hash) return nil unless hash # Extract variables from the hash. + state = hash['state'] ||= StateEnum::ACTIVE redirect_url = hash['redirectUrl'] - state = hash['state'] redirect_fallback_url = hash['redirectFallbackUrl'] redirect_method = hash['redirectMethod'] redirect_fallback_method = hash['redirectFallbackMethod'] @@ -101,16 +101,16 @@ def self.from_hash(hash) tag = hash['tag'] # Create object from extracted values. - ApiModifyCallRequest.new(redirect_url, - state, - redirect_fallback_url, - redirect_method, - redirect_fallback_method, - username, - password, - fallback_username, - fallback_password, - tag) + ModifyCallRequest.new(state, + redirect_url, + redirect_fallback_url, + redirect_method, + redirect_fallback_method, + username, + password, + fallback_username, + fallback_password, + tag) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb b/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb similarity index 82% rename from lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb rename to lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb index 2d66903e..5a0160a0 100644 --- a/lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb +++ b/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb @@ -4,8 +4,8 @@ # ( https://apimatic.io ). module Bandwidth - # ApiModifyConferenceRequest Model. - class ApiModifyConferenceRequest < BaseModel + # ModifyConferenceRequest Model. + class ModifyConferenceRequest < BaseModel # TODO: Write general description for this method # @return [StatusEnum] attr_accessor :status @@ -93,15 +93,15 @@ def self.from_hash(hash) fallback_password = hash['fallbackPassword'] # Create object from extracted values. - ApiModifyConferenceRequest.new(status, - redirect_url, - redirect_fallback_url, - redirect_method, - redirect_fallback_method, - username, - password, - fallback_username, - fallback_password) + ModifyConferenceRequest.new(status, + redirect_url, + redirect_fallback_url, + redirect_method, + redirect_fallback_method, + username, + password, + fallback_username, + fallback_password) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/state1_enum.rb b/lib/bandwidth/voice_lib/voice/models/state1_enum.rb index ff04b0cf..c23a7d00 100644 --- a/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +++ b/lib/bandwidth/voice_lib/voice/models/state1_enum.rb @@ -7,11 +7,14 @@ module Bandwidth # State1. class State1Enum STATE1_ENUM = [ - # TODO: Write general description for ACTIVE - ACTIVE = 'active'.freeze, + # TODO: Write general description for NOT_RECORDING + NOT_RECORDING = 'NOT_RECORDING'.freeze, - # TODO: Write general description for COMPLETED - COMPLETED = 'completed'.freeze + # TODO: Write general description for PAUSED + PAUSED = 'PAUSED'.freeze, + + # TODO: Write general description for RECORDING + RECORDING = 'RECORDING'.freeze ].freeze end end diff --git a/lib/bandwidth/voice_lib/voice/models/state2_enum.rb b/lib/bandwidth/voice_lib/voice/models/state2_enum.rb deleted file mode 100644 index 829d97d0..00000000 --- a/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +++ /dev/null @@ -1,20 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # State2. - class State2Enum - STATE2_ENUM = [ - # TODO: Write general description for NOT_RECORDING - NOT_RECORDING = 'NOT_RECORDING'.freeze, - - # TODO: Write general description for PAUSED - PAUSED = 'PAUSED'.freeze, - - # TODO: Write general description for RECORDING - RECORDING = 'RECORDING'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/state_enum.rb b/lib/bandwidth/voice_lib/voice/models/state_enum.rb index 7db1397b..da8ed33e 100644 --- a/lib/bandwidth/voice_lib/voice/models/state_enum.rb +++ b/lib/bandwidth/voice_lib/voice/models/state_enum.rb @@ -7,14 +7,11 @@ module Bandwidth # State. class StateEnum STATE_ENUM = [ - # TODO: Write general description for DISCONNECTED - DISCONNECTED = 'DISCONNECTED'.freeze, + # TODO: Write general description for ACTIVE + ACTIVE = 'active'.freeze, - # TODO: Write general description for ANSWERED - ANSWERED = 'ANSWERED'.freeze, - - # TODO: Write general description for INITIATED - INITIATED = 'INITIATED'.freeze + # TODO: Write general description for COMPLETED + COMPLETED = 'completed'.freeze ].freeze end end diff --git a/lib/bandwidth/voice_lib/voice/models/status1_enum.rb b/lib/bandwidth/voice_lib/voice/models/status1_enum.rb deleted file mode 100644 index ab6e12ca..00000000 --- a/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +++ /dev/null @@ -1,29 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Status1. - class Status1Enum - STATUS1_ENUM = [ - # TODO: Write general description for PROCESSING - PROCESSING = 'processing'.freeze, - - # TODO: Write general description for PARTIAL - PARTIAL = 'partial'.freeze, - - # TODO: Write general description for COMPLETE - COMPLETE = 'complete'.freeze, - - # TODO: Write general description for DELETED - DELETED = 'deleted'.freeze, - - # TODO: Write general description for ERROR - ERROR = 'error'.freeze, - - # TODO: Write general description for ALREADYINPROGRESS - ALREADYINPROGRESS = 'already-in-progress'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/status3_enum.rb b/lib/bandwidth/voice_lib/voice/models/status3_enum.rb deleted file mode 100644 index aaccb733..00000000 --- a/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +++ /dev/null @@ -1,32 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Status3. - class Status3Enum - STATUS3_ENUM = [ - # TODO: Write general description for NONE - NONE = 'none'.freeze, - - # TODO: Write general description for PROCESSING - PROCESSING = 'processing'.freeze, - - # TODO: Write general description for AVAILABLE - AVAILABLE = 'available'.freeze, - - # TODO: Write general description for ERROR - ERROR = 'error'.freeze, - - # TODO: Write general description for TIMEOUT - TIMEOUT = 'timeout'.freeze, - - # TODO: Write general description for FILESIZETOOBIG - FILESIZETOOBIG = 'file-size-too-big'.freeze, - - # TODO: Write general description for FILESIZETOOSMALL - FILESIZETOOSMALL = 'file-size-too-small'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb b/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb similarity index 80% rename from lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb rename to lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb index 2c74d16d..ee12c2a0 100644 --- a/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +++ b/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb @@ -4,8 +4,8 @@ # ( https://apimatic.io ). module Bandwidth - # ApiTranscribeRecordingRequest Model. - class ApiTranscribeRecordingRequest < BaseModel + # TranscribeRecordingRequest Model. + class TranscribeRecordingRequest < BaseModel # TODO: Write general description for this method # @return [String] attr_accessor :callback_url @@ -69,12 +69,12 @@ def self.from_hash(hash) callback_timeout = hash['callbackTimeout'] # Create object from extracted values. - ApiTranscribeRecordingRequest.new(callback_url, - callback_method, - username, - password, - tag, - callback_timeout) + TranscribeRecordingRequest.new(callback_url, + callback_method, + username, + password, + tag, + callback_timeout) end end end diff --git a/lib/bandwidth/voice_lib/voice/models/transcription.rb b/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb similarity index 50% rename from lib/bandwidth/voice_lib/voice/models/transcription.rb rename to lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb index 8774f174..d7b7d182 100644 --- a/lib/bandwidth/voice_lib/voice/models/transcription.rb +++ b/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb @@ -4,21 +4,30 @@ # ( https://apimatic.io ). module Bandwidth - # Transcription Model. - class Transcription < BaseModel + # TranscriptionMetadata Model. + class TranscriptionMetadata < BaseModel # TODO: Write general description for this method # @return [String] attr_accessor :id - # TODO: Write general description for this method - # @return [Status3Enum] + # The current status of the transcription. Current values are 'none', + # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and + # 'file-size-too-small'. Additional states may be added in the future, so + # your application must be tolerant of unknown values. + # @return [String] attr_accessor :status - # TODO: Write general description for this method + # The current status of the transcription. Current values are 'none', + # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and + # 'file-size-too-small'. Additional states may be added in the future, so + # your application must be tolerant of unknown values. # @return [String] attr_accessor :completed_time - # TODO: Write general description for this method + # The current status of the transcription. Current values are 'none', + # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and + # 'file-size-too-small'. Additional states may be added in the future, so + # your application must be tolerant of unknown values. # @return [String] attr_accessor :url @@ -53,10 +62,10 @@ def self.from_hash(hash) url = hash['url'] # Create object from extracted values. - Transcription.new(id, - status, - completed_time, - url) + TranscriptionMetadata.new(id, + status, + completed_time, + url) end end end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/client.rb b/lib/bandwidth/web_rtc_lib/web_rtc/client.rb index 74dea931..1549137e 100644 --- a/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +++ b/lib/bandwidth/web_rtc_lib/web_rtc/client.rb @@ -23,8 +23,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', @@ -43,8 +43,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, diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb b/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb index 6c081b33..163b6132 100644 --- a/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +++ b/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb @@ -498,20 +498,20 @@ def add_participant_to_session(account_id, # This will automatically remove any subscriptions the participant has # associated with this session # @param [String] account_id Required parameter: Account ID - # @param [String] participant_id Required parameter: Participant ID # @param [String] session_id Required parameter: Session ID + # @param [String] participant_id Required parameter: Participant ID # @return [void] response from the API call def remove_participant_from_session(account_id, - participant_id, - session_id) + session_id, + participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false } + 'sessionId' => { 'value' => session_id, 'encode' => false }, + 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder @@ -553,20 +553,20 @@ def remove_participant_from_session(account_id, # Get a participant's subscriptions # @param [String] account_id Required parameter: Account ID - # @param [String] participant_id Required parameter: Participant ID # @param [String] session_id Required parameter: Session ID + # @param [String] participant_id Required parameter: Participant ID # @return [Subscriptions] response from the API call def get_participant_subscriptions(account_id, - participant_id, - session_id) + session_id, + participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false } + 'sessionId' => { 'value' => session_id, 'encode' => false }, + 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder @@ -621,13 +621,13 @@ def get_participant_subscriptions(account_id, # subscriptions. Call this function with no `Subscriptions` object to remove # all subscriptions # @param [String] account_id Required parameter: Account ID - # @param [String] participant_id Required parameter: Participant ID # @param [String] session_id Required parameter: Session ID + # @param [String] participant_id Required parameter: Participant ID # @param [Subscriptions] body Optional parameter: Initial state # @return [void] response from the API call def update_participant_subscriptions(account_id, - participant_id, session_id, + participant_id, body: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) @@ -635,8 +635,8 @@ def update_participant_subscriptions(account_id, _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false } + 'sessionId' => { 'value' => session_id, 'encode' => false }, + 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder diff --git a/test/integration/test_integration.rb b/test/integration/test_integration.rb index 02621c15..5187f012 100644 --- a/test/integration/test_integration.rb +++ b/test/integration/test_integration.rb @@ -8,7 +8,7 @@ include Bandwidth include Bandwidth::Voice include Bandwidth::Messaging -include Bandwidth::TwoFactorAuth +include Bandwidth::MultiFactorAuth begin USERNAME = ENV.fetch("USERNAME") @@ -34,8 +34,8 @@ def setup voice_basic_auth_password: PASSWORD, messaging_basic_auth_user_name: USERNAME, messaging_basic_auth_password: PASSWORD, - two_factor_auth_basic_auth_user_name: USERNAME, - two_factor_auth_basic_auth_password: PASSWORD, + multi_factor_auth_basic_auth_user_name: USERNAME, + multi_factor_auth_basic_auth_password: PASSWORD, phone_number_lookup_basic_auth_user_name: USERNAME, phone_number_lookup_basic_auth_password: PASSWORD ) @@ -58,7 +58,7 @@ def test_create_message_invalid_phone_number body.from = PHONE_NUMBER_OUTBOUND body.text = "Ruby Integration" begin - @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, :body => body) + @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, body) #workaround to make sure that if the above error is not raised, the build will fail assert(false, "Expected exception not raised") rescue MessagingException => e @@ -72,7 +72,7 @@ def test_upload_download_media media_file = '12345' #todo: check a binary string #media upload - @bandwidth_client.messaging_client.client.upload_media(ACCOUNT_ID, media_file_name, media_file.length.to_s, media_file, :content_type => "application/octet-stream", :cache_control => "no-cache") + @bandwidth_client.messaging_client.client.upload_media(ACCOUNT_ID, media_file_name, media_file, :content_type => "application/octet-stream", :cache_control => "no-cache") #media download downloaded_media_file = @bandwidth_client.messaging_client.client.get_media(ACCOUNT_ID, media_file_name).data @@ -81,21 +81,21 @@ def test_upload_download_media end def test_create_call_and_get_call_state - body = ApiCreateCallRequest.new + body = CreateCallRequest.new body.from = PHONE_NUMBER_OUTBOUND body.to = PHONE_NUMBER_INBOUND body.application_id = VOICE_APPLICATION_ID body.answer_url = CALLBACK_URL - response = @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body) + response = @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, body) assert(response.data.call_id.length > 0, "call_id value not set") #Get phone call information - response = @bandwidth_client.voice_client.client.get_call_state(ACCOUNT_ID, response.data.call_id) + response = @bandwidth_client.voice_client.client.get_call(ACCOUNT_ID, response.data.call_id) assert(response.data.state.length > 0, "state value not set") end def test_create_call_invalid_phone_number - body = ApiCreateCallRequest.new + body = CreateCallRequest.new body.from = PHONE_NUMBER_OUTBOUND body.to = "+1invalid" body.application_id = VOICE_APPLICATION_ID @@ -105,7 +105,7 @@ def test_create_call_invalid_phone_number @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body) #workaround to make sure that if the above error is not raised, the build will fail assert(false, "Expected exception not raised") - rescue ApiErrorResponseException => e + rescue ApiErrorException => e assert(e.description.length > 0, "description value not set") end end @@ -473,7 +473,7 @@ def test_mfa_messaging body.digits = 6 body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" - response = @bandwidth_client.two_factor_auth_client.mfa.create_messaging_two_factor(ACCOUNT_ID, body) + response = @bandwidth_client.multi_factor_auth_client.mfa.create_messaging_two_factor(ACCOUNT_ID, body) assert(response.data.message_id.length > 0, "message id value not set") end @@ -486,7 +486,7 @@ def test_mfa_voice body.digits = 6 body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" - response = @bandwidth_client.two_factor_auth_client.mfa.create_voice_two_factor(ACCOUNT_ID, body) + response = @bandwidth_client.multi_factor_auth_client.mfa.create_voice_two_factor(ACCOUNT_ID, body) assert(response.data.call_id.length > 0, "call id value not set") end @@ -497,7 +497,7 @@ def test_mfa_verify body.scope = "scope" body.code = "123456" body.expiration_time_in_minutes = 3 - response = @bandwidth_client.two_factor_auth_client.mfa.create_verify_two_factor(ACCOUNT_ID, body) + response = @bandwidth_client.multi_factor_auth_client.mfa.create_verify_two_factor(ACCOUNT_ID, body) #Ruby has no check to see if variables are of type boolean #An explicit true/false check is required assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean")