Class: CustomerioAPI::V1Client
- Inherits:
-
Object
- Object
- CustomerioAPI::V1Client
- Defined in:
- lib/customerio_api/v1_client.rb
Constant Summary collapse
- BASE_URL =
'https://api.customer.io/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
- #connection ⇒ Object
- #customer ⇒ Object
-
#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ V1Client
constructor
A new instance of V1Client.
- #object ⇒ Object
- #object_relationship ⇒ Object
Constructor Details
#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ V1Client
Returns a new instance of V1Client.
10 11 12 13 |
# File 'lib/customerio_api/v1_client.rb', line 10 def initialize(api_key:, adapter: Faraday.default_adapter) @api_key = api_key @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/customerio_api/v1_client.rb', line 8 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/customerio_api/v1_client.rb', line 8 def api_key @api_key end |
Instance Method Details
#connection ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/customerio_api/v1_client.rb', line 27 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 conn.headers['Authorization'] = "Bearer #{api_key}" end end |
#customer ⇒ Object
15 16 17 |
# File 'lib/customerio_api/v1_client.rb', line 15 def customer CustomerResource.new(self) end |
#object ⇒ Object
19 20 21 |
# File 'lib/customerio_api/v1_client.rb', line 19 def object CustomerioObjectResource.new(self) end |
#object_relationship ⇒ Object
23 24 25 |
# File 'lib/customerio_api/v1_client.rb', line 23 def object_relationship ObjectRelationshipResource.new(self) end |