Class: Stannp::Client
- Inherits:
-
Object
- Object
- Stannp::Client
- Defined in:
- lib/stannp/client.rb
Constant Summary collapse
- BASE_URL =
'https://dash.stannp.com/api/v1'
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #account ⇒ Object
- #addresses ⇒ Object
- #campaigns ⇒ Object
- #connection ⇒ Object
- #events ⇒ Object
- #groups ⇒ Object
-
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #letters ⇒ Object
- #postcards ⇒ Object
- #recipients ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/stannp/client.rb', line 11 def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) @api_key = api_key @adapter = adapter @stubs = stubs end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/stannp/client.rb', line 9 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/stannp/client.rb', line 9 def api_key @api_key end |
Instance Method Details
#account ⇒ Object
17 18 19 |
# File 'lib/stannp/client.rb', line 17 def account AccountResource.new(client: self) end |
#addresses ⇒ Object
29 30 31 |
# File 'lib/stannp/client.rb', line 29 def addresses AddressesResource.new(client: self) end |
#campaigns ⇒ Object
45 46 47 |
# File 'lib/stannp/client.rb', line 45 def campaigns CampaignsResource.new(client: self) end |
#connection ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/stannp/client.rb', line 53 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = BASE_URL conn.request :json conn.response :json, content_type: 'application/json' conn.adapter adapter, stubs end end |
#events ⇒ Object
49 50 51 |
# File 'lib/stannp/client.rb', line 49 def events EventsResource.new(client: self) end |
#groups ⇒ Object
41 42 43 |
# File 'lib/stannp/client.rb', line 41 def groups GroupsResource.new(client: self) end |
#letters ⇒ Object
37 38 39 |
# File 'lib/stannp/client.rb', line 37 def letters LettersResource.new(client: self) end |
#postcards ⇒ Object
33 34 35 |
# File 'lib/stannp/client.rb', line 33 def postcards PostcardsResource.new(client: self) end |
#recipients ⇒ Object
25 26 27 |
# File 'lib/stannp/client.rb', line 25 def recipients RecipientsResource.new(client: self) end |
#user ⇒ Object
21 22 23 |
# File 'lib/stannp/client.rb', line 21 def user UserResource.new(client: self) end |