Class: MailchimpAPI::RequestExecutor Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mailchimp-api/request_executor.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 executing HTTP requests with retry logic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, http_opts: {}, retries: {}) ⇒ RequestExecutor

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 request executor

Parameters:

  • request (Request)

    The request to execute

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

    HTTP client configuration options

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

    Retry configuration options



20
21
22
23
24
# File 'lib/mailchimp-api/request_executor.rb', line 20

def initialize(request, http_opts: {}, retries: {})
  @request = request
  @http_opts = http_opts
  @retries = retries
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



11
12
13
# File 'lib/mailchimp-api/request_executor.rb', line 11

def http_opts
  @http_opts
end

#requestRequest (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 The request to be executed.

Returns:

  • (Request)

    The request to be executed



8
9
10
# File 'lib/mailchimp-api/request_executor.rb', line 8

def request
  @request
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



14
15
16
# File 'lib/mailchimp-api/request_executor.rb', line 14

def retries
  @retries
end

Instance Method Details

#callResponse

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.

Executes the request with retry logic

Returns:

  • (Response)

    The response from the API

Raises:



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

def call
  response = execute_request
  raise FailedRequestErrorBuilder.call(request: request, response: response) if response.failed?

  response
end