fathom_api 0.0.1.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +27 -14
- data/Gemfile +2 -0
- data/Gemfile.lock +54 -1
- data/README.md +103 -20
- data/bin/console +4 -0
- data/fathom_api.gemspec +13 -17
- data/lib/fathom.rb +31 -0
- data/lib/fathom/client.rb +41 -0
- data/lib/fathom/object.rb +18 -0
- data/lib/fathom/objects/account.rb +4 -0
- data/lib/fathom/objects/event.rb +4 -0
- data/lib/fathom/objects/list.rb +22 -0
- data/lib/fathom/objects/site.rb +4 -0
- data/lib/fathom/resource.rb +54 -0
- data/lib/fathom/resources/account.rb +7 -0
- data/lib/fathom/resources/aggregations.rb +9 -0
- data/lib/fathom/resources/current_visitors.rb +7 -0
- data/lib/fathom/resources/events.rb +27 -0
- data/lib/fathom/resources/sites.rb +27 -0
- data/lib/fathom/version.rb +5 -0
- data/lib/fathom_api.rb +3 -6
- metadata +45 -4
- data/lib/fathom_api/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b56f8631f9278d0a5e8631b168d07b807ef191896284e69711fac634da46efe
|
4
|
+
data.tar.gz: c66e9928e9c6ebff67d46fbe7479220bdbf13489a070c9e390a6f096294a3782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b0bb564ab470ae7e84af648dfd9d16ba792bee3366e54dd1ea4308d30b0457c6e46967fafcd3fe03af8ab5f04c7dd0a59936eec8f24bc853904e0b2b8511e20
|
7
|
+
data.tar.gz: be65304241b52804ed71a5830a75d06aa6be83a0d9015a1d4ccc04ad24de4977ff5058cee0db14b6b6b588a025f72d2499291f097aa923bed95b5d3e1438b3db
|
data/.github/workflows/main.yml
CHANGED
@@ -1,18 +1,31 @@
|
|
1
|
-
name:
|
2
|
-
|
3
|
-
|
1
|
+
name: Tests
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
branches:
|
5
|
+
- "*"
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- main
|
4
9
|
|
5
10
|
jobs:
|
6
|
-
|
11
|
+
tests:
|
7
12
|
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby: ["2.7", "3.0"]
|
16
|
+
|
8
17
|
steps:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
bundle exec
|
18
|
+
- uses: actions/checkout@main
|
19
|
+
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
|
26
|
+
- name: StandardRb check
|
27
|
+
run: bundle exec standardrb
|
28
|
+
|
29
|
+
- name: Run tests
|
30
|
+
run: |
|
31
|
+
bundle exec rake test
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,74 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fathom_api (0.
|
4
|
+
fathom_api (0.1.0)
|
5
|
+
faraday (~> 1.7)
|
6
|
+
faraday_middleware (~> 1.1)
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: https://rubygems.org/
|
8
10
|
specs:
|
11
|
+
ast (2.4.2)
|
12
|
+
faraday (1.7.0)
|
13
|
+
faraday-em_http (~> 1.0)
|
14
|
+
faraday-em_synchrony (~> 1.0)
|
15
|
+
faraday-excon (~> 1.1)
|
16
|
+
faraday-httpclient (~> 1.0.1)
|
17
|
+
faraday-net_http (~> 1.0)
|
18
|
+
faraday-net_http_persistent (~> 1.1)
|
19
|
+
faraday-patron (~> 1.0)
|
20
|
+
faraday-rack (~> 1.0)
|
21
|
+
multipart-post (>= 1.2, < 3)
|
22
|
+
ruby2_keywords (>= 0.0.4)
|
23
|
+
faraday-em_http (1.0.0)
|
24
|
+
faraday-em_synchrony (1.0.0)
|
25
|
+
faraday-excon (1.1.0)
|
26
|
+
faraday-httpclient (1.0.1)
|
27
|
+
faraday-net_http (1.0.1)
|
28
|
+
faraday-net_http_persistent (1.2.0)
|
29
|
+
faraday-patron (1.0.0)
|
30
|
+
faraday-rack (1.0.0)
|
31
|
+
faraday_middleware (1.1.0)
|
32
|
+
faraday (~> 1.0)
|
9
33
|
minitest (5.14.4)
|
34
|
+
multipart-post (2.1.1)
|
35
|
+
parallel (1.20.1)
|
36
|
+
parser (3.0.2.0)
|
37
|
+
ast (~> 2.4.1)
|
38
|
+
rainbow (3.0.0)
|
10
39
|
rake (13.0.6)
|
40
|
+
regexp_parser (2.1.1)
|
41
|
+
rexml (3.2.5)
|
42
|
+
rubocop (1.18.4)
|
43
|
+
parallel (~> 1.10)
|
44
|
+
parser (>= 3.0.0.0)
|
45
|
+
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 1.8, < 3.0)
|
47
|
+
rexml
|
48
|
+
rubocop-ast (>= 1.8.0, < 2.0)
|
49
|
+
ruby-progressbar (~> 1.7)
|
50
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
51
|
+
rubocop-ast (1.10.0)
|
52
|
+
parser (>= 3.0.1.1)
|
53
|
+
rubocop-performance (1.11.4)
|
54
|
+
rubocop (>= 1.7.0, < 2.0)
|
55
|
+
rubocop-ast (>= 0.4.0)
|
56
|
+
ruby-progressbar (1.11.0)
|
57
|
+
ruby2_keywords (0.0.5)
|
58
|
+
standard (1.1.7)
|
59
|
+
rubocop (= 1.18.4)
|
60
|
+
rubocop-performance (= 1.11.4)
|
61
|
+
unicode-display_width (2.0.0)
|
11
62
|
|
12
63
|
PLATFORMS
|
13
64
|
x86_64-darwin-20
|
65
|
+
x86_64-linux
|
14
66
|
|
15
67
|
DEPENDENCIES
|
16
68
|
fathom_api!
|
17
69
|
minitest (~> 5.0)
|
18
70
|
rake (~> 13.0)
|
71
|
+
standard
|
19
72
|
|
20
73
|
BUNDLED WITH
|
21
74
|
2.2.3
|
data/README.md
CHANGED
@@ -1,45 +1,128 @@
|
|
1
|
-
# FathomApi
|
2
|
-
|
3
1
|
### Hello there! This gem is a placeholder and will be updated and working soon. Please do not install it yet.
|
4
2
|
|
5
|
-
|
3
|
+
# Fathom API
|
4
|
+
|
5
|
+
### 🛠 An easy to use client with the Fathom API
|
6
|
+
|
7
|
+
You'll need a usefathom.com account to use the API, if you don't have one [click here to sign up](https://usefathom.com/ref/CVNWHD).
|
6
8
|
|
7
|
-
|
9
|
+
As of August 17th, 2021 the API was still early-access, so some endpoints may be different than in production. Feel free to submit a PR or issue. Contributions are welcome!
|
10
|
+
|
11
|
+
[](https://github.com/afomera/fathom_api/actions) [](https://badge.fury.io/rb/fathom_api)
|
8
12
|
|
9
13
|
## Installation
|
10
14
|
|
11
|
-
Add
|
15
|
+
Add `fathom_api` to your application's Gemfile:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
bundle add fathom_api
|
19
|
+
|
20
|
+
# OR in the Gemfile
|
21
|
+
gem "fathom_api"
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Create a client to get started, passing an `api_key` you generate in your Fathom API settings.
|
12
27
|
|
13
28
|
```ruby
|
14
|
-
|
29
|
+
client = Fathom::Client.new(api_key: ENV['FATHOM_API_KEY'])
|
15
30
|
```
|
16
31
|
|
17
|
-
|
32
|
+
### Fetch account details
|
18
33
|
|
19
|
-
|
34
|
+
```ruby
|
35
|
+
# Get account details
|
36
|
+
client.account.info
|
37
|
+
# => Fathom::Account
|
38
|
+
```
|
20
39
|
|
21
|
-
|
40
|
+
Responses are wrapped in an object that dynamically allows you to call the attributes as if they are an OpenStruct... IE
|
22
41
|
|
23
|
-
|
42
|
+
```ruby
|
43
|
+
response = client.account.info
|
44
|
+
# => #<Fathom::Account:0x00007fee844068c8 @attributes=#<OpenStruct id=12345, name="Your account name", email="you@starfleet.org", object="account">>
|
24
45
|
|
25
|
-
|
46
|
+
response.name
|
47
|
+
# => "Your account name"
|
48
|
+
response.email
|
49
|
+
# => "you@starfleet.org"
|
50
|
+
```
|
51
|
+
|
52
|
+
### A note on Fathom::List objects
|
53
|
+
|
54
|
+
When an API's response comes back with a object of "list", we automatically wrap that to attempt to provide some helper methods to ease your implementations.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
list = client.sites.list
|
58
|
+
# => Fathom::List
|
26
59
|
|
27
|
-
|
60
|
+
# get the cursor you can pass to the next request's starting_after param
|
61
|
+
list.next_page
|
62
|
+
# or get the ending_before param's cursor
|
63
|
+
list.prev_page
|
28
64
|
|
29
|
-
|
65
|
+
# check if the list has more after it with
|
66
|
+
list.has_more?
|
67
|
+
```
|
30
68
|
|
31
|
-
|
69
|
+
### Sites
|
32
70
|
|
33
|
-
|
71
|
+
```ruby
|
72
|
+
client.sites.list
|
73
|
+
# Optionally, pass params in to filter / limit responses
|
74
|
+
# Limit can be between 1 and 100
|
75
|
+
client.sites.list(limit: 1, starting_after: "SITE_ID")
|
76
|
+
# => Fathom::List
|
77
|
+
|
78
|
+
client.sites.retrieve(site_id: site_id)
|
79
|
+
client.sites.create({}) # Include `name` and other params
|
80
|
+
client.sites.update(site_id: site_id, {}) # Params being updated
|
81
|
+
client.sites.delete(site_id: site_id)
|
82
|
+
client.sites.wipe(site_id: site_id)
|
83
|
+
# All return
|
84
|
+
# => Fathom::Site
|
85
|
+
```
|
34
86
|
|
35
|
-
|
87
|
+
### Events
|
36
88
|
|
37
|
-
|
89
|
+
```ruby
|
90
|
+
client.events.list(site_id: site_id)
|
91
|
+
# => Fathom::List
|
92
|
+
# Optionally, pass params in to filter / limit responses
|
93
|
+
# Limit can be between 1 and 100
|
94
|
+
client.events.list(site_id: site_id, limit: 10, starting_after: "EVENT_ID")
|
95
|
+
# => Fathom::List
|
96
|
+
|
97
|
+
client.events.retrieve(site_id: site_id, event_id: event_id)
|
98
|
+
client.events.create(site_id: site_id, {}) # Attributes for event
|
99
|
+
client.events.update(site_id: site_id, {}) # Attributes being updated
|
100
|
+
client.events.delete(site_id: site_id, event_id: event_id)
|
101
|
+
client.events.wipe(site_id: site_id, event_id: event_id)
|
102
|
+
# All return
|
103
|
+
# Fathom::Event
|
104
|
+
```
|
38
105
|
|
39
|
-
|
106
|
+
### Current Visitors
|
40
107
|
|
41
|
-
|
108
|
+
```ruby
|
109
|
+
client.current_visitors(site_id: site_id, {}) # Can add detailed: true for a more detailed report
|
110
|
+
```
|
111
|
+
|
112
|
+
### Aggregation
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
client.aggregations.list(entity_id: entity_id, entity_type: entity_type, aggregates: aggregates, **params)
|
116
|
+
```
|
117
|
+
|
118
|
+
## 🙏 Contributing
|
119
|
+
|
120
|
+
This project uses Standard for formatting Ruby code. Please make sure to run standardrb before submitting pull requests. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/afomera/fathom_api/blob/main/CODE_OF_CONDUCT.md).
|
42
121
|
|
43
122
|
## Code of Conduct
|
44
123
|
|
45
|
-
Everyone interacting in the FathomApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
124
|
+
Everyone interacting in the FathomApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/afomera/fathom_api/blob/main/CODE_OF_CONDUCT.md).
|
125
|
+
|
126
|
+
## 📝 License
|
127
|
+
|
128
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/bin/console
CHANGED
data/fathom_api.gemspec
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "lib/
|
3
|
+
require_relative "lib/fathom/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
10
|
-
|
11
|
-
spec.summary
|
12
|
-
spec.homepage
|
13
|
-
spec.license
|
6
|
+
spec.name = "fathom_api"
|
7
|
+
spec.version = Fathom::VERSION
|
8
|
+
spec.authors = ["Andrea Fomera"]
|
9
|
+
spec.email = ["afomera@hey.com"]
|
10
|
+
|
11
|
+
spec.summary = "A gem for using the Fathom API"
|
12
|
+
spec.homepage = "https://github.com/afomera/fathom_api"
|
13
|
+
spec.license = "MIT"
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
15
15
|
|
16
|
-
|
17
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
17
|
spec.metadata["source_code_uri"] = "https://github.com/afomera/fathom_api"
|
19
18
|
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
@@ -23,13 +22,10 @@ Gem::Specification.new do |spec|
|
|
23
22
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
23
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
24
|
end
|
26
|
-
spec.bindir
|
27
|
-
spec.executables
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
27
|
spec.require_paths = ["lib"]
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# For more information and examples about making a new gem, checkout our
|
34
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
29
|
+
spec.add_dependency "faraday", "~> 1.7"
|
30
|
+
spec.add_dependency "faraday_middleware", "~> 1.1"
|
35
31
|
end
|
data/lib/fathom.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "fathom/version"
|
4
|
+
|
5
|
+
module Fathom
|
6
|
+
autoload :Client, "fathom/client"
|
7
|
+
autoload :Resource, "fathom/resource"
|
8
|
+
autoload :Object, "fathom/object"
|
9
|
+
|
10
|
+
# Resources (like high level API endpoints)
|
11
|
+
autoload :AccountResource, "fathom/resources/account"
|
12
|
+
autoload :AggregationsResource, "fathom/resources/aggregations"
|
13
|
+
autoload :CurrentVisitorsResource, "fathom/resources/current_visitors"
|
14
|
+
autoload :EventsResource, "fathom/resources/events"
|
15
|
+
autoload :SitesResource, "fathom/resources/sites"
|
16
|
+
|
17
|
+
# Objects we wrap the responses in
|
18
|
+
autoload :Account, "fathom/objects/account"
|
19
|
+
autoload :Event, "fathom/objects/event"
|
20
|
+
autoload :List, "fathom/objects/list"
|
21
|
+
autoload :Site, "fathom/objects/site"
|
22
|
+
|
23
|
+
class Error < StandardError; end
|
24
|
+
|
25
|
+
def self.build_object(data)
|
26
|
+
return data unless data.is_a?(Hash)
|
27
|
+
type = data.fetch("object", "object")
|
28
|
+
class_name = type.split("_").map(&:capitalize).join
|
29
|
+
Fathom.const_get(class_name).new(data)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fathom
|
2
|
+
class Client
|
3
|
+
BASE_URL = "https://api.usefathom.com/v1"
|
4
|
+
|
5
|
+
attr_reader :api_key, :adapter
|
6
|
+
|
7
|
+
def initialize(api_key:, adapter: Faraday.default_adapter)
|
8
|
+
@api_key = api_key
|
9
|
+
@adapter = adapter
|
10
|
+
end
|
11
|
+
|
12
|
+
def account
|
13
|
+
AccountResource.new(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
def aggregations
|
17
|
+
AggregationsResource.new(self)
|
18
|
+
end
|
19
|
+
|
20
|
+
def current_visitors
|
21
|
+
CurrentVisitorsResource.new(self)
|
22
|
+
end
|
23
|
+
|
24
|
+
def events
|
25
|
+
EventsResource.new(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def sites
|
29
|
+
SitesResource.new(self)
|
30
|
+
end
|
31
|
+
|
32
|
+
def connection
|
33
|
+
@connection ||= Faraday.new do |conn|
|
34
|
+
conn.url_prefix = BASE_URL
|
35
|
+
conn.request :json
|
36
|
+
conn.response :json, content_type: "application/json"
|
37
|
+
conn.adapter adapter
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
|
3
|
+
module Fathom
|
4
|
+
class Object
|
5
|
+
def initialize(attributes)
|
6
|
+
@attributes = OpenStruct.new(attributes)
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(method, *args, &block)
|
10
|
+
attribute = @attributes.send(method, *args, &block)
|
11
|
+
attribute.is_a?(Hash) ? Object.new(attribute) : attribute
|
12
|
+
end
|
13
|
+
|
14
|
+
def respond_to_missing?(method, include_private = false)
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fathom
|
2
|
+
class List < Object
|
3
|
+
def initialize(attributes)
|
4
|
+
super
|
5
|
+
@attributes["data"].map! do |entry|
|
6
|
+
Fathom.build_object(entry)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def has_more?
|
11
|
+
@attributes["has_more"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def next_page
|
15
|
+
@attributes["data"].last.id
|
16
|
+
end
|
17
|
+
|
18
|
+
def prev_page
|
19
|
+
@attributes["data"].first.id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Fathom
|
2
|
+
class Resource
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def get_request(url, params: {}, headers: {})
|
12
|
+
handle_response client.connection.get(url, params, default_headers.merge(headers))
|
13
|
+
end
|
14
|
+
|
15
|
+
def post_request(url, body:, headers: {})
|
16
|
+
handle_response client.connection.post(url, body, default_headers.merge(headers))
|
17
|
+
end
|
18
|
+
|
19
|
+
def patch_request(url, body:, headers: {})
|
20
|
+
handle_response client.connection.patch(url, body, default_headers.merge(headers))
|
21
|
+
end
|
22
|
+
|
23
|
+
def put_request(url, body:, headers: {})
|
24
|
+
handle_response client.connection.put(url, body, default_headers.merge(headers))
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete_request(url, params: {}, headers: {})
|
28
|
+
handle_response client.connection.delete(url, params, default_headers.merge(headers))
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_headers
|
32
|
+
{Authorization: "Bearer #{client.api_key}"}
|
33
|
+
end
|
34
|
+
|
35
|
+
def handle_response(response)
|
36
|
+
case response.status
|
37
|
+
when 400
|
38
|
+
raise Error, "Your request was malformed. #{response.body}"
|
39
|
+
when 401
|
40
|
+
raise Error, "You did not supply valid authentication credentials. #{response.body}"
|
41
|
+
when 403
|
42
|
+
raise Error, "You are not allowed to perform that action. #{response.body}"
|
43
|
+
when 404
|
44
|
+
raise Error, "No results were found for your request. #{response.body}"
|
45
|
+
when 429
|
46
|
+
raise Error, "Your request exceeded the API rate limit. #{response.body}"
|
47
|
+
when 500
|
48
|
+
raise Error, "We were unable to perform the request due to server-side problems. #{response.body}"
|
49
|
+
end
|
50
|
+
|
51
|
+
Fathom.build_object(response.body)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Fathom
|
2
|
+
class AggregationsResource < Resource
|
3
|
+
# TODO: Ensure this works properly
|
4
|
+
def list(entity_id:, entity_type:, aggregates:, **params)
|
5
|
+
get_request("aggregations", params: params.merge(entity_id: entity_id,
|
6
|
+
entity_type: entity_type, aggregates: aggregates))
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fathom
|
2
|
+
class EventsResource < Resource
|
3
|
+
def list(site_id:, **params)
|
4
|
+
get_request("sites/#{site_id}/events", params: params)
|
5
|
+
end
|
6
|
+
|
7
|
+
def retrieve(site_id:, event_id:)
|
8
|
+
get_request("sites/#{site_id}/events/#{event_id}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(site_id:, **attributes)
|
12
|
+
post_request("sites/#{site_id}/events", body: attributes)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(site_id:, event_id:, **attributes)
|
16
|
+
post_request("sites/#{site_id}/events/#{event_id}", body: attributes)
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete(site_id:, event_id:)
|
20
|
+
delete_request("sites/#{site_id}/events/#{event_id}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def wipe(site_id:, event_id:)
|
24
|
+
delete_request("sites/#{site_id}/events/#{event_id}/data")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fathom
|
2
|
+
class SitesResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
get_request("sites", params: params)
|
5
|
+
end
|
6
|
+
|
7
|
+
def retrieve(site_id:)
|
8
|
+
get_request("sites/#{site_id}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(**attributes)
|
12
|
+
post_request("sites", body: attributes)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(site_id:, **attributes)
|
16
|
+
post_request("sites/#{site_id}", body: attributes)
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete(site_id:)
|
20
|
+
delete_request("sites/#{site_id}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def wipe(site_id:)
|
24
|
+
delete_request("sites/#{site_id}/data")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/fathom_api.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
class Error < StandardError; end
|
7
|
-
# Your code goes here...
|
8
|
-
end
|
3
|
+
# Empty, but used to require and load in the Fathom namespace automatically
|
4
|
+
# So we have saner class names rather than FathomApi::Client
|
5
|
+
require "fathom"
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fathom_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Fomera
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
13
41
|
description:
|
14
42
|
email:
|
15
43
|
- afomera@hey.com
|
@@ -28,8 +56,21 @@ files:
|
|
28
56
|
- bin/console
|
29
57
|
- bin/setup
|
30
58
|
- fathom_api.gemspec
|
59
|
+
- lib/fathom.rb
|
60
|
+
- lib/fathom/client.rb
|
61
|
+
- lib/fathom/object.rb
|
62
|
+
- lib/fathom/objects/account.rb
|
63
|
+
- lib/fathom/objects/event.rb
|
64
|
+
- lib/fathom/objects/list.rb
|
65
|
+
- lib/fathom/objects/site.rb
|
66
|
+
- lib/fathom/resource.rb
|
67
|
+
- lib/fathom/resources/account.rb
|
68
|
+
- lib/fathom/resources/aggregations.rb
|
69
|
+
- lib/fathom/resources/current_visitors.rb
|
70
|
+
- lib/fathom/resources/events.rb
|
71
|
+
- lib/fathom/resources/sites.rb
|
72
|
+
- lib/fathom/version.rb
|
31
73
|
- lib/fathom_api.rb
|
32
|
-
- lib/fathom_api/version.rb
|
33
74
|
homepage: https://github.com/afomera/fathom_api
|
34
75
|
licenses:
|
35
76
|
- MIT
|