pirsch_api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f23f5623a3fd98b5f09a7190b83e86a9f8a7fe4f4403ba3da9387f2fe98cc3a1
4
- data.tar.gz: 6137f3417cd67bffbe7be5d48fc5cfcd963d5b650f0998a1ce75da3c8547f285
3
+ metadata.gz: b41470047653a8abd5e3eff60fe44bef1d2afb51c82279ef48879be999fc8243
4
+ data.tar.gz: fdb4e7546d50d6049f48e727781ecb2e9395b105e4149aa01e83070340c97c43
5
5
  SHA512:
6
- metadata.gz: 0755236fcf745ccf413778bddb08e14c71330dddfbc1f1cb98991e29d708a1ec5d4a714516d452fc42d5cc032a662eb1ad1ff90fc4d74abd98ef40c0a3f1583b
7
- data.tar.gz: 889498694ba2e82c6fae0fa31e48e21ce09ef538ee02c25112a8ff8388dfd142ce2b8ac2d534924909f2d99a27c790cab19ab55a15f4366c42682f6bb8f0b7eb
6
+ metadata.gz: 9b4aa5375433d5a9196928eecddbf7d8edfcaa39161853dd84cfe51e1bf9e9bfa71e733755982ecd1014c87a52d995e34acc327911f45ce0d1fd7ea59a0e1979
7
+ data.tar.gz: 2d0763db86bbaeb91027bbdad1ef3baacb01fe8ebf91e6e80051026e8700a74f44c54b9684c5e3e62c1ee7830e1b0e960645f63d5e100885e67bcda9995768b1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pirsch_api (0.0.2)
4
+ pirsch_api (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -4,54 +4,86 @@ It's based on the [API guide](https://docs.pirsch.io/api-sdks/api/)
4
4
 
5
5
  ## Usage
6
6
  Add this gem to your Gemfile:
7
+
7
8
  ```rb
8
9
  gem 'pirsch_api'
9
10
  ```
10
- Then you need to initialize a Client with your `client_id` and the `client_secret`.
11
+
12
+ Now you need to initialize a Client with your `client_id` and the `client_secret`.
13
+
11
14
  ```rb
12
- c = PirschApi::Client.new(client_id: '<client_id>', client_secret: '<client_secret>')
15
+ client = PirschApi::Client.new(client_id: '<client_id>', client_secret: '<client_secret>')
13
16
 
14
17
  # Test if the credentials are valid
15
- c.valid?
18
+ client.valid?
16
19
  => true
20
+ ```
21
+
22
+ You will need a `Domain` as a parameter to all the following methods. This parameter could be either
23
+ a `PisrchApi::Domain` instance or a simple String containing the `id` of one domain.
17
24
 
25
+ ```rb
18
26
  # Get /domains
19
- c.domains
27
+ client.domains
20
28
  => [#<PirschApi::Domain id="0D3a...", user_id="0D3a...", hostname="pirsch.io", subdomain="pirsch", ... >]
21
- c.domains.first.hostname
29
+ domain = c.domains.first
30
+ domain.hostname
22
31
  => "pirsch.io"
32
+ domain.id
33
+ => "0D3a..."
34
+ domain.to_s
35
+ => "0D3a..."
36
+ ```
37
+ All the following methods receive a `domain` and an optional `filters` hash as a parameter. You can include any filter defined in the official documentation.
38
+
39
+ ```rb
40
+ # Get /statistics/visitors
41
+ client.visitors(domain: domain)
42
+
43
+ # Get /statistics/active
44
+ client.active(domain: domain)
45
+
46
+ # Get /statistics/pages
47
+ client.pages(domain: domain)
23
48
 
24
- # You will need one domain for all the following requests
25
- d = c.domains.first
49
+ # Get /statistics/referrers
50
+ client.referrers(domain: domain)
26
51
 
27
- # All the following methods require a `domain` and can receive a `filters` hash
52
+ # Get /statistics/growth
53
+ client.growth(domain: domain)
28
54
 
29
- # Get /statistics/visitor
30
- c.visitors(domain: d)
55
+ # Get /statistics/events
56
+ client.events(domain: domain)
57
+
58
+ # Get /statistics/utm/source
59
+ client.utm_source(domain: domain)
60
+
61
+ # Get /statistics/utm/medium
62
+ client.utm_medium(domain: domain)
63
+
64
+ # Get /statistics/utm/campaign
65
+ client.utm_campaign(domain: domain)
66
+ ```
67
+
68
+ ## Examples
69
+ ```rb
70
+
71
+ client.visitors(domain: d)
31
72
  => [#<PirschApi::Visitor day="2021-08-30T00:00:00Z", visitors=87, views=200, sessions=125, bounces=53, bounce_rate=0.6091954022988506>, #<PirschApi::Visitor day="2021-08-31T00:00:00Z", visitors=77, views=159, sessions=113, bounces=49, bounce_rate=0.6363636363636364>, #<PirschApi::Visitor day="2021-09-01T00:00:00Z", visitors=76, views=161, sessions=110, bounces=48, bounce_rate=0.631578947368421>, #<PirschApi::Visitor day="2021-09-02T00:00:00Z", visitors=79, views=152, sessions=130, bounces=52, bounce_rate=0.6582278481012658>, #<PirschApi::Visitor day="2021-09-03T00:00:00Z", visitors=53, views=109, sessions=68, bounces=26, bounce_rate=0.49056603773584906>, #<PirschApi::Visitor day="2021-09-04T00:00:00Z", visitors=54, views=126, sessions=71, bounces=31, bounce_rate=0.5740740740740741>, #<PirschApi::Visitor day="2021-09-05T00:00:00Z", visitors=116, views=202, sessions=131, bounces=84, bounce_rate=0.7241379310344828>, #<PirschApi::Visitor day="2021-09-06T00:00:00Z", visitors=1, views=1, sessions=1, bounces=1, bounce_rate=1>]
32
- c.visitors(domain: d, filters: { from: '2021-09-01' })
33
- [#<PirschApi::Visitor day="2021-09-01T00:00:00Z", visitors=76, views=161, sessions=110, bounces=48, bounce_rate=0.631578947368421>, #<PirschApi::Visitor day="2021-09-02T00:00:00Z", visitors=79, views=152, sessions=130, bounces=52, bounce_rate=0.6582278481012658>, #<PirschApi::Visitor day="2021-09-03T00:00:00Z", visitors=53, views=109, sessions=68, bounces=26, bounce_rate=0.49056603773584906>, #<PirschApi::Visitor day="2021-09-04T00:00:00Z", visitors=54, views=126, sessions=71, bounces=31, bounce_rate=0.5740740740740741>, #<PirschApi::Visitor day="2021-09-05T00:00:00Z", visitors=116, views=202, sessions=131, bounces=84, bounce_rate=0.7241379310344828>, #<PirschApi::Visitor day="2021-09-06T00:00:00Z", visitors=1, views=1, sessions=1, bounces=1, bounce_rate=1>]
34
- c.visitors(domain: d, filters: { from: '2021-09-01' }).first.day
73
+
74
+ client.visitors(domain: d, filters: { from: '2021-09-01' })
75
+ => [#<PirschApi::Visitor day="2021-09-01T00:00:00Z", visitors=76, views=161, sessions=110, bounces=48, bounce_rate=0.631578947368421>, #<PirschApi::Visitor day="2021-09-02T00:00:00Z", visitors=79, views=152, sessions=130, bounces=52, bounce_rate=0.6582278481012658>, #<PirschApi::Visitor day="2021-09-03T00:00:00Z", visitors=53, views=109, sessions=68, bounces=26, bounce_rate=0.49056603773584906>, #<PirschApi::Visitor day="2021-09-04T00:00:00Z", visitors=54, views=126, sessions=71, bounces=31, bounce_rate=0.5740740740740741>, #<PirschApi::Visitor day="2021-09-05T00:00:00Z", visitors=116, views=202, sessions=131, bounces=84, bounce_rate=0.7241379310344828>, #<PirschApi::Visitor day="2021-09-06T00:00:00Z", visitors=1, views=1, sessions=1, bounces=1, bounce_rate=1>]
76
+
77
+ client.visitors(domain: d, filters: { from: '2021-09-01' }).first.day
35
78
  => "2021-09-01T00:00:00Z"
36
79
 
37
80
  # Get /statistics/active
38
- c.active(domain: d)
81
+ client.active(domain: d)
39
82
  => #<PirschApi::Active stats=nil, visitors=0>
40
- c.active(domain: d).visitors
83
+ client.active(domain: d).visitors
41
84
  => 0
42
-
43
- # Other available methods (Remember that they can all receive a `filters` hash)
44
- c.pages(domain: d)
45
- c.referrers(domain: d)
46
- c.active(domain: d)
47
- c.growth(domain: d)
48
- c.events(domain: d)
49
- c.utm_source(domain: d)
50
- c.utm_medium(domain: d)
51
- c.utm_campaign(domain: d)
52
85
  ```
53
86
 
54
-
55
87
  ## Development
56
88
 
57
89
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,4 +1,7 @@
1
1
  module PirschApi
2
2
  class Domain < Object
3
+ def to_s
4
+ id.to_s
5
+ end
3
6
  end
4
7
  end
@@ -31,7 +31,7 @@ module PirschApi
31
31
  raise PirschApi::Error.new errors unless valid?
32
32
 
33
33
  if domain
34
- filters[:id] = domain.id
34
+ filters[:id] = domain.to_s
35
35
  end
36
36
 
37
37
  url = "#{PirschApi::Client::BASE_URL}/#{request_url}"
@@ -1,3 +1,3 @@
1
1
  module PirschApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pirsch_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Garcia