Class: CustomerioAPI::V1Client

Inherits:
Object
  • Object
show all
Defined in:
lib/customerio_api/v1_client.rb

Constant Summary collapse

BASE_URL =
'https://api.customer.io/v1/'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#adapterObject (readonly)

Returns the value of attribute adapter.



8
9
10
# File 'lib/customerio_api/v1_client.rb', line 8

def adapter
  @adapter
end

#api_keyObject (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

#connectionObject



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

#customerObject



15
16
17
# File 'lib/customerio_api/v1_client.rb', line 15

def customer
  CustomerResource.new(self)
end

#objectObject



19
20
21
# File 'lib/customerio_api/v1_client.rb', line 19

def object
  CustomerioObjectResource.new(self)
end

#object_relationshipObject



23
24
25
# File 'lib/customerio_api/v1_client.rb', line 23

def object_relationship
  ObjectRelationshipResource.new(self)
end