postcode_validation 0.0.11 → 0.0.12

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: 1f772bbb1ed5eaa70bcbbe832210d54caee0a70e
4
- data.tar.gz: 185c0f53c06f9558852a613a9f59fb687f053e02
3
+ metadata.gz: 81b7f2c35a2e2a77cb0ba321af57f507b45ab31e
4
+ data.tar.gz: 0c8b61dbb12285f18023a0d10fb7068fb8f55f70
5
5
  SHA512:
6
- metadata.gz: 2e35f4e35e4fd67d697d7bd6e76b99dc230f7fd21a7faae5d8bc188abbdf6db5bccdf332671605f5d81fa5accd32641b6af8bece562fabea7c9784bf7478e8cc
7
- data.tar.gz: acdb21d673474d9e99cb217de6c30946781ee1e0735980667c0e123811784b5ba4ae935f0521e48c9b555c33845fe9999c676ee5d879143a0fd21b809092f1c4
6
+ metadata.gz: f1ecf4638a02a8ff10c3f0dbfbdf29daf5b6950901a918956801063d719c80ffe5b9dd302858359ab4ec50e801717b05c48154354a68ea5aca39b146fb2e4031
7
+ data.tar.gz: 8ab12a39697d09f02b155b9e64cd362e70909754317d07a79beb6b6d2a5ccb82d7dca4c217545f5de94b62547f0c153fa6721fa64ca612a9570b722a91a0170f
@@ -6,9 +6,11 @@ module PostcodeValidation
6
6
  def initialize(address_list_gateway:, logger: nil)
7
7
  @address_list_gateway = address_list_gateway
8
8
  @logger = logger
9
+ @errors = []
9
10
  end
10
11
 
11
12
  def execute(postcode:, country:)
13
+ check_country(country)
12
14
  addresses = matched_addresses(postcode, country)
13
15
 
14
16
  formatted(addresses)
@@ -21,6 +23,8 @@ module PostcodeValidation
21
23
  attr_reader :address_match_gateway, :logger
22
24
 
23
25
  def formatted(addresses)
26
+ return { errors: @errors } unless @errors.empty?
27
+
24
28
  addresses.map do |address|
25
29
  {
26
30
  id: address.id,
@@ -37,6 +41,10 @@ module PostcodeValidation
37
41
  @address_list_gateway.query(search_term: postcode,
38
42
  country: country)
39
43
  end
44
+
45
+ def check_country(country)
46
+ @errors << 'no_country_provided' if country.nil?
47
+ end
40
48
  end
41
49
  end
42
50
  end
@@ -1,3 +1,3 @@
1
1
  module PostcodeValidation
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postcode_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig J. Bass
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-17 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty