Class: MailchimpAPI::Config Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Internal class for storing and managing client configuration

Constant Summary collapse

DEFAULTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Default configuration options

Returns:

  • (Hash)

    Frozen hash containing default settings

{
  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: {}) ⇒ Config

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new configuration instance

Examples:

config = MailchimpAPI::Config.new(
  http_opts: { read_timeout: 30 },
  retries: { count: 3 }
)

Parameters:

  • http_opts (Hash) (defaults to: nil)

    Net::Http options for all requests

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

    Retry configuration options



29
30
31
32
33
34
# File 'lib/mailchimp-api/config.rb', line 29

def initialize(http_opts: nil, retries: {})
  @http_opts = http_opts.dup.freeze || DEFAULTS[:http_opts]
  @retries = DEFAULTS[:retries].merge(retries || {}).freeze

  freeze
end

Instance Attribute Details

#http_optsHash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns HTTP client configuration options.

Returns:

  • (Hash)

    HTTP client configuration options



15
16
17
# File 'lib/mailchimp-api/config.rb', line 15

def http_opts
  @http_opts
end

#retriesHash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Retry configuration options.

Returns:

  • (Hash)

    Retry configuration options



18
19
20
# File 'lib/mailchimp-api/config.rb', line 18

def retries
  @retries
end