spackle-ruby 0.0.15 → 0.0.16

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: 62488969b7e0cbd8420db57f77f1f75b7c7b0cd7e9ca246521bc01c3a91c94f0
4
- data.tar.gz: ed07a041cf115c6120bdfc1940a11dc322908c95e3e10fb99842a74aa7dec32a
3
+ metadata.gz: 2836d3a94748b633923e713c61666b48202ec2a69e88a47e1f49f43697ac446a
4
+ data.tar.gz: 567c08ffaf04b62443c7e7c35de97179781834c6ad2992a7df5ac634a3c71c77
5
5
  SHA512:
6
- metadata.gz: c89eb3973dbdbd7b3b72d9c83cbbd62e0d7eb06c03c84f4bd3f19978e52d3f6881a62dd4367839ba48ce1133cce0dc611be07bd6c01a5339d67f292c02be6dba
7
- data.tar.gz: f26e1cb1ea3c87a9baa86b3108801bb2fd4c4775c2e1850e29d3684dfcb23c1b25d2dcc80ef94a01936179096731c01cfdecec90b8a20dc72194dae969ee4e56
6
+ metadata.gz: 7fa9cb1dcd0df67dde5d2466f0ddecd37c727038c018408c4473836dc1aa5ea3de9dca87e054256b412d393578027f861967a50104f7a12ac02bd4694747196d
7
+ data.tar.gz: a98c28187be567457ff71b9c61728aa2764cb805f950fddca6899c37b39dca4e19ee1b0db39e202c164f5ffed1a711f4a804ba471a01224bb024dadf52a26a89
data/Gemfile CHANGED
@@ -9,5 +9,4 @@ gem "nokogiri", "~> 1.13"
9
9
  gem "minitest", "~> 5.18"
10
10
  gem "webmock", "~> 3.18"
11
11
  gem "stripe", "~> 8.3"
12
- gem "http", "~> 5.1"
13
- gem "connection_pool", "~> 2.4"
12
+ gem "faraday", "~> 2.7"
@@ -1,43 +1,45 @@
1
- require 'connection_pool'
2
- require 'http'
1
+ require 'faraday'
3
2
  require 'json'
4
3
  require 'logger'
5
4
 
6
5
  module Spackle
7
6
  class EdgeStore < BaseStore
8
7
  def initialize()
9
- @edge = ConnectionPool.new(size: 10, timeout: 5) do
10
- HTTP.persistent(Spackle.edge_base)
11
- end
12
-
13
- @api = ConnectionPool.new(size: 10, timeout: 5) do
14
- HTTP.persistent(Spackle.api_base)
15
- end
8
+ @edge = Faraday.new(
9
+ url: Spackle.edge_base,
10
+ headers: {
11
+ 'Authorization' => "Bearer #{Spackle.api_key}",
12
+ 'X-Spackle-Schema-Version' => Spackle.version.to_s,
13
+ }
14
+ )
15
+ @api = Faraday.new(
16
+ url: Spackle.api_base,
17
+ headers: {
18
+ 'Authorization' => "Bearer #{Spackle.api_key}",
19
+ 'X-Spackle-Schema-Version' => Spackle.version.to_s,
20
+ }
21
+ )
16
22
  end
17
23
 
18
24
  def get_customer_data(id)
19
- @edge.with do |http|
20
- response = http.auth("Bearer #{Spackle.api_key}").get(Spackle.edge_base + '/customers/' + id + '/state').flush
21
-
22
- if response.code != 200
23
- return fetch_state_from_api(id)
24
- end
25
+ response = @edge.get("/customers/#{id}/state")
25
26
 
26
- return JSON.parse(response.body)
27
+ if response.status != 200
28
+ return fetch_state_from_api(id)
27
29
  end
30
+
31
+ return JSON.parse(response.body)
28
32
  end
29
33
 
30
34
  def fetch_state_from_api(id)
31
35
  Util.log_warn("Customer #{id} not found. Fetching from API...")
32
- @api.with do |http|
33
- response = http.auth("Bearer #{Spackle.api_key}").get(Spackle.api_base + '/customers/' + id + '/state').flush
34
-
35
- if response.code != 200
36
- raise SpackleError.new "Customer #{id} not found"
37
- end
36
+ response = @api.get(Spackle.api_base + "/customers/#{id}/state")
38
37
 
39
- return JSON.parse(response.body)
38
+ if response.status != 200
39
+ raise SpackleError.new "Customer #{id} not found"
40
40
  end
41
+
42
+ return JSON.parse(response.body)
41
43
  end
42
44
  end
43
45
  end
data/spackle.gemspec CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift(::File.join(::File.dirname(__FILE__), "lib"))
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "spackle-ruby"
5
- s.version = "0.0.15"
5
+ s.version = "0.0.16"
6
6
  s.summary = "Spackle Ruby gem"
7
7
  s.description = "Spackle is the easiest way to integrate your Ruby app with Stripe Billing. " \
8
8
  "See https://www.spackle.so for details."
@@ -18,10 +18,9 @@ Gem::Specification.new do |s|
18
18
  "source_code_uri" => "https://github.com/spackleso/spackle-ruby",
19
19
  }
20
20
 
21
+ s.add_dependency "faraday", "~> 2.7"
21
22
  s.add_dependency "nokogiri", "~> 1.13"
22
23
  s.add_dependency "stripe", "~> 8.3"
23
- s.add_dependency "http", "~> 5.1"
24
- s.add_dependency "connection_pool", "~> 2.4"
25
24
 
26
25
  s.add_development_dependency "rake", "~> 13.0"
27
26
  s.add_development_dependency "minitest", "~> 5.18"
metadata CHANGED
@@ -1,71 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spackle-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spackle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-23 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nokogiri
14
+ name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: '2.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: '2.7'
27
27
  - !ruby/object:Gem::Dependency
28
- name: stripe
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '8.3'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '8.3'
41
- - !ruby/object:Gem::Dependency
42
- name: http
28
+ name: nokogiri
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '5.1'
33
+ version: '1.13'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '5.1'
40
+ version: '1.13'
55
41
  - !ruby/object:Gem::Dependency
56
- name: connection_pool
42
+ name: stripe
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '2.4'
47
+ version: '8.3'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '2.4'
54
+ version: '8.3'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement