Class: Fathom::Client
- Inherits:
-
Object
- Object
- Fathom::Client
- Defined in:
- lib/fathom/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.usefathom.com/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
- #aggregations ⇒ Object
- #connection ⇒ Object
- #current_visitors ⇒ Object
- #events ⇒ Object
-
#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ Client
constructor
A new instance of Client.
- #sites ⇒ Object
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
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/fathom/client.rb', line 5 def adapter @adapter end |
#api_key ⇒ Object (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
#account ⇒ Object
12 13 14 |
# File 'lib/fathom/client.rb', line 12 def account AccountResource.new(self) end |
#aggregations ⇒ Object
16 17 18 |
# File 'lib/fathom/client.rb', line 16 def aggregations AggregationsResource.new(self) end |
#connection ⇒ Object
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_visitors ⇒ Object
20 21 22 |
# File 'lib/fathom/client.rb', line 20 def current_visitors CurrentVisitorsResource.new(self) end |
#events ⇒ Object
24 25 26 |
# File 'lib/fathom/client.rb', line 24 def events EventsResource.new(self) end |
#sites ⇒ Object
28 29 30 |
# File 'lib/fathom/client.rb', line 28 def sites SitesResource.new(self) end |