postcode_validation 0.0.1 → 0.0.2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 969757f1b9dadfcc8c8558149da021ca01ac30f1
|
4
|
+
data.tar.gz: 74e813efac7b28877b0b1ba5c63e4d78709eb77e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bb9d8016d76ae1fe87201a5e7bd702aadf2b71feee1f88ea36c740e8b4043ac53d7e653961883c0eaf493848cf1f6a8369b1ef26e2ee0f0c2462bd71a3bb24f
|
7
|
+
data.tar.gz: 1e1cf7282b35ce418aa6c1b496c0471b5518ae164a6d6bc64ab59ab83dac41b3e3bb7390471a579402760541987b85fe775016c9b6f0a1b6c768b364ce536d0c
|
@@ -1,4 +1,10 @@
|
|
1
1
|
module PostcodeValidation
|
2
|
+
class RailsLogger
|
3
|
+
def error(error)
|
4
|
+
Rails.logger.tagged('Remote-Validate-Address') { Rails.logger.error(error.message) }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
2
8
|
module SpreeOrderPostcodeValid
|
3
9
|
extend ActiveSupport::Concern
|
4
10
|
|
@@ -26,7 +32,8 @@ module PostcodeValidation
|
|
26
32
|
|
27
33
|
def use_case
|
28
34
|
PostcodeValidation::UseCase::ValidateAddress.new(
|
29
|
-
address_match_gateway: PostcodeValidation::Gateway::PCAPotentialAddressMatch.new
|
35
|
+
address_match_gateway: PostcodeValidation::Gateway::PCAPotentialAddressMatch.new,
|
36
|
+
logger: PostcodeValidation::RailsLogger.new
|
30
37
|
)
|
31
38
|
end
|
32
39
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module PostcodeValidation
|
2
2
|
module UseCase
|
3
3
|
class ValidateAddress
|
4
|
-
def initialize(address_match_gateway:)
|
4
|
+
def initialize(address_match_gateway:, logger: nil)
|
5
5
|
@address_match_gateway = address_match_gateway
|
6
|
+
@logger = logger
|
6
7
|
end
|
7
8
|
|
8
9
|
def execute(postcode:, country:)
|
@@ -16,9 +17,11 @@ module PostcodeValidation
|
|
16
17
|
|
17
18
|
private
|
18
19
|
|
19
|
-
attr_reader :address_match_gateway, :postcode, :country
|
20
|
+
attr_reader :address_match_gateway, :logger, :postcode, :country
|
20
21
|
|
21
|
-
def on_error(e)
|
22
|
+
def on_error(e)
|
23
|
+
logger.error(e) unless logger.nil?
|
24
|
+
end
|
22
25
|
|
23
26
|
def valid_postcode?
|
24
27
|
address = first_potential_address
|