defra_ruby_govpay 0.2.3 → 0.2.5

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: ba54aba1349d8a9f7f7e7091775e4687b69ba8b3437a980fd0f355d8648db453
4
- data.tar.gz: ea4115db350c21ba48e867aebbeb4b96791aa89852ca41144b0065cb07bc19df
3
+ metadata.gz: 50914b4891648701b6e1d7e553820f3938c232af1e52666ddc99c60fc12e22e6
4
+ data.tar.gz: b893ef2af65fadf32e9dc5e437a4303f9f538e597751a976378046d87410ae38
5
5
  SHA512:
6
- metadata.gz: 5d1da26faac8cd47483c60a8f66c32b405654978e4322b3258812009a336ef6409ddd68a763248070e7dd5b08f95e658d25710b283a2be0425bb877ea6ab0e70
7
- data.tar.gz: 9d64fc44573910e2aedd3290065d5d0f3743b12218af85466f2b3bfc8ca7fc5c99636456b59e99b07de2250ddb9a82055a02e34b29121693f6a2b574165370d7
6
+ metadata.gz: 6518bb755f204d0e71c717b7c4e4ee1c1cc325596fb43dff3b8d034488d6489f4729d7e798e93ca3d2d186d57f19b02ab1159a38ba68a14a4090affc579cced3
7
+ data.tar.gz: 71e3faefb42675a382fe7eb872ab5f08e96843d1fe54a46770c2f75e986fa0950837d1d69e415670014bb0bd46e44245fbfcd27fa6a74d33843a29ea0ab3914b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,64 @@
1
- ## [Unreleased]
1
+ # Changelog
2
2
 
3
- ## [0.1.0] - 2023-09-06
3
+ ## [Unreleased](https://github.com/DEFRA/defra-ruby-govpay/tree/HEAD)
4
4
 
