defra_ruby_govpay 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -16
- data/.rubocop_todo.yml +12 -0
- data/.ruby-version +1 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +32 -11
- data/defra_ruby_govpay.gemspec +3 -2
- data/lib/defra_ruby_govpay/api.rb +20 -15
- data/lib/defra_ruby_govpay/version.rb +1 -1
- data/lib/defra_ruby_govpay.rb +9 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba54aba1349d8a9f7f7e7091775e4687b69ba8b3437a980fd0f355d8648db453
|
4
|
+
data.tar.gz: ea4115db350c21ba48e867aebbeb4b96791aa89852ca41144b0065cb07bc19df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d1da26faac8cd47483c60a8f66c32b405654978e4322b3258812009a336ef6409ddd68a763248070e7dd5b08f95e658d25710b283a2be0425bb877ea6ab0e70
|
7
|
+
data.tar.gz: 9d64fc44573910e2aedd3290065d5d0f3743b12218af85466f2b3bfc8ca7fc5c99636456b59e99b07de2250ddb9a82055a02e34b29121693f6a2b574165370d7
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,17 +1,5 @@
|
|
1
|
-
|
2
|
-
TargetRubyVersion: 2.6
|
1
|
+
inherit_from: .rubocop_todo.yml
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Style/StringLiteralsInInterpolation:
|
9
|
-
Enabled: true
|
10
|
-
EnforcedStyle: double_quotes
|
11
|
-
|
12
|
-
Layout/LineLength:
|
13
|
-
Max: 120
|
14
|
-
|
15
|
-
Metrics/BlockLength:
|
16
|
-
Exclude:
|
17
|
-
- 'spec/**/*'
|
3
|
+
inherit_gem:
|
4
|
+
defra_ruby_style:
|
5
|
+
- default.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2023-11-03 17:41:17 UTC using RuboCop version 1.57.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
Style/OpenStructUse:
|
11
|
+
Exclude:
|
12
|
+
- 'lib/defra_ruby_govpay/object.rb'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/Gemfile
CHANGED
@@ -5,10 +5,16 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in govpay_integration.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
gem "byebug"
|
9
|
+
|
10
|
+
gem "defra_ruby_style", "~> 0.4"
|
11
|
+
|
8
12
|
gem "rake", "~> 13.0"
|
9
13
|
|
10
14
|
gem "rspec", "~> 3.0"
|
11
15
|
|
12
16
|
gem "rubocop", "~> 1.21"
|
17
|
+
gem "rubocop-rake"
|
18
|
+
gem "rubocop-rspec"
|
13
19
|
|
14
20
|
gem "webmock", "~> 3.4"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
defra_ruby_govpay (0.
|
4
|
+
defra_ruby_govpay (0.2.2)
|
5
5
|
rest-client (~> 2.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -10,8 +10,14 @@ GEM
|
|
10
10
|
addressable (2.8.5)
|
11
11
|
public_suffix (>= 2.0.2, < 6.0)
|
12
12
|
ast (2.4.2)
|
13
|
+
byebug (11.1.3)
|
13
14
|
crack (0.4.5)
|
14
15
|
rexml
|
16
|
+
defra_ruby_style (0.4.0)
|
17
|
+
rubocop (>= 1.0, < 2.0)
|
18
|
+
rubocop-factory_bot
|
19
|
+
rubocop-rake
|
20
|
+
rubocop-rspec
|
15
21
|
diff-lcs (1.5.0)
|
16
22
|
domain_name (0.5.20190701)
|
17
23
|
unf (>= 0.0.5, < 1.0.0)
|
@@ -26,20 +32,20 @@ GEM
|
|
26
32
|
mime-types-data (3.2023.0808)
|
27
33
|
netrc (0.11.0)
|
28
34
|
parallel (1.23.0)
|
29
|
-
parser (3.2.2.
|
35
|
+
parser (3.2.2.4)
|
30
36
|
ast (~> 2.4.1)
|
31
37
|
racc
|
32
38
|
public_suffix (5.0.3)
|
33
|
-
racc (1.7.
|
39
|
+
racc (1.7.2)
|
34
40
|
rainbow (3.1.1)
|
35
41
|
rake (13.0.6)
|
36
|
-
regexp_parser (2.8.
|
42
|
+
regexp_parser (2.8.2)
|
37
43
|
rest-client (2.1.0)
|
38
44
|
http-accept (>= 1.7.0, < 2.0)
|
39
45
|
http-cookie (>= 1.0.2, < 2.0)
|
40
46
|
mime-types (>= 1.16, < 4.0)
|
41
47
|
netrc (~> 0.8)
|
42
|
-
rexml (3.2.
|
48
|
+
rexml (3.2.6)
|
43
49
|
rspec (3.12.0)
|
44
50
|
rspec-core (~> 3.12.0)
|
45
51
|
rspec-expectations (~> 3.12.0)
|
@@ -53,38 +59,53 @@ GEM
|
|
53
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
54
60
|
rspec-support (~> 3.12.0)
|
55
61
|
rspec-support (3.12.1)
|
56
|
-
rubocop (1.
|
62
|
+
rubocop (1.57.2)
|
57
63
|
json (~> 2.3)
|
58
64
|
language_server-protocol (>= 3.17.0)
|
59
65
|
parallel (~> 1.10)
|
60
|
-
parser (>= 3.2.2.
|
66
|
+
parser (>= 3.2.2.4)
|
61
67
|
rainbow (>= 2.2.2, < 4.0)
|
62
68
|
regexp_parser (>= 1.8, < 3.0)
|
63
69
|
rexml (>= 3.2.5, < 4.0)
|
64
|
-
rubocop-ast (>= 1.28.
|
70
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
65
71
|
ruby-progressbar (~> 1.7)
|
66
72
|
unicode-display_width (>= 2.4.0, < 3.0)
|
67
|
-
rubocop-ast (1.
|
73
|
+
rubocop-ast (1.30.0)
|
68
74
|
parser (>= 3.2.1.0)
|
75
|
+
rubocop-capybara (2.19.0)
|
76
|
+
rubocop (~> 1.41)
|
77
|
+
rubocop-factory_bot (2.24.0)
|
78
|
+
rubocop (~> 1.33)
|
79
|
+
rubocop-rake (0.6.0)
|
80
|
+
rubocop (~> 1.0)
|
81
|
+
rubocop-rspec (2.25.0)
|
82
|
+
rubocop (~> 1.40)
|
83
|
+
rubocop-capybara (~> 2.17)
|
84
|
+
rubocop-factory_bot (~> 2.22)
|
69
85
|
ruby-progressbar (1.13.0)
|
70
86
|
unf (0.1.4)
|
71
87
|
unf_ext
|
72
88
|
unf_ext (0.0.8.2)
|
73
|
-
unicode-display_width (2.
|
89
|
+
unicode-display_width (2.5.0)
|
74
90
|
webmock (3.19.1)
|
75
91
|
addressable (>= 2.8.0)
|
76
92
|
crack (>= 0.3.2)
|
77
93
|
hashdiff (>= 0.4.0, < 2.0.0)
|
78
94
|
|
79
95
|
PLATFORMS
|
96
|
+
x86_64-darwin-21
|
80
97
|
x86_64-darwin-22
|
81
98
|
|
82
99
|
DEPENDENCIES
|
100
|
+
byebug
|
83
101
|
defra_ruby_govpay!
|
102
|
+
defra_ruby_style (~> 0.4)
|
84
103
|
rake (~> 13.0)
|
85
104
|
rspec (~> 3.0)
|
86
105
|
rubocop (~> 1.21)
|
106
|
+
rubocop-rake
|
107
|
+
rubocop-rspec
|
87
108
|
webmock (~> 3.4)
|
88
109
|
|
89
110
|
BUNDLED WITH
|
90
|
-
2.4.
|
111
|
+
2.4.13
|
data/defra_ruby_govpay.gemspec
CHANGED
@@ -12,14 +12,15 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "This gem abstracts the Govpay integration code, facilitating " \
|
13
13
|
"integration within defra ruby applications."
|
14
14
|
spec.homepage = "https://github.com/DEFRA/defra-ruby-govpay"
|
15
|
-
spec.required_ruby_version = ">= 2.
|
15
|
+
spec.required_ruby_version = ">= 3.2.0"
|
16
16
|
|
17
17
|
spec.metadata["source_code_uri"] = "https://github.com/DEFRA/defra-ruby-govpay"
|
18
18
|
|
19
19
|
spec.add_dependency "rest-client", "~> 2.1"
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.files = Dir.chdir(File.expand_path(
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
23
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
24
|
end
|
25
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
25
26
|
end
|
@@ -22,38 +22,41 @@ module DefraRubyGovpay
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def send_request(method:, path:, params: nil, is_moto: false)
|
25
|
-
|
25
|
+
@is_moto = is_moto
|
26
|
+
DefraRubyGovpay.logger.debug build_log_message(method, path, params)
|
26
27
|
|
27
28
|
begin
|
28
|
-
response = execute_request(method, path, params
|
29
|
-
|
29
|
+
response = execute_request(method, path, params)
|
30
|
+
DefraRubyGovpay.logger.debug "Received response from Govpay: #{response}"
|
30
31
|
response
|
31
|
-
rescue StandardError =>
|
32
|
-
handle_error(
|
32
|
+
rescue StandardError => e
|
33
|
+
handle_error(e, method, path, params)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
private
|
37
38
|
|
38
|
-
def build_log_message(method, path, params
|
39
|
-
"#{self.class} sending #{method} request to govpay (#{path}), params: #{params}, moto: #{is_moto}"
|
39
|
+
def build_log_message(method, path, params)
|
40
|
+
"#{self.class} sending #{method} request to govpay (#{path}), params: #{params}, moto: #{@is_moto}, " \
|
41
|
+
"govpay API token ending \"#{bearer_token[-5..]}\""
|
40
42
|
end
|
41
43
|
|
42
|
-
def execute_request(method, path, params
|
44
|
+
def execute_request(method, path, params)
|
43
45
|
RestClient::Request.execute(
|
44
46
|
method: method,
|
45
47
|
url: url(path),
|
46
48
|
payload: payload(params),
|
47
49
|
headers: {
|
48
|
-
"Authorization" => "Bearer #{bearer_token
|
50
|
+
"Authorization" => "Bearer #{bearer_token}",
|
49
51
|
"Content-Type" => "application/json"
|
50
52
|
}
|
51
53
|
)
|
52
54
|
end
|
53
55
|
|
54
56
|
def handle_error(error, method, path, params)
|
55
|
-
error_message = "Error sending request to govpay (#{method} #{path}, params: #{params})
|
56
|
-
|
57
|
+
error_message = "Error sending request to govpay (#{method} #{path}, params: #{params}), " \
|
58
|
+
"response body: #{error.response&.body}: #{error}"
|
59
|
+
DefraRubyGovpay.logger.error error_message
|
57
60
|
raise GovpayApiError, error_message
|
58
61
|
end
|
59
62
|
|
@@ -61,10 +64,12 @@ module DefraRubyGovpay
|
|
61
64
|
"#{@config.govpay_url}#{path}"
|
62
65
|
end
|
63
66
|
|
64
|
-
def bearer_token
|
65
|
-
|
66
|
-
|
67
|
-
|
67
|
+
def bearer_token
|
68
|
+
@bearer_token ||= if @is_back_office
|
69
|
+
@is_moto ? @back_office_token : @front_office_token
|
70
|
+
else
|
71
|
+
@front_office_token
|
72
|
+
end
|
68
73
|
end
|
69
74
|
|
70
75
|
def payload(params)
|
data/lib/defra_ruby_govpay.rb
CHANGED
@@ -20,4 +20,13 @@ module DefraRubyGovpay
|
|
20
20
|
self.configuration ||= Configuration.new
|
21
21
|
yield(configuration)
|
22
22
|
end
|
23
|
+
|
24
|
+
# Use DefraRubyGovpay.logger if it exists, else use a simple console logger
|
25
|
+
def self.logger
|
26
|
+
@logger ||= defined?(Rails) ? Rails.logger : Logger.new($stdout)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.logger=(logger)
|
30
|
+
@logger = logger
|
31
|
+
end
|
23
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defra_ruby_govpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerome Pratt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -32,9 +32,12 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
+
- ".github/dependabot.yml"
|
35
36
|
- ".gitignore"
|
36
37
|
- ".rspec"
|
37
38
|
- ".rubocop.yml"
|
39
|
+
- ".rubocop_todo.yml"
|
40
|
+
- ".ruby-version"
|
38
41
|
- CHANGELOG.md
|
39
42
|
- Gemfile
|
40
43
|
- Gemfile.lock
|
@@ -56,6 +59,7 @@ homepage: https://github.com/DEFRA/defra-ruby-govpay
|
|
56
59
|
licenses: []
|
57
60
|
metadata:
|
58
61
|
source_code_uri: https://github.com/DEFRA/defra-ruby-govpay
|
62
|
+
rubygems_mfa_required: 'true'
|
59
63
|
post_install_message:
|
60
64
|
rdoc_options: []
|
61
65
|
require_paths:
|
@@ -64,14 +68,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
68
|
requirements:
|
65
69
|
- - ">="
|
66
70
|
- !ruby/object:Gem::Version
|
67
|
-
version: 2.
|
71
|
+
version: 3.2.0
|
68
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
73
|
requirements:
|
70
74
|
- - ">="
|
71
75
|
- !ruby/object:Gem::Version
|
72
76
|
version: '0'
|
73
77
|
requirements: []
|
74
|
-
rubygems_version: 3.
|
78
|
+
rubygems_version: 3.4.10
|
75
79
|
signing_key:
|
76
80
|
specification_version: 4
|
77
81
|
summary: A Ruby gem facilitating integration with Govpay services in ruby applications.
|