Class: Postmark::Client
- Inherits:
-
Object
- Object
- Postmark::Client
- Defined in:
- lib/postmark/client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#max_retries ⇒ Object
readonly
Returns the value of attribute max_retries.
Instance Method Summary collapse
- #api_token=(api_token) ⇒ Object (also: #api_key=)
- #find_each(path, name, options = {}) ⇒ Object
-
#initialize(api_token, options = {}) ⇒ Client
constructor
A new instance of Client.
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, = {}) = .dup @max_retries = .delete(:max_retries) || 0 @http_client = HttpClient.new(api_token, ) end |
Instance Attribute Details
#http_client ⇒ Object (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_retries ⇒ Object (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, = {}) if block_given? = .dup i, total_count = [0, 1] while i < total_count [:offset] = i total_count, collection = load_batch(path, name, ) collection.each { |e| yield e } i += collection.size end else enum_for(:find_each, path, name, ) do get_resource_count(path, ) end end end |