Class: CustomerioAPI::TrackV1Client

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site_id:, track_api_key:, adapter: Faraday.default_adapter) ⇒ TrackV1Client

Returns a new instance of TrackV1Client.



10
11
12
13
14
# File 'lib/customerio_api/track_v1_client.rb', line 10

def initialize(site_id:, track_api_key:, adapter: Faraday.default_adapter)
  @site_id = site_id
  @track_api_key = track_api_key
  @adapter = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



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

def adapter
  @adapter
end

#site_idObject (readonly)

Returns the value of attribute site_id.



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

def site_id
  @site_id
end

#track_api_keyObject (readonly)

Returns the value of attribute track_api_key.



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

def track_api_key
  @track_api_key
end

Instance Method Details

#connectionObject



20
21
22
23
24
25
26
27
28
# File 'lib/customerio_api/track_v1_client.rb', line 20

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.request :authorization, :basic, site_id, track_api_key
  end
end

#customer_eventObject



16
17
18
# File 'lib/customerio_api/track_v1_client.rb', line 16

def customer_event
  CustomerEventResource.new(self)
end