egov_utils 1.5.0.alpha16 → 1.5.0.alpha17
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/app/models/egov_utils/address.rb +19 -11
- data/app/services/egov_utils/iszr/find_address_by_aifo.rb +22 -12
- data/app/services/egov_utils/iszr/find_address_by_ico.rb +22 -12
- data/db/migrate/20250413085634_add_text_address_to_addresses.rb +5 -0
- data/lib/egov_utils/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2d9c2f0865a844342b3e80729356354092681e4f680bb90de22e68259258ed2
|
4
|
+
data.tar.gz: 6c47f3787cee7fb3415422500b5591a9fead43ac07b43b3f4a6fa57dde705a5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a006382752a2064a135b8c66df67c022600b67d57b5ea51c29395b65efe0ba86f7ed5afb4682ac7e1f48915df25c426d1726bfde77d5fe8b4920e50993bffb1d
|
7
|
+
data.tar.gz: 4357089c5a0e4bab18a7e3d8481c96c54db580a5742d69ea4b9a59f8b2cb22ca3a361cdfca9fe0f0e1bbffcdf3045e374744580d8ad65902a948579806841513
|
@@ -3,17 +3,21 @@ module EgovUtils
|
|
3
3
|
|
4
4
|
# before_safe :identify_address , if: :changed?
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
with_options unless: :text_address? do
|
7
|
+
validates :street, :city, length: 2..255
|
8
|
+
validates :postcode, numericality: { only_integer: true }
|
9
|
+
with_options if: :in_czech_republic? do
|
10
|
+
validates :district, inclusion: { in: :district_names }
|
11
|
+
validates :region, inclusion: { in: :region_names }
|
12
|
+
end
|
13
|
+
with_options if: -> { !in_czech_republic? } do
|
14
|
+
validates :district, inclusion: { in: :district_names }, allow_nil: true
|
15
|
+
validates :region, inclusion: { in: :region_names }, allow_nil: true
|
16
|
+
end
|
17
|
+
validates :country, inclusion: { in: :country_ids }, allow_nil: true
|
15
18
|
end
|
16
|
-
|
19
|
+
|
20
|
+
before_validation -> { self.country = CZ_ISO_CODE if text_address? }
|
17
21
|
|
18
22
|
District = Struct.new(:id, :name, :region_id)
|
19
23
|
Region = Struct.new(:id, :name)
|
@@ -22,6 +26,10 @@ module EgovUtils
|
|
22
26
|
|
23
27
|
CZ_ISO_CODE = '203'
|
24
28
|
|
29
|
+
def text_address?
|
30
|
+
text_address.present?
|
31
|
+
end
|
32
|
+
|
25
33
|
def self.countries
|
26
34
|
return @countries if @countries
|
27
35
|
require 'csv'
|
@@ -99,7 +107,7 @@ module EgovUtils
|
|
99
107
|
end
|
100
108
|
|
101
109
|
def to_s
|
102
|
-
"#{street} #{number}, #{postcode} #{city}"
|
110
|
+
text_address.presence || "#{street} #{number}, #{postcode} #{city}"
|
103
111
|
end
|
104
112
|
|
105
113
|
def prepare_egon_message(message)
|
@@ -8,18 +8,28 @@ module EgovUtils
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def handle_response!
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
if text_address?
|
12
|
+
EgovUtils::Address.new(
|
13
|
+
text_address: response_body.xpath('//AdresaTextem').text
|
14
|
+
)
|
15
|
+
else
|
16
|
+
EgovUtils::Address.new(
|
17
|
+
street:
|
18
|
+
response_body.xpath('//UliceNazev').text.presence || response_body.xpath('//CastObceNazev').text,
|
19
|
+
house_number: response_body.xpath('//CisloDomovni').text,
|
20
|
+
orientation_number: response_body.xpath('//CisloOrientacni').text,
|
21
|
+
city: response_body.xpath('//ObecNazev').text,
|
22
|
+
postcode: response_body.xpath('//PostaKod').text,
|
23
|
+
egov_identifier: response_body.xpath('//AdresniMistoKod').text,
|
24
|
+
country: 203,
|
25
|
+
district: district.name,
|
26
|
+
region: region.name,
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def text_address?
|
32
|
+
response_body.xpath('//AdresaTextem').text.present?
|
23
33
|
end
|
24
34
|
|
25
35
|
def district
|
@@ -6,18 +6,28 @@ module EgovUtils
|
|
6
6
|
private
|
7
7
|
|
8
8
|
def handle_response!
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
9
|
+
if text_address?
|
10
|
+
EgovUtils::Address.new(
|
11
|
+
text_address: response_body.xpath('//AdresaTextem').text
|
12
|
+
)
|
13
|
+
else
|
14
|
+
EgovUtils::Address.new(
|
15
|
+
street:
|
16
|
+
response_body.xpath('//UliceNazev').text.presence || response_body.xpath('//CastObceNazev').text,
|
17
|
+
house_number: response_body.xpath('//CisloDomovni').text,
|
18
|
+
orientation_number: response_body.xpath('//CisloOrientacni').text,
|
19
|
+
city: response_body.xpath('//ObecNazev').text,
|
20
|
+
postcode: response_body.xpath('//PostaKod').text,
|
21
|
+
egov_identifier: response_body.xpath('//AdresniMistoKod').text,
|
22
|
+
country: 203,
|
23
|
+
district: district.name,
|
24
|
+
region: region.name,
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def text_address?
|
30
|
+
response_body.xpath('//AdresaTextem').text.present?
|
21
31
|
end
|
22
32
|
|
23
33
|
def district
|
data/lib/egov_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egov_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.
|
4
|
+
version: 1.5.0.alpha17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -779,6 +779,7 @@ files:
|
|
779
779
|
- db/migrate/20230427091407_add_fields_to_registration_requests.rb
|
780
780
|
- db/migrate/20231006131159_add_supervisor_assignment_to_registration_requests.rb
|
781
781
|
- db/migrate/20240711130901_add_remote_id_to_people.rb
|
782
|
+
- db/migrate/20250413085634_add_text_address_to_addresses.rb
|
782
783
|
- lib/azahara_schema_currency.rb
|
783
784
|
- lib/azahara_schema_currency/aggregation_attribute_patch.rb
|
784
785
|
- lib/azahara_schema_currency/association_attribute_patch.rb
|