class Mercadopago::RequestOptions

Attributes

access_token[R]
connection_timeout[R]
corporation_id[R]
custom_headers[R]
integrator_id[R]
max_retries[R]
platform_id[R]

Public Class Methods

new(access_token: nil, connection_timeout: 60.0, custom_headers: nil, corporation_id: nil, integrator_id: nil, platform_id: nil, max_retries: 3) click to toggle source
# File lib/mercadopago/config/request_options.rb, line 9
def initialize(access_token: nil,
               connection_timeout: 60.0,
               custom_headers: nil,
               corporation_id: nil,
               integrator_id: nil,
               platform_id: nil,
               max_retries: 3)
  self.access_token = access_token
  self.connection_timeout = connection_timeout
  self.custom_headers = custom_headers
  self.corporation_id = corporation_id
  self.integrator_id = integrator_id
  self.platform_id = platform_id
  self.max_retries = max_retries

  @config = Config.new
end

Public Instance Methods

access_token=(value) click to toggle source
# File lib/mercadopago/config/request_options.rb, line 43
def access_token=(value)
  raise TypeError, 'Param access_token must be a String' unless access_token.nil? || value.is_a?(String)

  @access_token = value
end
connection_timeout=(value) click to toggle source
# File lib/mercadopago/config/request_options.rb, line 55
def connection_timeout=(value)
  raise TypeError, 'Param connection_timeout must be a Float' unless value.is_a?(Float)

  @connection_timeout = value
end
corporation_id=(value) click to toggle source
# File lib/mercadopago/config/request_options.rb, line 61
def corporation_id=(value)
  raise TypeError, 'Param corporation_id must be a String' unless value.nil? || value.is_a?(String)

  @corporation_id = value
end
custom_headers=(value) click to toggle source
# File lib/mercadopago/config/request_options.rb, line 49
def custom_headers=(value)
  raise TypeError, 'Param custom_headers must be a Hash' unless value.nil? || value.is_a?(Hash)

  @custom_headers = value
end
get_headers() click to toggle source
# File lib/mercadopago/config/request_options.rb, line 27
def get_headers
  headers = { 'Authorization': "Bearer #{@access_token}",
              'x-product-id' => @config.product_id,
              'x-tracking-id' => @config.tracking_id,
              'User-Agent' => @config.user_agent,
              'Accept': @config.mime_json }

  headers['x-corporation-id'] = @corporation_id unless @corporation_id.nil?
  headers['x-integrator-id'] = @integrator_id unless @integrator_id.nil?
  headers['x-platform-id'] = @platform_id unless @platform_id.nil?

  headers.merge(@custom_headers) unless @custom_headers.nil?

  headers
end
integrator_id=(value) click to toggle source
# File lib/mercadopago/config/request_options.rb, line 67
def integrator_id=(value)
  raise TypeError, 'Param integrator_id must be a String' unless value.nil? || value.is_a?(String)

  @integrator_id = value
end
max_retries=(value) click to toggle source
# File lib/mercadopago/config/request_options.rb, line 79
def max_retries=(value)
  raise TypeError, 'Param max_retries must be a Integer' unless value.is_a?(Integer)

  @max_retries = value
end
platform_id=(value) click to toggle source
# File lib/mercadopago/config/request_options.rb, line 73
def platform_id=(value)
  raise TypeError, 'Param platform_id must be a String' unless value.nil? || value.is_a?(String)

  @platform_id = value
end