Class: Mercadopago::RequestOptions
- Inherits:
-
Object
- Object
- Mercadopago::RequestOptions
- Defined in:
- lib/mercadopago/config/request_options.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#connection_timeout ⇒ Object
Returns the value of attribute connection_timeout.
-
#corporation_id ⇒ Object
Returns the value of attribute corporation_id.
-
#custom_headers ⇒ Object
Returns the value of attribute custom_headers.
-
#integrator_id ⇒ Object
Returns the value of attribute integrator_id.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#platform_id ⇒ Object
Returns the value of attribute platform_id.
Instance Method Summary collapse
- #get_headers ⇒ Object
-
#initialize(access_token: nil, connection_timeout: 60.0, custom_headers: nil, corporation_id: nil, integrator_id: nil, platform_id: nil, max_retries: 3) ⇒ RequestOptions
constructor
A new instance of RequestOptions.
Constructor Details
#initialize(access_token: nil, connection_timeout: 60.0, custom_headers: nil, corporation_id: nil, integrator_id: nil, platform_id: nil, max_retries: 3) ⇒ RequestOptions
Returns a new instance of RequestOptions.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/mercadopago/config/request_options.rb', line 6 def access_token @access_token end |
#connection_timeout ⇒ Object
Returns the value of attribute connection_timeout.
6 7 8 |
# File 'lib/mercadopago/config/request_options.rb', line 6 def connection_timeout @connection_timeout end |
#corporation_id ⇒ Object
Returns the value of attribute corporation_id.
6 7 8 |
# File 'lib/mercadopago/config/request_options.rb', line 6 def corporation_id @corporation_id end |
#custom_headers ⇒ Object
Returns the value of attribute custom_headers.
6 7 8 |
# File 'lib/mercadopago/config/request_options.rb', line 6 def custom_headers @custom_headers end |
#integrator_id ⇒ Object
Returns the value of attribute integrator_id.
6 7 8 |
# File 'lib/mercadopago/config/request_options.rb', line 6 def integrator_id @integrator_id end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
6 7 8 |
# File 'lib/mercadopago/config/request_options.rb', line 6 def max_retries @max_retries end |
#platform_id ⇒ Object
Returns the value of attribute platform_id.
6 7 8 |
# File 'lib/mercadopago/config/request_options.rb', line 6 def platform_id @platform_id end |
Instance Method Details
#get_headers ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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, 'x-idempotency-key' => SecureRandom.uuid, '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 |