defra_ruby_govpay 0.2.4 → 0.2.5
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 +4 -4
- data/CHANGELOG.md +10 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/defra_ruby_govpay/api.rb +6 -5
- data/lib/defra_ruby_govpay/configuration.rb +1 -1
- data/lib/defra_ruby_govpay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50914b4891648701b6e1d7e553820f3938c232af1e52666ddc99c60fc12e22e6
|
4
|
+
data.tar.gz: b893ef2af65fadf32e9dc5e437a4303f9f538e597751a976378046d87410ae38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6518bb755f204d0e71c717b7c4e4ee1c1cc325596fb43dff3b8d034488d6489f4729d7e798e93ca3d2d186d57f19b02ab1159a38ba68a14a4090affc579cced3
|
7
|
+
data.tar.gz: 71e3faefb42675a382fe7eb872ab5f08e96843d1fe54a46770c2f75e986fa0950837d1d69e415670014bb0bd46e44245fbfcd27fa6a74d33843a29ea0ab3914b
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,15 @@
|
|
2
2
|
|
3
3
|
## [Unreleased](https://github.com/DEFRA/defra-ruby-govpay/tree/HEAD)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.
|
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)
|
6
14
|
|
7
15
|
**Fixed bugs:**
|
8
16
|
|
@@ -10,6 +18,7 @@
|
|
10
18
|
|
11
19
|
**Merged pull requests:**
|
12
20
|
|
21
|
+
- Version 0.2.4 [\#10](https://github.com/DEFRA/defra-ruby-govpay/pull/10) ([PaulDoyle-DEFRA](https://github.com/PaulDoyle-DEFRA))
|
13
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))
|
14
23
|
|
15
24
|
## [v0.2.3](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.2.3) (2023-11-07)
|
data/Gemfile.lock
CHANGED
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
|
-
|
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")
|
@@ -16,6 +17,10 @@ module DefraRubyGovpay
|
|
16
17
|
|
17
18
|
class API
|
18
19
|
|
20
|
+
def initialize(host_is_back_office:)
|
21
|
+
@host_is_back_office = host_is_back_office
|
22
|
+
end
|
23
|
+
|
19
24
|
def send_request(method:, path:, params: nil, is_moto: false)
|
20
25
|
@is_moto = is_moto
|
21
26
|
DefraRubyGovpay.logger.debug build_log_message(method, path, params)
|
@@ -63,10 +68,6 @@ module DefraRubyGovpay
|
|
63
68
|
"#{govpay_url}#{path}"
|
64
69
|
end
|
65
70
|
|
66
|
-
def back_office_app
|
67
|
-
@back_office_app ||= DefraRubyGovpay.configuration.host_is_back_office
|
68
|
-
end
|
69
|
-
|
70
71
|
def front_office_token
|
71
72
|
@front_office_token ||= DefraRubyGovpay.configuration.govpay_front_office_api_token
|
72
73
|
end
|
@@ -76,7 +77,7 @@ module DefraRubyGovpay
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def bearer_token
|
79
|
-
if
|
80
|
+
if @host_is_back_office
|
80
81
|
@is_moto ? back_office_token : front_office_token
|
81
82
|
else
|
82
83
|
front_office_token
|
@@ -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
|
8
|
+
attr_accessor :govpay_url, :govpay_front_office_api_token, :govpay_back_office_api_token
|
9
9
|
end
|
10
10
|
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.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-
|
11
|
+
date: 2023-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|