Class: MailchimpAPI::BatchRequest Private
- Inherits:
-
Object
- Object
- MailchimpAPI::BatchRequest
- Defined in:
- lib/mailchimp-api/batch_request.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 constructing batch operation requests
Constant Summary collapse
- API_VERSION_PREFIX =
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.
API version prefix to be removed from paths
"/#{MailchimpAPI::API_VERSION}"
Instance Attribute Summary collapse
-
#operation_id ⇒ String?
readonly
private
Optional operation ID for tracking batch operations.
-
#request ⇒ MailchimpAPI::Request
readonly
private
The original request object.
Instance Method Summary collapse
-
#initialize(request, operation_id: nil) ⇒ BatchRequest
constructor
private
Creates a new batch request.
-
#operation ⇒ Hash
private
Converts the request into a batch operation format.
Constructor Details
#initialize(request, operation_id: nil) ⇒ BatchRequest
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 batch request
19 20 21 22 |
# File 'lib/mailchimp-api/batch_request.rb', line 19 def initialize(request, operation_id: nil) @request = request @operation_id = operation_id end |
Instance Attribute Details
#operation_id ⇒ String? (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 Optional operation ID for tracking batch operations.
14 15 16 |
# File 'lib/mailchimp-api/batch_request.rb', line 14 def operation_id @operation_id end |
#request ⇒ MailchimpAPI::Request (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 original request object.
11 12 13 |
# File 'lib/mailchimp-api/batch_request.rb', line 11 def request @request end |
Instance Method Details
#operation ⇒ Hash
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.
Converts the request into a batch operation format
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mailchimp-api/batch_request.rb', line 33 def operation operation = { method: request.method, # "GET", "POST", "PUT", "PATCH", "DELETE" path: request.path.delete_prefix(API_VERSION_PREFIX) # Path relative to version prefix } body = request.body operation[:body] = body if body params = request.query operation[:params] = params unless params.empty? operation[:operation_id] = operation_id if operation_id operation end |