affirm-ruby 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -2
- data/Gemfile.lock +25 -25
- data/affirm.gemspec +0 -1
- data/lib/affirm/client.rb +4 -4
- data/lib/affirm/version.rb +1 -1
- data/lib/affirm.rb +0 -1
- data/spec/charge_spec.rb +10 -6
- data/spec/client_spec.rb +17 -19
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 311a0f81d64a7f23bbfbc57366e2f174d4c80a1914fd59c225f3849a49992264
|
4
|
+
data.tar.gz: 7881f6ca2e67a47a50de4c12bbfcd53427a9084c1d68c6ff2ecb01e8f1df476f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a861d1e63477c020271f17c8b1f4648918a4fc38b5d546bfe9554dd52246ecfc7dbaf374f75d8390433e58914949a36e3cc64e1802de00791995394f4f81e620
|
7
|
+
data.tar.gz: 2c1e55d82b904144ae5add4cafc9ab4077dd1308472cfa0d7b23581332ccff84f7d6c74ce5c0ee85811e4170a2b2bb064c1afb242da73c55f472713b5216dbb5
|
data/CHANGELOG.md
CHANGED
@@ -4,13 +4,17 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
-
## [1.1.3][] (
|
7
|
+
## [1.1.3][] (2022-04-29)
|
8
|
+
|
9
|
+
Fixes:
|
10
|
+
|
11
|
+
- Fix error on Ruby 3 (embold-tyler in [#6](https://github.com/spectator/affirm/pull/6))
|
8
12
|
|
9
13
|
## [1.1.2][] (2021-10-30)
|
10
14
|
|
11
15
|
Fixes:
|
12
16
|
|
13
|
-
- Relax Ruby requirement (embold-tyler in [#
|
17
|
+
- Relax Ruby requirement (embold-tyler in [#5](https://github.com/spectator/affirm/pull/5))
|
14
18
|
|
15
19
|
## [1.1.0][] (2019-09-03)
|
16
20
|
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
affirm-ruby (1.
|
4
|
+
affirm-ruby (1.2.0)
|
5
5
|
faraday
|
6
|
-
faraday_middleware
|
7
6
|
virtus (~> 1.0, >= 1.0.0)
|
8
7
|
|
9
8
|
GEM
|
@@ -13,35 +12,35 @@ GEM
|
|
13
12
|
descendants_tracker (~> 0.0.4)
|
14
13
|
ice_nine (~> 0.11.0)
|
15
14
|
thread_safe (~> 0.3, >= 0.3.1)
|
16
|
-
|
17
|
-
|
15
|
+
base64 (0.1.1)
|
16
|
+
byebug (11.1.3)
|
18
17
|
coercible (1.0.0)
|
19
18
|
descendants_tracker (~> 0.0.1)
|
20
|
-
columnize (0.9.0)
|
21
19
|
descendants_tracker (0.0.4)
|
22
20
|
thread_safe (~> 0.3, >= 0.3.1)
|
23
|
-
diff-lcs (1.
|
21
|
+
diff-lcs (1.5.0)
|
24
22
|
equalizer (0.0.11)
|
25
|
-
faraday (
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
faraday (2.7.11)
|
24
|
+
base64
|
25
|
+
faraday-net_http (>= 2.0, < 3.1)
|
26
|
+
ruby2_keywords (>= 0.0.4)
|
27
|
+
faraday-net_http (3.0.2)
|
29
28
|
ice_nine (0.11.2)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rspec-
|
34
|
-
rspec-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
rspec-expectations (3.9.0)
|
29
|
+
rake (13.1.0)
|
30
|
+
rspec (3.12.0)
|
31
|
+
rspec-core (~> 3.12.0)
|
32
|
+
rspec-expectations (~> 3.12.0)
|
33
|
+
rspec-mocks (~> 3.12.0)
|
34
|
+
rspec-core (3.12.2)
|
35
|
+
rspec-support (~> 3.12.0)
|
36
|
+
rspec-expectations (3.12.3)
|
39
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.12.0)
|
39
|
+
rspec-mocks (3.12.6)
|
42
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
41
|
+
rspec-support (~> 3.12.0)
|
42
|
+
rspec-support (3.12.1)
|
43
|
+
ruby2_keywords (0.0.5)
|
45
44
|
thread_safe (0.3.6)
|
46
45
|
virtus (1.0.5)
|
47
46
|
axiom-types (~> 0.1)
|
@@ -50,7 +49,8 @@ GEM
|
|
50
49
|
equalizer (~> 0.0, >= 0.0.9)
|
51
50
|
|
52
51
|
PLATFORMS
|
53
|
-
|
52
|
+
arm64-darwin-22
|
53
|
+
x86_64-darwin-21
|
54
54
|
|
55
55
|
DEPENDENCIES
|
56
56
|
affirm-ruby!
|
@@ -60,4 +60,4 @@ DEPENDENCIES
|
|
60
60
|
rspec
|
61
61
|
|
62
62
|
BUNDLED WITH
|
63
|
-
2.
|
63
|
+
2.4.19
|
data/affirm.gemspec
CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = [">= 2.1", "< 4.0"]
|
22
22
|
spec.add_dependency "faraday"
|
23
|
-
spec.add_dependency "faraday_middleware"
|
24
23
|
spec.add_dependency "virtus", "~> 1.0", ">= 1.0.0"
|
25
24
|
|
26
25
|
spec.add_development_dependency "bundler"
|
data/lib/affirm/client.rb
CHANGED
@@ -6,7 +6,7 @@ module Affirm
|
|
6
6
|
private :url_prefix
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def request(method, path,
|
9
|
+
def request(method, path, data={})
|
10
10
|
new.public_send(method, path, data)
|
11
11
|
end
|
12
12
|
end
|
@@ -14,18 +14,18 @@ module Affirm
|
|
14
14
|
def initialize
|
15
15
|
@url_prefix = "/api/v2"
|
16
16
|
@connection = Faraday.new(Affirm.configuration.endpoint) do |conn|
|
17
|
-
conn.
|
17
|
+
conn.request :authorization, :basic, basic_auth_user, basic_auth_password
|
18
18
|
conn.request :json
|
19
19
|
conn.response :json, content_type: /\bjson$/
|
20
20
|
conn.adapter Faraday.default_adapter
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def get(path,
|
24
|
+
def get(path, data={})
|
25
25
|
connection.get(normalized_path(path), data)
|
26
26
|
end
|
27
27
|
|
28
|
-
def post(path,
|
28
|
+
def post(path, data={})
|
29
29
|
connection.post(normalized_path(path), data)
|
30
30
|
end
|
31
31
|
|
data/lib/affirm/version.rb
CHANGED
data/lib/affirm.rb
CHANGED
data/spec/charge_spec.rb
CHANGED
@@ -266,9 +266,11 @@ RSpec.describe Affirm::Charge do
|
|
266
266
|
before do
|
267
267
|
expect(Affirm::Client).to receive(:request)
|
268
268
|
.with(:post, "charges/1/update",
|
269
|
-
|
270
|
-
|
271
|
-
|
269
|
+
{
|
270
|
+
order_id: "XYZ-007",
|
271
|
+
shipping_carrier: "FedEx",
|
272
|
+
shipping_confirmation: "1ZX007"
|
273
|
+
})
|
272
274
|
.and_return(failed_response)
|
273
275
|
end
|
274
276
|
|
@@ -310,9 +312,11 @@ RSpec.describe Affirm::Charge do
|
|
310
312
|
before do
|
311
313
|
expect(Affirm::Client).to receive(:request)
|
312
314
|
.with(:post, "charges/1/update",
|
313
|
-
|
314
|
-
|
315
|
-
|
315
|
+
{
|
316
|
+
order_id: "XYZ-007",
|
317
|
+
shipping_carrier: "FedEx",
|
318
|
+
shipping_confirmation: "1ZX007"
|
319
|
+
}
|
316
320
|
)
|
317
321
|
.and_return(successful_response)
|
318
322
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -1,28 +1,16 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
3
|
RSpec.describe Affirm::Client do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
before(:all) do
|
5
|
+
Affirm.configure do |config|
|
6
|
+
config.public_api_key = "abc"
|
7
|
+
config.private_api_key = "xyz"
|
7
8
|
end
|
8
9
|
end
|
9
10
|
|
10
|
-
context "
|
11
|
-
|
12
|
-
|
13
|
-
config.public_api_key = "abc"
|
14
|
-
config.private_api_key = "xyz"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "sets json handlers" do
|
19
|
-
expect(
|
20
|
-
subject.connection.builder.handlers
|
21
|
-
).to include(FaradayMiddleware::EncodeJson, FaradayMiddleware::ParseJson)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "sets basic auth header" do
|
25
|
-
expect(subject.connection.headers["Authorization"]).to eq("Basic YWJjOnh5eg==")
|
11
|
+
context "new instance" do
|
12
|
+
it "creates Faraday connection" do
|
13
|
+
expect(subject.connection).to be_an_instance_of(Faraday::Connection)
|
26
14
|
end
|
27
15
|
end
|
28
16
|
|
@@ -41,6 +29,11 @@ RSpec.describe Affirm::Client do
|
|
41
29
|
subject.connection.adapter(:test, @stubs)
|
42
30
|
end
|
43
31
|
|
32
|
+
it "sets basic auth header" do
|
33
|
+
response = subject.post("foo", {})
|
34
|
+
expect(response.env.request_headers["Authorization"]).to eq("Basic YWJjOnh5eg==")
|
35
|
+
end
|
36
|
+
|
44
37
|
it "makes request to full url" do
|
45
38
|
response = subject.post("foo", {})
|
46
39
|
expect(response.env.url.to_s).to eq("https://api.affirm.com/api/v2/foo")
|
@@ -74,6 +67,11 @@ RSpec.describe Affirm::Client do
|
|
74
67
|
subject.connection.adapter(:test, @stubs)
|
75
68
|
end
|
76
69
|
|
70
|
+
it "sets basic auth header" do
|
71
|
+
response = subject.get("foo", {})
|
72
|
+
expect(response.env.request_headers["Authorization"]).to eq("Basic YWJjOnh5eg==")
|
73
|
+
end
|
74
|
+
|
77
75
|
it "makes request to full url" do
|
78
76
|
response = subject.get("foo", {})
|
79
77
|
expect(response.env.url.to_s).to eq("https://api.affirm.com/api/v2/foo")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: affirm-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Velikanau
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -25,20 +25,6 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: faraday_middleware
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :runtime
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: virtus
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
170
|
- !ruby/object:Gem::Version
|
185
171
|
version: '0'
|
186
172
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
173
|
+
rubygems_version: 3.3.7
|
188
174
|
signing_key:
|
189
175
|
specification_version: 4
|
190
176
|
summary: Ruby wrapper for Affirm.com API
|