Class: MailerLite::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/mailerlite/batch/batch.rb

Overview

This is a class for manipulating the Batch from MailerLite API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: MailerLite::Client.new) ⇒ Batch

Inits the ‘Batch` class with the specified `client`.

Parameters:

  • client (MailerLite::Client) (defaults to: MailerLite::Client.new)

    the ‘Client` instance to use



11
12
13
# File 'lib/mailerlite/batch/batch.rb', line 11

def initialize(client: MailerLite::Client.new)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/mailerlite/batch/batch.rb', line 6

def client
  @client
end

Instance Method Details

#request(requests:) ⇒ HTTP::Response

Create a Batch Request

Parameters:

  • requests (Array)

    Array of objects containing required method and path properties and optional body

Returns:

  • (HTTP::Response)

    the response from the API



19
20
21
22
# File 'lib/mailerlite/batch/batch.rb', line 19

def request(requests:)
  params = { requests: requests }
  client.http.post("#{MAILERLITE_API_URL}/batch", body: params.to_json)
end