Class: Fathom::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fathom/client.rb

Constant Summary collapse

BASE_URL =
"https://api.usefathom.com/v1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/fathom/client.rb', line 7

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.



5
6
7
# File 'lib/fathom/client.rb', line 5

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



5
6
7
# File 'lib/fathom/client.rb', line 5

def api_key
  @api_key
end

Instance Method Details

#accountObject



12
13
14
# File 'lib/fathom/client.rb', line 12

def 
  AccountResource.new(self)
end

#aggregationsObject



16
17
18
# File 'lib/fathom/client.rb', line 16

def aggregations
  AggregationsResource.new(self)
end

#connectionObject



32
33
34
35
36
37
38
39
# File 'lib/fathom/client.rb', line 32

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
  end
end

#current_visitorsObject



20
21
22
# File 'lib/fathom/client.rb', line 20

def current_visitors
  CurrentVisitorsResource.new(self)
end

#eventsObject



24
25
26
# File 'lib/fathom/client.rb', line 24

def events
  EventsResource.new(self)
end

#sitesObject



28
29
30
# File 'lib/fathom/client.rb', line 28

def sites
  SitesResource.new(self)
end