Class: Postmark::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/postmark/client.rb

Direct Known Subclasses

AccountApiClient, ApiClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_token, options = {}) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
# File 'lib/postmark/client.rb', line 7

def initialize(api_token, options = {})
  options = options.dup
  @max_retries = options.delete(:max_retries) || 0
  @http_client = HttpClient.new(api_token, options)
end

Instance Attribute Details

#http_clientObject (readonly)

Returns the value of attribute http_client.



5
6
7
# File 'lib/postmark/client.rb', line 5

def http_client
  @http_client
end

#max_retriesObject (readonly)

Returns the value of attribute max_retries.



5
6
7
# File 'lib/postmark/client.rb', line 5

def max_retries
  @max_retries
end

Instance Method Details

#api_token=(api_token) ⇒ Object Also known as: api_key=



13
14
15
# File 'lib/postmark/client.rb', line 13

def api_token=(api_token)
  http_client.api_token = api_token
end

#find_each(path, name, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/postmark/client.rb', line 18

def find_each(path, name, options = {})
  if block_given?
    options = options.dup
    i, total_count = [0, 1]

    while i < total_count
      options[:offset] = i
      total_count, collection = load_batch(path, name, options)
      collection.each { |e| yield e }
      i += collection.size
    end
  else
    enum_for(:find_each, path, name, options) do
      get_resource_count(path, options)
    end
  end
end