international_postcode_api 0.1.0 → 0.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9af275bfc146cecf97764f2bf81ed5af66d535ad1dbce81a099393b9c5eb637
|
4
|
+
data.tar.gz: f4a6004acb47d1932f0dd1585e24a16374cfbf716b93f6860c6b353ab382c83c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 455a88fa756f1389171f60b0c29f7ae17e1124bd3bd79e258ea449e45a5f2187a08eddf647661e465b957b23552286c26a2b35d9aa11d0c8375399094fff0679
|
7
|
+
data.tar.gz: 9f8e044f10d919c7416e0d049a020298841eab4bf5120e3ac801c562fbfbf37b17e90ad702a30b7a163412778f1092df941646a8a7f9ed36b7a8ced7d7df16cb
|
@@ -4,7 +4,7 @@ require 'json'
|
|
4
4
|
module InternationalPostcodeApi
|
5
5
|
class Client
|
6
6
|
def self.autocomplete(term, context = 'nld')
|
7
|
-
uri = generate_uri(:autocomplete, context, term)
|
7
|
+
uri = generate_uri(:autocomplete, context.downcase, term)
|
8
8
|
fetch(uri)
|
9
9
|
end
|
10
10
|
|
@@ -23,16 +23,16 @@ module InternationalPostcodeApi
|
|
23
23
|
fetch(uri)
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.postcode(postcode, house_number, lang = '
|
27
|
-
if lang == '
|
26
|
+
def self.postcode(postcode, house_number, lang = 'NLD')
|
27
|
+
if lang == 'NLD' && InternationalPostcodeApi.configuration.dynamic_endpoints
|
28
28
|
response = dutch_postcode(postcode, house_number)
|
29
29
|
return { street: response.dig('street'), city: response.dig('city') }
|
30
30
|
else
|
31
|
-
query = autocomplete
|
31
|
+
query = autocomplete("#{postcode} #{house_number}", lang)
|
32
32
|
context = query['matches'][0].dig('context')
|
33
33
|
if context
|
34
34
|
response = details(context)
|
35
|
-
return { street: response.dig('address')
|
35
|
+
return { street: response.dig('address')&.dig('street'), city: response.dig('address')&.dig('locality')}
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: international_postcode_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis de Vulder
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02
|
12
|
-
dependencies:
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: A ruby wrapper for the api.postcode.eu endpoints.
|
14
28
|
email:
|
15
29
|
- dennisdevulder@gmail.com
|