supergood 0.0.12 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +26 -0
- data/.tool-versions +1 -0
- data/Gemfile.lock +2 -2
- data/README.md +18 -4
- data/lib/supergood/api.rb +18 -14
- data/lib/supergood/version.rb +1 -1
- data/supergood.gemspec +1 -1
- metadata +23 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5cc6a38a2204140f0764b5875faa3a86e40770b12b9783b2c62d79349a587e2
|
4
|
+
data.tar.gz: 776779840ec476c214c227d86de870fe6834738776c22ae14e5acf21c446adc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21dd980b5e7a766943b055d414112155687672fdaac6842d823f9f4920196ad2ea5012454ed6d38f5a27ae8151aa7d8da682c5d73b7b2032cb314f68802f447b
|
7
|
+
data.tar.gz: 3ae1572a26f4cba3416892c8faa3dc806580cbe4411edac101a8389364ac0dcef1950e6f09bd557a0cad5d00c90589c95cb1b852b68f3e712cd36b27fd266014
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Unit Tests
|
2
|
+
env:
|
3
|
+
DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }}
|
4
|
+
SUPERGOOD_CLIENT_ID: ${{ secrets.STAGING_SUPERGOOD_CLIENT_ID }}
|
5
|
+
SUPERGOOD_CLIENT_SECRET: ${{ secrets.STAGING_SUPERGOOD_CLIENT_SECRET }}
|
6
|
+
SUPERGOOD_BASE_URL: 'http://localhost:3000'
|
7
|
+
SUPERGOOD_ORGANIZATION_ID: ${{ vars.SUPERGOOD_ORGANIZATION_ID }}
|
8
|
+
on:
|
9
|
+
push:
|
10
|
+
branches:
|
11
|
+
- master
|
12
|
+
pull_request:
|
13
|
+
branches: [master]
|
14
|
+
jobs:
|
15
|
+
test:
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v3
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
|
21
|
+
with:
|
22
|
+
ruby-version: '3.1'
|
23
|
+
- name: Install dependencies
|
24
|
+
run: bundle install
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rspec spec/client_spec.rb
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.2.1
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
supergood (0.0
|
5
|
-
faraday (~> 2.7, >= 2.7.4)
|
4
|
+
supergood (0.1.0)
|
6
5
|
rudash (~> 4.0, >= 4.0.2)
|
7
6
|
|
8
7
|
GEM
|
@@ -92,6 +91,7 @@ DEPENDENCIES
|
|
92
91
|
base64
|
93
92
|
digest
|
94
93
|
dotenv
|
94
|
+
faraday (~> 2.7, >= 2.7.4)
|
95
95
|
http (~> 5.1, >= 5.1.1)
|
96
96
|
httparty (~> 0.21.0)
|
97
97
|
json
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# Supergood
|
2
2
|
|
3
|
-
|
3
|
+
Monitor the cost and performance of your external API's with two lines of code.
|
4
4
|
|
5
|
-
|
5
|
+
Interested in learning more? Check us out at https://supergood.ai or Reach out to alex@supergood.ai .
|
6
|
+
|
7
|
+
Not built on Ruby? We've got a node client, python client and golang client as well.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -22,7 +24,19 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
1. Head over to https://dashboard.supergood.ai and make an account, make sure to use your work email address!
|
28
|
+
2. Click on the tab labeled "API Keys" and generate a client id and client secret.
|
29
|
+
3. Head back to your code and initialize the Supergood client one of two ways:
|
30
|
+
|
31
|
+
```
|
32
|
+
require 'supergood'
|
33
|
+
|
34
|
+
Supergood.init(<client_id>, <client_secret>)
|
35
|
+
```
|
36
|
+
OR
|
37
|
+
|
38
|
+
set `SUPERGOOD_CLIENT_ID` and `SUPERGOOD_CLIENT_SECRET` as environment variables and leave the init function as `Supergood.init`
|
39
|
+
|
26
40
|
|
27
41
|
## Development
|
28
42
|
|
@@ -32,5 +46,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
46
|
|
33
47
|
## Contributing
|
34
48
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/supergoodsystems/supergood-rb.
|
36
50
|
|
data/lib/supergood/api.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'faraday'
|
2
1
|
require 'dotenv'
|
3
2
|
|
4
3
|
Dotenv.load
|
@@ -27,21 +26,21 @@ module Supergood
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def post_events(payload)
|
30
|
-
|
31
|
-
response =
|
32
|
-
if response.
|
29
|
+
uri = URI(@base_url + @event_sink_endpoint)
|
30
|
+
response = Net::HTTP.post(uri, payload.to_json, @header_options)
|
31
|
+
if response.code == '200'
|
33
32
|
return JSON.parse(response.body, symbolize_names: true)
|
34
|
-
elsif response.
|
33
|
+
elsif response.code == '401'
|
35
34
|
raise SupergoodException.new ERRORS[:UNAUTHORIZED]
|
36
|
-
elsif response.
|
35
|
+
elsif response.code != '200' && response.code != '201'
|
37
36
|
raise SupergoodException.new ERRORS[:POSTING_EVENTS]
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
40
|
def post_errors(payload)
|
42
|
-
|
43
|
-
response =
|
44
|
-
if response.
|
41
|
+
uri = URI(@base_url + @error_sink_endpoint)
|
42
|
+
response = Net::HTTP.post(uri, payload.to_json, @header_options)
|
43
|
+
if response.code == '200'
|
45
44
|
return JSON.parse(response.body, symbolize_names: true)
|
46
45
|
else
|
47
46
|
@log.warn(ERRORS[:POSTING_ERRORS])
|
@@ -49,13 +48,18 @@ module Supergood
|
|
49
48
|
end
|
50
49
|
|
51
50
|
def fetch_config
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
uri = URI(@base_url + '/api/config')
|
52
|
+
request = Net::HTTP::Get.new(uri)
|
53
|
+
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
54
|
+
request['Content-Type'] = 'application/json'
|
55
|
+
request['Authorization'] = @header_options['Authorization']
|
56
|
+
http.request(request)
|
57
|
+
end
|
58
|
+
if response.code == '200'
|
55
59
|
return JSON.parse(response.body, symbolize_names: true)
|
56
|
-
elsif response.
|
60
|
+
elsif response.code == '401'
|
57
61
|
raise SupergoodException.new ERRORS[:UNAUTHORIZED]
|
58
|
-
elsif response.
|
62
|
+
elsif response.code != '200' && response.code != '201'
|
59
63
|
raise SupergoodException.new ERRORS[:FETCHING_CONFIG]
|
60
64
|
end
|
61
65
|
end
|
data/lib/supergood/version.rb
CHANGED
data/supergood.gemspec
CHANGED
@@ -19,13 +19,13 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
20
20
|
|
21
21
|
s.add_dependency 'rudash', '~> 4.0', '>= 4.0.2'
|
22
|
-
s.add_dependency 'faraday', '~> 2.7', '>= 2.7.4'
|
23
22
|
|
24
23
|
s.add_development_dependency 'rest-client', '~> 2.1'
|
25
24
|
s.add_development_dependency 'httparty', '~> 0.21.0'
|
26
25
|
s.add_development_dependency 'http', '~> 5.1', '>= 5.1.1'
|
27
26
|
s.add_development_dependency 'rspec', '~> 3.12'
|
28
27
|
s.add_development_dependency 'webmock', '~> 3.18', '>= 3.18.1'
|
28
|
+
s.add_development_dependency 'faraday', '~> 2.7', '>= 2.7.4'
|
29
29
|
|
30
30
|
end
|
31
31
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supergood
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Klarfeld
|
@@ -30,26 +30,6 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 4.0.2
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: faraday
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '2.7'
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 2.7.4
|
43
|
-
type: :runtime
|
44
|
-
prerelease: false
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '2.7'
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 2.7.4
|
53
33
|
- !ruby/object:Gem::Dependency
|
54
34
|
name: rest-client
|
55
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,14 +112,36 @@ dependencies:
|
|
132
112
|
- - ">="
|
133
113
|
- !ruby/object:Gem::Version
|
134
114
|
version: 3.18.1
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: faraday
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '2.7'
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.7.4
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.7'
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 2.7.4
|
135
135
|
description:
|
136
136
|
email: alex@supergood.ai
|
137
137
|
executables: []
|
138
138
|
extensions: []
|
139
139
|
extra_rdoc_files: []
|
140
140
|
files:
|
141
|
+
- ".github/workflows/test.yml"
|
141
142
|
- ".gitignore"
|
142
143
|
- ".rspec"
|
144
|
+
- ".tool-versions"
|
143
145
|
- ".travis.yml"
|
144
146
|
- ".vscode/settings.json"
|
145
147
|
- Gemfile
|