plausible_api 0.1.1 → 0.1.2

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: 1ab7e5d90aa275223a1b9006a563093a7ac9e7ceb0be4efdb2539a511361a15b
4
- data.tar.gz: f42c1294d5a65bb6ed07043a99c8febf4f42dc88d1b722632d86af2d845dd216
3
+ metadata.gz: 56e5dc3ef2295b911db3855a3dd745f9f6bfe964fd9744fca791071785dcfe10
4
+ data.tar.gz: 90f4ee8e828ed9318e2a990bc4f9ed928af6e828c073020a179bb656ad4538c6
5
5
  SHA512:
6
- metadata.gz: d85ed0990813b05c2cd277e6544859bf7bfdb8875ee68c20d6d71ce62ffef1579878b6e459b35305fc825bfa20fd868c5157d24eb9114bb100b2f7ce7e1a6601
7
- data.tar.gz: cb29f033d91225f2bdaa6cb908308444855d734b2fd3b146345915c593257db8689556a6d227775cd440683001756a377b770a6c36b3e248b88429fece538877
6
+ metadata.gz: 8f76963510fbb456467cd9cca3cbfdb7100ddddf0b7aaf38848153386b5d09dd1617839416a52bf59b8cf755b829913748335826c908ed1826f496d7b164f29e
7
+ data.tar.gz: a0750f809ecd8982532cc8a325361a660d0152610b37dd8c34ad83179b08ea3468a8e3eac8c6c92c37e54468cbe7f55e7b74b005e346e32f9d8d16b15de3742a
data/Gemfile.lock CHANGED
@@ -1,21 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plausible_api (0.1.1)
5
- faraday (~> 1.0)
4
+ plausible_api (0.1.2)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
- faraday (1.3.0)
11
- faraday-net_http (~> 1.0)
12
- multipart-post (>= 1.2, < 3)
13
- ruby2_keywords
14
- faraday-net_http (1.0.1)
15
9
  minitest (5.14.3)
16
- multipart-post (2.1.1)
17
10
  rake (12.3.3)
18
- ruby2_keywords (0.0.4)
19
11
 
20
12
  PLATFORMS
21
13
  ruby
@@ -4,8 +4,10 @@ require 'plausible_api/stats/realtime/visitors'
4
4
  require 'plausible_api/stats/aggregate'
5
5
  require 'plausible_api/stats/timeseries'
6
6
 
7
- require 'faraday'
8
7
  require 'json'
8
+ require "net/http"
9
+ require "uri"
10
+ require "cgi"
9
11
 
10
12
  module PlausibleApi
11
13
  class Client
@@ -29,14 +31,22 @@ module PlausibleApi
29
31
  call PlausibleApi::Stats::Realtime::Visitors.new
30
32
  end
31
33
 
34
+ def test
35
+ realtime_visitors.is_a? Integer
36
+ end
37
+
32
38
  private
33
- def call(api)
39
+ def call(api)
34
40
  url = "#{BASE_URL}#{api.request_url.gsub('$SITE_ID', @site_id)}"
35
- puts url
36
- res = Faraday.get(url) do |req|
37
- req.headers['Authorization'] = "Bearer #{@token}"
38
- end
39
- JSON.parse res.body
41
+ uri = URI.parse(url)
42
+
43
+ req = Net::HTTP::Get.new(uri.request_uri)
44
+ req.add_field('Authorization', "Bearer #{@token}")
45
+
46
+ http = Net::HTTP.new(uri.host, uri.port)
47
+ http.use_ssl = true
48
+
49
+ JSON.parse http.request(req).body
40
50
  end
41
51
  end
42
52
  end
@@ -1,3 +1,3 @@
1
1
  module PlausibleApi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -24,6 +24,4 @@ Gem::Specification.new do |spec|
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
-
28
- spec.add_dependency 'faraday', '~> 1.0'
29
27
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plausible_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-14 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.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
11
+ date: 2021-02-15 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: A very humble wrapper for the new API by Plausible
28
14
  email:
29
15
  - gustavo@dailytics.com