Sha256: c9437f421afd1979af2ab15a2669bed78a26dbf7d421b87b346b688185ce916e

Contents?: true

Size: 726 Bytes

Versions: 3

Compression:

Stored size: 726 Bytes

Contents

# frozen_string_literal: true

module MailerLite
  # This is a class for manipulating the Batch from MailerLite API.
  class Batch
    attr_reader :client

    # Inits the `Batch` class with the specified `client`.
    #
    # @param client [MailerLite::Client] the `Client` instance to use
    def initialize(client: MailerLite::Client.new)
      @client = client
    end

    # Create a Batch Request
    #
    # @param requests [Array] Array of objects containing required method and path properties and optional body
    # @return [HTTP::Response] the response from the API
    def request(requests:)
      params = { requests: requests }
      client.http.post("#{API_URL}/batch", body: params.to_json)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mailerlite-ruby-1.0.4 lib/mailerlite/batch/batch.rb
mailerlite-ruby-1.0.3 lib/mailerlite/batch/batch.rb
mailerlite-ruby-1.0.2 lib/mailerlite/batch/batch.rb