Class: Esendex::Batches

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/xednese/batches.rb

Overview

Provides methods for working with message batches. A Batches instance is Enumerable, and will only make requests when needed.

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Batches

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 a new instance of Batches.

See Also:



9
10
11
# File 'lib/xednese/batches.rb', line 9

def initialize(credentials)
  @credentials = credentials
end

Instance Method Details

#each {|Batch| ... } ⇒ Object

access to

Yields:

  • (Batch)

    Calls the provided block with each batch the user has



15
16
17
18
19
20
21
# File 'lib/xednese/batches.rb', line 15

def each(&block)
  Client.get(@credentials, 'v1.1/messagebatches') {|status, data|
    Responses::Batches.deserialise(data).batches.map do |batch|
      Batch.new(@credentials, batch)
    end
  }.each(&block)
end

#get(id) ⇒ Batch

Returns the batch with the given id.

Parameters:

  • id (String)

    the id of the batch to return

Returns:

  • (Batch)

    Returns the batch with the given id.



27
28
29
30
31
# File 'lib/xednese/batches.rb', line 27

def get(id)
  Client.get(@credentials, "v1.1/messagebatches/#{id}") do |status, data|
    Batch.new @credentials, Responses::Batch.deserialise(data)
  end
end