costa_rica_address_utils 0.1.02 → 0.2.0

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: 6d7671d4fcae7c2b653dfc0e0a1c21efb653c6a50a2b23d156ec05b82780b4ef
4
- data.tar.gz: 4302d34bd690087a8297e306d35358f0663191f80312dbd11e8a80624ef9a495
3
+ metadata.gz: 04debe8d04f23737c37f0245a89db018f2cc1cad8047513ed6efdc25f264b0e9
4
+ data.tar.gz: 86e9e38618a9f539d1ce4150f7435cccc64e498bab4471f1708c66a89b60ae8f
5
5
  SHA512:
6
- metadata.gz: 330f3a0b91cf8259c330b6cc27dd2b03d08474b3d8bdec8b73a60e8ff6d52cc9a34b2e803311a228654fe175b894723f1655cad50e929740ab4df8e22c7507e8
7
- data.tar.gz: 07f8abbfa8bd4e1d78f0f9cade46534ff517d8f870545c6dcb0066542562d5a369de9db6eb02d03d81f12e7af0e34d87afae1cc2951139324cfb394045cfce8f
6
+ metadata.gz: f56595def1fa147c29b29c381b5062b266bbe68fbd8296618553aea44f72f2eb87d615037bed90603577ef0832a61714a068756d3c92ff82bc90bed31698c311
7
+ data.tar.gz: a09b8dce9a653949d4c9f6253dee360d0368c4cc80d8020783bbf849dbc8e8b5d8a58978491ee39c397c19c80ed04490caee6b7f14896bca0047e14c12631ebe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- costa_rica_address_utils (0.1.02)
4
+ costa_rica_address_utils (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CostaRicaAddressUtils
4
- VERSION = "0.1.02"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -35,6 +35,28 @@ module CostaRicaAddressUtils
35
35
  }
36
36
  end
37
37
 
38
+ # Get one address information from a zip code
39
+ def self.fetch_address_from_zip(zip_code)
40
+ raise "Zip code provided #{zip_code} is invalid. Must be a 5 digits number" if !zip_code || zip_code.to_s.length != 5
41
+ zip_code_s = zip_code.to_s
42
+ LOCATIONS_DATASET.each do |province, province_data|
43
+ province_data["cantons"].each do |canton, canton_data|
44
+ canton_data["districts"].each do |district, district_data|
45
+ if district_data["zip_code"] == zip_code_s
46
+ return {
47
+ province: province,
48
+ canton: canton,
49
+ district: district,
50
+ zip: zip_code_s,
51
+ }
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ return nil
58
+ end
59
+
38
60
  def self.address_valid?(province:, canton:, district:)
39
61
  is_valid = true
40
62
  begin
@@ -47,7 +69,6 @@ module CostaRicaAddressUtils
47
69
  return is_valid
48
70
  end
49
71
 
50
-
51
72
  # Build a Costa Rica address from an address of an external provider (Shopify, Brightpearl, etc)
52
73
  # https://shopify.dev/api/admin-graphql/2022-10/objects/mailingaddress
53
74
  # https://api-docs.brightpearl.com/contact/postal-address/get.html
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: costa_rica_address_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.02
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vicvans20
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-15 00:00:00.000000000 Z
11
+ date: 2024-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.2.32
72
+ rubygems_version: 3.5.3
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Utils lib to work with Costa Rica addresses.