5
- - Initial release
5
+ [Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.4...HEAD)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - fix host\_is\_back\_office [\#11](https://github.com/DEFRA/defra-ruby-govpay/pull/11) ([PaulDoyle-DEFRA](https://github.com/PaulDoyle-DEFRA))
10
+
11
+ ## [v0.2.4](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.2.4) (2023-11-10)
12
+
13
+ [Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.3...v0.2.4)
14
+
15
+ **Fixed bugs:**
16
+
17
+ - fix DefraRubyGovpay config [\#9](https://github.com/DEFRA/defra-ruby-govpay/pull/9) ([PaulDoyle-DEFRA](https://github.com/PaulDoyle-DEFRA))
18
+
19
+ **Merged pull requests:**
20
+
21
+ - Version 0.2.4 [\#10](https://github.com/DEFRA/defra-ruby-govpay/pull/10) ([PaulDoyle-DEFRA](https://github.com/PaulDoyle-DEFRA))
22
+ - Bump rake from 13.0.6 to 13.1.0 [\#6](https://github.com/DEFRA/defra-ruby-govpay/pull/6) ([dependabot[bot]](https://github.com/apps/dependabot))
23
+
24
+ ## [v0.2.3](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.2.3) (2023-11-07)
25
+
26
+ [Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.2...v0.2.3)
27
+
28
+ **Implemented enhancements:**
29
+
30
+ - Chore/ruby 2769 enhance govpay logging [\#8](https://github.com/DEFRA/defra-ruby-govpay/pull/8) ([PaulDoyle-DEFRA](https://github.com/PaulDoyle-DEFRA))
31
+
32
+ ## [v0.2.2](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.2.2) (2023-11-06)
33
+
34
+ [Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.1...v0.2.2)
35
+
36
+ **Implemented enhancements:**
37
+
38
+ - gem version 0.2.2 [\#7](https://github.com/DEFRA/defra-ruby-govpay/pull/7) ([PaulDoyle-DEFRA](https://github.com/PaulDoyle-DEFRA))
39
+ - Chore/ruby 2769 enhance govpay logging [\#5](https://github.com/DEFRA/defra-ruby-govpay/pull/5) ([PaulDoyle-DEFRA](https://github.com/PaulDoyle-DEFRA))
40
+
41
+ ## [v0.2.1](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.2.1) (2023-10-03)
42
+
43
+ [Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.0...v0.2.1)
44
+
45
+ ## [v0.2.0](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.2.0) (2023-09-26)
46
+
47
+ [Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.1.2...v0.2.0)
48
+
49
+ ## [v0.1.2](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.1.2) (2023-09-18)
50
+
51
+ [Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.1.1...v0.1.2)
52
+
53
+ **Merged pull requests:**
54
+
55
+ - release/v0.1.2 [\#4](https://github.com/DEFRA/defra-ruby-govpay/pull/4) ([jjromeo](https://github.com/jjromeo))
56
+ - gem version 0.1.0 [\#1](https://github.com/DEFRA/defra-ruby-govpay/pull/1) ([jjromeo](https://github.com/jjromeo))
57
+
58
+ ## [v0.1.1](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.1.1) (2023-09-18)
59
+
60
+ [Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/1bd9ccaffdb51137f980d553336b5dddf2f4901d...v0.1.1)
61
+
62
+
63
+
64
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile CHANGED
@@ -7,6 +7,8 @@ gemspec
7
7
 
8
8
  gem "byebug"
9
9
 
10
+ gem "github_changelog_generator"
11
+
10
12
  gem "defra_ruby_style", "~> 0.4"
11
13
 
12
14
  gem "rake", "~> 13.0"
data/Gemfile.lock CHANGED
@@ -1,16 +1,53 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- defra_ruby_govpay (0.2.2)
4
+ defra_ruby_govpay (0.2.5)
5
5
  rest-client (~> 2.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ activesupport (7.1.1)
11
+ base64
12
+ bigdecimal
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ connection_pool (>= 2.2.5)
15
+ drb
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ mutex_m
19
+ tzinfo (~> 2.0)
10
20
  addressable (2.8.5)
11
21
  public_suffix (>= 2.0.2, < 6.0)
12
22
  ast (2.4.2)
23
+ async (2.6.5)
24
+ console (~> 1.10)
25
+ fiber-annotation
26
+ io-event (~> 1.1)
27
+ timers (~> 4.1)
28
+ async-http (0.61.0)
29
+ async (>= 1.25)
30
+ async-io (>= 1.28)
31
+ async-pool (>= 0.2)
32
+ protocol-http (~> 0.25.0)
33
+ protocol-http1 (~> 0.16.0)
34
+ protocol-http2 (~> 0.15.0)
35
+ traces (>= 0.10.0)
36
+ async-http-faraday (0.12.0)
37
+ async-http (~> 0.42)
38
+ faraday
39
+ async-io (1.36.1)
40
+ async
41
+ async-pool (0.4.0)
42
+ async (>= 1.25)
43
+ base64 (0.1.1)
44
+ bigdecimal (3.1.4)
13
45
  byebug (11.1.3)
46
+ concurrent-ruby (1.2.2)
47
+ connection_pool (2.4.1)
48
+ console (1.23.2)
49
+ fiber-annotation
50
+ fiber-local
14
51
  crack (0.4.5)
15
52
  rexml
16
53
  defra_ruby_style (0.4.0)
@@ -21,24 +58,60 @@ GEM
21
58
  diff-lcs (1.5.0)
22
59
  domain_name (0.5.20190701)
23
60
  unf (>= 0.0.5, < 1.0.0)
61
+ drb (2.1.1)
62
+ ruby2_keywords
63
+ faraday (2.7.11)
64
+ base64
65
+ faraday-net_http (>= 2.0, < 3.1)
66
+ ruby2_keywords (>= 0.0.4)
67
+ faraday-http-cache (2.5.0)
68
+ faraday (>= 0.8)
69
+ faraday-net_http (3.0.2)
70
+ fiber-annotation (0.2.0)
71
+ fiber-local (1.0.0)
72
+ github_changelog_generator (1.16.4)
73
+ activesupport
74
+ async (>= 1.25.0)
75
+ async-http-faraday
76
+ faraday-http-cache
77
+ multi_json
78
+ octokit (~> 4.6)
79
+ rainbow (>= 2.2.1)
80
+ rake (>= 10.0)
24
81
  hashdiff (1.0.1)
25
82
  http-accept (1.7.0)
26
83
  http-cookie (1.0.5)
27
84
  domain_name (~> 0.5)
85
+ i18n (1.14.1)
86
+ concurrent-ruby (~> 1.0)
87
+ io-event (1.3.3)
28
88
  json (2.6.3)
29
89
  language_server-protocol (3.17.0.3)
30
90
  mime-types (3.5.1)
31
91
  mime-types-data (~> 3.2015)
32
92
  mime-types-data (3.2023.0808)
93
+ minitest (5.20.0)
94
+ multi_json (1.15.0)
95
+ mutex_m (0.1.2)
33
96
  netrc (0.11.0)
97
+ octokit (4.25.1)
98
+ faraday (>= 1, < 3)
99
+ sawyer (~> 0.9)
34
100
  parallel (1.23.0)
35
101
  parser (3.2.2.4)
36
102
  ast (~> 2.4.1)
37
103
  racc
104
+ protocol-hpack (1.4.2)
105
+ protocol-http (0.25.0)
106
+ protocol-http1 (0.16.0)
107
+ protocol-http (~> 0.22)
108
+ protocol-http2 (0.15.1)
109
+ protocol-hpack (~> 1.4)
110
+ protocol-http (~> 0.18)
38
111
  public_suffix (5.0.3)
39
112
  racc (1.7.2)
40
113
  rainbow (3.1.1)
41
- rake (13.0.6)
114
+ rake (13.1.0)
42
115
  regexp_parser (2.8.2)
43
116
  rest-client (2.1.0)
44
117
  http-accept (>= 1.7.0, < 2.0)
@@ -83,6 +156,14 @@ GEM
83
156
  rubocop-capybara (~> 2.17)
84
157
  rubocop-factory_bot (~> 2.22)
85
158
  ruby-progressbar (1.13.0)
159
+ ruby2_keywords (0.0.5)
160
+ sawyer (0.9.2)
161
+ addressable (>= 2.3.5)
162
+ faraday (>= 0.17.3, < 3)
163
+ timers (4.3.5)
164
+ traces (0.11.1)
165
+ tzinfo (2.0.6)
166
+ concurrent-ruby (~> 1.0)
86
167
  unf (0.1.4)
87
168
  unf_ext
88
169
  unf_ext (0.0.8.2)
@@ -95,11 +176,13 @@ GEM
95
176
  PLATFORMS
96
177
  x86_64-darwin-21
97
178
  x86_64-darwin-22
179
+ x86_64-linux
98
180
 
99
181
  DEPENDENCIES
100
182
  byebug
101
183
  defra_ruby_govpay!
102
184
  defra_ruby_style (~> 0.4)
185
+ github_changelog_generator
103
186
  rake (~> 13.0)
104
187
  rspec (~> 3.0)
105
188
  rubocop (~> 1.21)
data/README.md CHANGED
@@ -36,7 +36,6 @@ DefraRubyGovpay.configure do |config|
36
36
  config.govpay_url = 'https://your-govpay-url.com'
37
37
  config.govpay_front_office_api_token = 'your-front-office-token'
38
38
  config.govpay_back_office_api_token = 'your-back-office-token'
39
- config.host_is_back_office = false
40
39
  # ... any other configurations
41
40
  end
42
41
  ```
@@ -49,9 +48,10 @@ Here is a detailed guide on how to use the various components of the `defra-ruby
49
48
 
50
49
  You can send requests to the GovPay API using the `send_request` method. Here's an example:
51
50
 
52
- after having followed the configuration step:
51
+ After having followed the configuration step, create an API instance. This has a mandatory parameter to indicate
52
+ whether the host is a back-office application, in which case any payments it creates will be flagged as MOTO.
53
53
  ```ruby
54
- govpay_api = DefraRubyGovpay::API.new
54
+ govpay_api = DefraRubyGovpay::API.new(host_is_back_office: false)
55
55
 
56
56
  begin
57
57
  response = govpay_api.send_request(
@@ -3,6 +3,7 @@
3
3
  require "rest-client"
4
4
 
5
5
  module DefraRubyGovpay
6
+
6
7
  # Custom error class to handle Govpay API errors
7
8
  class GovpayApiError < StandardError
8
9
  def initialize(msg = "Govpay API error")
@@ -13,12 +14,11 @@ module DefraRubyGovpay
13
14
  # The API class is responsible for making requests to the Govpay API.
14
15
  # It handles the construction of request URLs, headers, and payload,
15
16
  # and also deals with any errors that occur during the API request.
17
+
16
18
  class API
17
- def initialize(config = DefraRubyGovpay.configuration)
18
- @config = config
19
- @is_back_office = config.host_is_back_office
20
- @front_office_token = config.govpay_front_office_api_token
21
- @back_office_token = config.govpay_back_office_api_token
19
+
20
+ def initialize(host_is_back_office:)
21
+ @host_is_back_office = host_is_back_office
22
22
  end
23
23
 
24
24
  def send_request(method:, path:, params: nil, is_moto: false)
@@ -60,16 +60,28 @@ module DefraRubyGovpay
60
60
  raise GovpayApiError, error_message
61
61
  end
62
62
 
63
+ def govpay_url
64
+ @govpay_url ||= DefraRubyGovpay.configuration.govpay_url
65
+ end
66
+
63
67
  def url(path)
64
- "#{@config.govpay_url}#{path}"
68
+ "#{govpay_url}#{path}"
69
+ end
70
+
71
+ def front_office_token
72
+ @front_office_token ||= DefraRubyGovpay.configuration.govpay_front_office_api_token
73
+ end
74
+
75
+ def back_office_token
76
+ @back_office_token ||= DefraRubyGovpay.configuration.govpay_back_office_api_token
65
77
  end
66
78
 
67
79
  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
80
+ if @host_is_back_office
81
+ @is_moto ? back_office_token : front_office_token
82
+ else
83
+ front_office_token
84
+ end
73
85
  end
74
86
 
75
87
  def payload(params)
@@ -5,6 +5,6 @@ module DefraRubyGovpay
5
5
  # for the DefraRubyGovpay module. You can set different options like
6
6
  # API tokens, host preferences, and other necessary configurations here.
7
7
  class Configuration
8
- attr_accessor :govpay_url, :govpay_front_office_api_token, :govpay_back_office_api_token, :host_is_back_office
8
+ attr_accessor :govpay_url, :govpay_front_office_api_token, :govpay_back_office_api_token
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DefraRubyGovpay
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  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.3
4
+ version: 0.2.5
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-07 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client