spackle-ruby 0.0.15 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/lib/spackle/stores/edge.rb +28 -20
- data/spackle.gemspec +2 -3
- metadata +11 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32480a021112248d161f422541c003cbe176944ac291b40eb3bfd108bd2b8a64
|
4
|
+
data.tar.gz: a95dc99b789dd3640ba204b1ec789ed51e94507594cfa92f929fa87003fb46cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c32a949157acd858345046696e28754414b55716bcdefd057ed72023049a87697a8fa375d002745f3e4fedec7ff15c9db2fa6b7bf0768253150039bc0dad1f76
|
7
|
+
data.tar.gz: 18c1f836c78568b3a05ee87f03a60adfc254ee6516129320246ceac812947b4c7c5fe6beb29a3deabfa98caa0ecfbf2222c79d9caa228a0a1a461c630a8c6868
|
data/Gemfile
CHANGED
data/lib/spackle/stores/edge.rb
CHANGED
@@ -1,43 +1,51 @@
|
|
1
|
-
require '
|
2
|
-
require
|
1
|
+
require 'faraday'
|
2
|
+
require "faraday/net_http_persistent"
|
3
3
|
require 'json'
|
4
4
|
require 'logger'
|
5
5
|
|
6
6
|
module Spackle
|
7
7
|
class EdgeStore < BaseStore
|
8
8
|
def initialize()
|
9
|
-
@edge =
|
10
|
-
|
9
|
+
@edge = Faraday.new(
|
10
|
+
url: Spackle.edge_base,
|
11
|
+
headers: {
|
12
|
+
'Authorization' => "Bearer #{Spackle.api_key}",
|
13
|
+
'X-Spackle-Schema-Version' => Spackle.version.to_s,
|
14
|
+
}
|
15
|
+
) do |faraday|
|
16
|
+
faraday.adapter :net_http_persistent
|
11
17
|
end
|
12
18
|
|
13
|
-
@api =
|
14
|
-
|
19
|
+
@api = Faraday.new(
|
20
|
+
url: Spackle.api_base,
|
21
|
+
headers: {
|
22
|
+
'Authorization' => "Bearer #{Spackle.api_key}",
|
23
|
+
'X-Spackle-Schema-Version' => Spackle.version.to_s,
|
24
|
+
}
|
25
|
+
) do |faraday|
|
26
|
+
faraday.adapter :net_http_persistent
|
15
27
|
end
|
16
28
|
end
|
17
29
|
|
18
30
|
def get_customer_data(id)
|
19
|
-
@edge.
|
20
|
-
response = http.auth("Bearer #{Spackle.api_key}").get(Spackle.edge_base + '/customers/' + id + '/state').flush
|
31
|
+
response = @edge.get("/customers/#{id}/state")
|
21
32
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
return JSON.parse(response.body)
|
33
|
+
if response.status != 200
|
34
|
+
return fetch_state_from_api(id)
|
27
35
|
end
|
36
|
+
|
37
|
+
return JSON.parse(response.body)
|
28
38
|
end
|
29
39
|
|
30
40
|
def fetch_state_from_api(id)
|
31
41
|
Util.log_warn("Customer #{id} not found. Fetching from API...")
|
32
|
-
@api.
|
33
|
-
response = http.auth("Bearer #{Spackle.api_key}").get(Spackle.api_base + '/customers/' + id + '/state').flush
|
42
|
+
response = @api.get(Spackle.api_base + "/customers/#{id}/state")
|
34
43
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
return JSON.parse(response.body)
|
44
|
+
if response.status != 200
|
45
|
+
raise SpackleError.new "Customer #{id} not found"
|
40
46
|
end
|
47
|
+
|
48
|
+
return JSON.parse(response.body)
|
41
49
|
end
|
42
50
|
end
|
43
51
|
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.
|
5
|
+
s.version = "0.0.17"
|
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.
|
4
|
+
version: 0.0.17
|
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-
|
11
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
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: '
|
26
|
+
version: '2.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
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: '
|
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: '
|
40
|
+
version: '1.13'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: stripe
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
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: '
|
54
|
+
version: '8.3'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rake
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|