Class: Unitpost::Client
- Inherits:
-
Object
- Object
- Unitpost::Client
- Defined in:
- lib/unitpost/client.rb
Overview
The Unitpost client. Construct once, reuse everywhere.
require "unitpost"
unitpost = Unitpost::Client.new # reads UNITPOST_API_KEY
result = unitpost.emails.send(from: ..., to: ..., subject: ..., html: ...)
if result.error
warn "#{result.error.code}: #{result.error.message}"
else
puts result.data["id"]
end
Instance Attribute Summary collapse
-
#api_keys ⇒ Object
readonly
Returns the value of attribute api_keys.
-
#brand_kits ⇒ Object
readonly
Returns the value of attribute brand_kits.
-
#campaigns ⇒ Object
readonly
Returns the value of attribute campaigns.
-
#contact_fields ⇒ Object
readonly
Returns the value of attribute contact_fields.
-
#contacts ⇒ Object
readonly
Returns the value of attribute contacts.
-
#domains ⇒ Object
readonly
Returns the value of attribute domains.
-
#emails ⇒ Object
readonly
Returns the value of attribute emails.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
-
#suppressions ⇒ Object
readonly
Returns the value of attribute suppressions.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
-
#topics ⇒ Object
readonly
Returns the value of attribute topics.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
-
#webhooks ⇒ Object
readonly
Returns the value of attribute webhooks.
Instance Method Summary collapse
-
#initialize(api_key: nil, base_url: nil, timeout: 30, headers: {}, adapter: nil, stubs: nil, max_retries: 2, retry_base_delay: 0.5, max_retry_delay: 20.0, sleeper: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key: nil, base_url: nil, timeout: 30, headers: {}, adapter: nil, stubs: nil, max_retries: 2, retry_base_delay: 0.5, max_retry_delay: 20.0, sleeper: nil) ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/unitpost/client.rb', line 22 def initialize(api_key: nil, base_url: nil, timeout: 30, headers: {}, adapter: nil, stubs: nil, max_retries: 2, retry_base_delay: 0.5, max_retry_delay: 20.0, sleeper: nil) http = HttpClient.new( api_key: api_key, base_url: base_url, timeout: timeout, headers: headers, adapter: adapter, stubs: stubs, max_retries: max_retries, retry_base_delay: retry_base_delay, max_retry_delay: max_retry_delay, sleeper: sleeper ) @emails = Resources::Emails.new(http) @contacts = Resources::Contacts.new(http) @contact_fields = Resources::ContactFields.new(http) @segments = Resources::Segments.new(http) @topics = Resources::Topics.new(http) @campaigns = Resources::Campaigns.new(http) @templates = Resources::Templates.new(http) @brand_kits = Resources::BrandKits.new(http) @domains = Resources::Domains.new(http) @webhooks = Resources::Webhooks.new(http) @api_keys = Resources::ApiKeys.new(http) @suppressions = Resources::Suppressions.new(http) # NOTE (pre-launch): `events` is intentionally absent while the # custom-events surface is behind the launch gate. @usage = Resources::Usage.new(http) end |
Instance Attribute Details
#api_keys ⇒ Object (readonly)
Returns the value of attribute api_keys.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def api_keys @api_keys end |
#brand_kits ⇒ Object (readonly)
Returns the value of attribute brand_kits.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def brand_kits @brand_kits end |
#campaigns ⇒ Object (readonly)
Returns the value of attribute campaigns.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def campaigns @campaigns end |
#contact_fields ⇒ Object (readonly)
Returns the value of attribute contact_fields.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def contact_fields @contact_fields end |
#contacts ⇒ Object (readonly)
Returns the value of attribute contacts.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def contacts @contacts end |
#domains ⇒ Object (readonly)
Returns the value of attribute domains.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def domains @domains end |
#emails ⇒ Object (readonly)
Returns the value of attribute emails.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def emails @emails end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def segments @segments end |
#suppressions ⇒ Object (readonly)
Returns the value of attribute suppressions.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def suppressions @suppressions end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def templates @templates end |
#topics ⇒ Object (readonly)
Returns the value of attribute topics.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def topics @topics end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def usage @usage end |
#webhooks ⇒ Object (readonly)
Returns the value of attribute webhooks.
18 19 20 |
# File 'lib/unitpost/client.rb', line 18 def webhooks @webhooks end |