lib/bandwidth-sdk/configuration.rb in bandwidth-sdk-12.1.0 vs lib/bandwidth-sdk/configuration.rb in bandwidth-sdk-13.0.0

- old
+ new

@@ -4,11 +4,11 @@ #Bandwidth's Communication APIs The version of the OpenAPI document: 1.0.0 Contact: letstalk@bandwidth.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 7.0.0 +Generator version: 7.7.0 =end module Bandwidth class Configuration @@ -77,10 +77,18 @@ # Default to false. # # @return [true, false] attr_accessor :debugging + # Set this to ignore operation servers for the API client. This is useful when you need to + # send requests to a different server than the one specified in the OpenAPI document. + # Will default to the base url defined in the spec but can be overridden by setting + # `scheme`, `host`, `base_path` directly. + # Default to false. + # @return [true, false] + attr_accessor :ignore_operation_servers + # Defines the logger used for debugging. # Default to `Rails.logger` (when in Rails) or logging to STDOUT. # # @return [#debug] attr_accessor :logger @@ -168,10 +176,11 @@ @timeout = 60 # return data as binary instead of file @return_binary_data = false @params_encoder = nil @debugging = false + @ignore_operation_servers = false @inject_format = false @force_ending_format = false @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) yield(self) if block_given? @@ -202,9 +211,10 @@ @base_path = '' if @base_path == '/' end # Returns base URL for specified operation based on server settings def base_url(operation = nil) + return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers if operation_server_settings.key?(operation) then index = server_operation_index.fetch(operation, server_index) server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation]) else server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)