defra_ruby_govpay 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2decfa9d321b4886b2c4aa340730cc04e315318a94df1c1b31ecc4219f1efe1e
4
- data.tar.gz: 5dc7af54e47bf042414ff1f730eb6d2f2444e35c917d68ecca24f3c251116a1a
3
+ metadata.gz: ba54aba1349d8a9f7f7e7091775e4687b69ba8b3437a980fd0f355d8648db453
4
+ data.tar.gz: ea4115db350c21ba48e867aebbeb4b96791aa89852ca41144b0065cb07bc19df
5
5
  SHA512:
6
- metadata.gz: 7ebef882ca7c22536dd057a6b9117055d0dfee7f82208b2d65f57d142a26e7650941da1c8c3fbc8e4f91eac345ae4fa2e0d9da264d36a6c0494443e7709b4593
7
- data.tar.gz: 126ae4b0e31d66d9ab9a206174da49bc606a84e58d67c67b71b60c0b8108d6aa02aef3bf246dce20f87e471323127fcc77d007dcf0bddc16cabd56c582622304
6
+ metadata.gz: 5d1da26faac8cd47483c60a8f66c32b405654978e4322b3258812009a336ef6409ddd68a763248070e7dd5b08f95e658d25710b283a2be0425bb877ea6ab0e70
7
+ data.tar.gz: 9d64fc44573910e2aedd3290065d5d0f3743b12218af85466f2b3bfc8ca7fc5c99636456b59e99b07de2250ddb9a82055a02e34b29121693f6a2b574165370d7
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ versioning-strategy: lockfile-only
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  *.gem
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .byebug_history
data/.rubocop.yml CHANGED
@@ -1,17 +1,5 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6
1
+ inherit_from: .rubocop_todo.yml
3
2
 
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
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.1.2)
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.3)
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.1)
39
+ racc (1.7.2)
34
40
  rainbow (3.1.1)
35
41
  rake (13.0.6)
36
- regexp_parser (2.8.1)
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.5)
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.54.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.3)
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.0, < 2.0)
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.29.0)
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.4.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.8
111
+ 2.4.13
@@ -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.6.0"
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('..', __FILE__)) do
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
- Rails.logger.info build_log_message(method, path, params, is_moto)
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, is_moto)
29
- Rails.logger.info "Received response from Govpay: #{response}"
29
+ response = execute_request(method, path, params)
30
+ DefraRubyGovpay.logger.debug "Received response from Govpay: #{response}"
30
31
  response
31
- rescue StandardError => error
32
- handle_error(error, method, path, params)
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, is_moto)
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, is_moto)
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(is_moto)}",
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}): #{error}"
56
- Rails.logger.info error_message
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(is_moto)
65
- return @front_office_token unless @is_back_office
66
-
67
- is_moto ? @back_office_token : @front_office_token
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DefraRubyGovpay
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
@@ -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.1
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-10-03 00:00:00.000000000 Z
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.6.0
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.3.7
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.