Class: PaypalAPI::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/paypal-api/config.rb

Overview

Stores client requests configuration

Constant Summary collapse

DEFAULTS =

Default config options

{
  http_opts: {}.freeze,
  retries: {enabled: true, count: 4, sleep: [0, 0.25, 0.75, 1.5].freeze}.freeze
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_opts: nil, retries: {}, cache: nil) ⇒ Client

Initializes Config

Parameters:

  • http_opts (Hash) (defaults to: nil)

    Net::Http opts for all requests

  • retries (Hash) (defaults to: {})

    Retries configuration

  • cache (#read, nil) (defaults to: nil)

    Application cache to store certificates to validate webhook events locally. Must respond to #fetch(key, &block)



25
26
27
28
29
30
31
# File 'lib/paypal-api/config.rb', line 25

def initialize(http_opts: nil, retries: {}, cache: nil)
  @http_opts = http_opts || DEFAULTS[:http_opts]
  @retries = DEFAULTS[:retries].merge(retries || {})
  @certs_cache = WebhookVerifier::CertsCache.new(cache)

  freeze
end

Instance Attribute Details

#certs_cacheObject (readonly)

Returns the value of attribute certs_cache.



14
15
16
# File 'lib/paypal-api/config.rb', line 14

def certs_cache
  @certs_cache
end

#http_optsObject (readonly)

Returns the value of attribute http_opts.



14
15
16
# File 'lib/paypal-api/config.rb', line 14

def http_opts
  @http_opts
end

#retriesObject (readonly)

Returns the value of attribute retries.



14
15
16
# File 'lib/paypal-api/config.rb', line 14

def retries
  @retries
end