supergood 0.1.0 → 0.1.1

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: cb3307099fe394492d12e7f204da26d9ccb0cca6d53eae8ad1a3e7cc65ae599f
4
- data.tar.gz: 9d8b94b82e04ccdb7d0751b52a29381ebbba02aa2bc7c4e088354626600af5ed
3
+ metadata.gz: a5cc6a38a2204140f0764b5875faa3a86e40770b12b9783b2c62d79349a587e2
4
+ data.tar.gz: 776779840ec476c214c227d86de870fe6834738776c22ae14e5acf21c446adc7
5
5
  SHA512:
6
- metadata.gz: add414866656373dbef5a3c78bcdf6c0220eda4855bf83c4c0b2ae4a9861e7ad8f071ebe4b3ab80244b74f0646f4953c0fcf8f8c0bba6e8af23a1c34c1c7522f
7
- data.tar.gz: dec173ab5aeb5b18e9cac6a4ef15c00f8b523982b9f313e92e18a42f0c2ab15f568cf6e85662d86843e9166c155a8236afa42dc9d96f2fb25a6635508398bad7
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.12)
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
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/supergood`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Monitor the cost and performance of your external API's with two lines of code.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
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/[USERNAME]/supergood.
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
- conn = Faraday.new(url: @base_url, headers: @header_options)
31
- response = conn.post(@event_sink_endpoint, body = payload.to_json, headers = @header_options)
32
- if response.status == 200
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.status == 401
33
+ elsif response.code == '401'
35
34
  raise SupergoodException.new ERRORS[:UNAUTHORIZED]
36
- elsif response.status != 200 && response.status != 201
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
- conn = Faraday.new(url: @base_url, headers: @header_options)
43
- response = conn.post(@error_sink_endpoint, body = payload.to_json, headers = @header_options)
44
- if response.status == 200
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
- conn = Faraday.new(url: @base_url, headers: @header_options)
53
- response = conn.get('/api/config')
54
- if response.status == 200
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.status == 401
60
+ elsif response.code == '401'
57
61
  raise SupergoodException.new ERRORS[:UNAUTHORIZED]
58
- elsif response.status != 200 && response.status != 201
62
+ elsif response.code != '200' && response.code != '201'
59
63
  raise SupergoodException.new ERRORS[:FETCHING_CONFIG]
60
64
  end
61
65
  end
@@ -1,3 +1,3 @@
1
1
  module Supergood
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
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.1.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