egov_utils 1.5.0.alpha10 → 1.5.0.alpha12

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: 5be2f7d146ffd93939d4439e5499f8c6bb3850bb7c71f4e966b5c985497fa99f
4
- data.tar.gz: dbe8a432e8db4a475b40507a6b30977c63f6503faa5055c2906fac9f49ef75f6
3
+ metadata.gz: '078ff51d228a6daa3256634531da7ab192c702e4b50983b47efea4f697d0cd04'
4
+ data.tar.gz: c767737919a144419c646aaa436c60eab238922329703996e266b82284894bdd
5
5
  SHA512:
6
- metadata.gz: cfc3b34cad592a56c854f03a9f5831162718c2fcd817f3d421efec9383b0a918eb764623b9cbac2a54ed54371848cbd9a6e23d7407dd113612eb354a7663d9a6
7
- data.tar.gz: f12174cc8e38f84ee8dcf1534e9ef6f4cb5fa913c669bb964dbf7f039b3d8b2d16a617c87600ac7faa6438953ac7c7bf04b7dec0de0aea11fd9516a8d2f4a143
6
+ metadata.gz: 920fb3ef3d111b29f64ab3310e91eeda3fed4d2932510f11dbfdd8b8f007bdb37edbbc6e2c271bbf7f5b5f7313bf43be802d56691dcae94d5d3094c44ec220d6
7
+ data.tar.gz: cbe7ce9f4a893a5623dbcd5699d9fb5fc7012e1071c58e338fd3a2f3b95fde5e3f24a1dcc9a8a75cf19e4261f293e3417b090e2059ce3175d6a3202701d57195
@@ -12,7 +12,7 @@ module EgovUtils
12
12
 
13
13
  def strategy_class
14
14
  if Rails.env.production?
15
- EgovUtils::Iszr::Addresses::FetchForLegalPerson::FromRemoteReposiory
15
+ EgovUtils::Iszr::FindAddressByIco
16
16
  else
17
17
  EgovUtils::Iszr::Addresses::FetchForLegalPerson::FromSampleData
18
18
  end
@@ -0,0 +1,76 @@
1
+ module EgovUtils
2
+ module Iszr
3
+ class FindAddressByIco < Request
4
+ string :remote_id
5
+
6
+ private
7
+
8
+ def handle_response!
9
+ EgovUtils::Address.new(
10
+ street:
11
+ response_body.xpath('//UliceNazev').text.presence || response_body.xpath('//CastObceNazev').text,
12
+ house_number: response_body.xpath('//CisloDomovni').text,
13
+ orientation_number: response_body.xpath('//CisloOrientacni').text,
14
+ city: response_body.xpath('//ObecNazev').text,
15
+ postcode: response_body.xpath('//PostaKod').text,
16
+ egov_identifier: response_body.xpath('//AdresniMistoKod').text,
17
+ country: 203,
18
+ district: district.name,
19
+ region: region.name
20
+ )
21
+ end
22
+
23
+ def body
24
+ Nokogiri::XML::Builder.new do |xml|
25
+ xml['e256'].RosCtiIco2(
26
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
27
+ 'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:IszrRosCtiIco2:v1 IszrRosCtiIco2.xsd',
28
+ 'xmlns:abs' => 'urn:cz:isvs:iszr:schemas:IszrAbstract:v1',
29
+ 'xmlns:e256' => 'urn:cz:isvs:iszr:schemas:IszrRosCtiIco2:v1',
30
+ 'xmlns:reg' => 'urn:cz:isvs:reg:schemas:RegTypy:v1',
31
+ 'xmlns:ros' => 'urn:cz:isvs:ros:schemas:RosDotazyData:v2'
32
+ ) {
33
+ xml['abs'].ZadostInfo {
34
+ xml['reg'].CasZadosti Time.current.iso8601
35
+ xml['reg'].Agenda EgovUtils::Settings['iszr']['agenda']
36
+ xml['reg'].AgendovaRole EgovUtils::Settings['iszr']['agendova_role']
37
+ xml['reg'].Ovm '00025429'
38
+ xml['reg'].Ais EgovUtils::Settings['iszr']['ais']
39
+ xml['reg'].Subjekt '00025429'
40
+ xml['reg'].Uzivatel 'Administrator'
41
+ xml['reg'].DuvodUcel 'ztotozneni'
42
+ xml['reg'].AgendaZadostId SecureRandom.uuid
43
+ }
44
+ xml['abs'].AutorizaceInfo {
45
+ xml['abs'].SeznamUdaju 'ObchodniNazev AdresaSidla ROBCti ROSCti RUIANCti'
46
+ }
47
+ xml['e256'].Zadost {
48
+ xml['e256'].RosCtiIco2Data {
49
+ xml['ros'].Ico remote_id
50
+ }
51
+ }
52
+ }
53
+ end
54
+ end
55
+
56
+ def response_error_code
57
+ @response_error_code ||=
58
+ response_body.xpath('//VysledekSubKod').last&.text&.presence
59
+ end
60
+
61
+ def internal_error_code
62
+ return unless response_error_code
63
+
64
+ if response_error_code == 'ZAZNAM NENALEZEN'
65
+ "not_found"
66
+ elsif response_error_code == 'PREKROCEN POCET'
67
+ "multiple_records_found"
68
+ end
69
+ end
70
+
71
+ def service_id
72
+ 'E256'
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EgovUtils
4
+ module Iszr
5
+ class FindPersonByAifo < Request
6
+ string :remote_id
7
+
8
+ private
9
+
10
+ def handle_response!
11
+ {
12
+ name: response_body.xpath('//OsobaNazev').text.capitalize,
13
+ ico: remote_id
14
+ }
15
+ end
16
+
17
+ def body
18
+ Nokogiri::XML::Builder.new do |xml|
19
+ xml[service_id].RobCtiAifo2(
20
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
21
+ 'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:IszrRobCtiAifo2:v1 IszrRobCtiAifo2.xsd',
22
+ 'xmlns:abs' => 'urn:cz:isvs:iszr:schemas:IszrAbstract:v1',
23
+ 'xmlns:E276' => 'urn:cz:isvs:iszr:schemas:IszrRobCtiAifo2:v1',
24
+ 'xmlns:reg' => 'urn:cz:isvs:reg:schemas:RegTypy:v1',
25
+ 'xmlns:rod' => 'urn:cz:isvs:rob:schemas:RobDotazyData:v1',
26
+ 'xmlns:rob' => 'urn:cz:isvs:rob:schemas:RobTypy:v1'
27
+ ) {
28
+ xml['abs'].ZadostInfo {
29
+ xml['reg'].CasZadosti Time.current.iso8601
30
+ xml['reg'].Agenda EgovUtils::Settings['iszr']['agenda']
31
+ xml['reg'].AgendovaRole EgovUtils::Settings['iszr']['agendova_role']
32
+ xml['reg'].Ovm '00025429'
33
+ xml['reg'].Ais EgovUtils::Settings['iszr']['ais']
34
+ xml['reg'].Subjekt '00025429'
35
+ xml['reg'].Uzivatel 'Administrator'
36
+ xml['reg'].DuvodUcel 'ztotozneni'
37
+ xml['reg'].AgendaZadostId SecureRandom.uuid
38
+ }
39
+ xml['abs'].AutorizaceInfo {
40
+ xml['abs'].SeznamUdaju 'Aifo Prijmeni Jmeno DatumNarozeni RUIANCti AdresaPobytu MistoNarozeni'
41
+ }
42
+ xml['abs'].MapaAifo(nacistData: true) {
43
+ xml['reg'].PrevodAifo {
44
+ xml['reg'].LokalniAifo 1
45
+ xml['reg'].GlobalniAifo remote_id
46
+ }
47
+ }
48
+ xml[service_id].Zadost {
49
+ xml[service_id].RobCtiAifo2Data {
50
+ xml['rod'].Aifo 1
51
+ xml['rod'].VyuzitiPoskytnuti 'poskytnuti'
52
+ }
53
+ }
54
+ }
55
+ end
56
+ end
57
+
58
+ def service_id
59
+ 'E276'
60
+ end
61
+ end
62
+ end
63
+ end
@@ -6,32 +6,45 @@ module EgovUtils
6
6
 
7
7
  private
8
8
 
9
+ def handle_response!
10
+ if internal_error_code
11
+ errors.add(:base, internal_error_code)
12
+ return
13
+ end
14
+
15
+ EgovUtils::Services::Iszr::LegalPeople.new(
16
+ name: response_body.xpath('//NazevOsoby').text.capitalize,
17
+ ico: response_body.xpath('//Ico').text,
18
+ remote_id: response_body.xpath('//Ico').text
19
+ )
20
+ end
21
+
9
22
  def body
10
23
  Nokogiri::XML::Builder.new do |xml|
11
- xml['e20'].RosCtiIco(
24
+ xml['e256'].RosCtiIco2(
12
25
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
13
- 'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:IszrRosCtiIco:v1 IszrRosCtiIco.xsd',
26
+ 'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:IszrRosCtiIco2:v1 IszrRosCtiIco2.xsd',
14
27
  'xmlns:abs' => 'urn:cz:isvs:iszr:schemas:IszrAbstract:v1',
15
- 'xmlns:e20' => 'urn:cz:isvs:iszr:schemas:IszrRosCtiIco:v1',
28
+ 'xmlns:e256' => 'urn:cz:isvs:iszr:schemas:IszrRosCtiIco2:v1',
16
29
  'xmlns:reg' => 'urn:cz:isvs:reg:schemas:RegTypy:v1',
17
30
  'xmlns:ros' => 'urn:cz:isvs:ros:schemas:RosDotazyData:v2'
18
31
  ) {
19
32
  xml['abs'].ZadostInfo {
20
- xml['reg'].CasZadosti Time.current
21
- xml['reg'].Agenda 'A482'
22
- xml['reg'].AgendovaRole 'CTENAR'
33
+ xml['reg'].CasZadosti Time.current.iso8601
34
+ xml['reg'].Agenda EgovUtils::Settings['iszr']['agenda']
35
+ xml['reg'].AgendovaRole EgovUtils::Settings['iszr']['agendova_role']
23
36
  xml['reg'].Ovm '00025429'
24
- xml['reg'].Ais '124'
25
- xml['reg'].Uzivatel 'Uzivatel156'
26
- xml['reg'].AgendaZadostId '5a7b9af0-f759-4632-ab96-7bb06df1b98c'
37
+ xml['reg'].Ais EgovUtils::Settings['iszr']['ais']
38
+ xml['reg'].Subjekt '00025429'
39
+ xml['reg'].Uzivatel 'Administrator'
40
+ xml['reg'].DuvodUcel 'ztotozneni'
41
+ xml['reg'].AgendaZadostId SecureRandom.uuid
27
42
  }
28
43
  xml['abs'].AutorizaceInfo {
29
- xml['abs'].SeznamUdaju 'DatovaSchrankaROS ObchodniNazev PravniForma PravniStav
30
- FyzickaOsoba AdresaSidla Provozovny StatutarniOrgany DatumVznikuOpravneni DatumZanikuOpravneni
31
- Ico Jmeno Prijmeni AdresaPobytu AdresaUradu ROBCti ROSCti RUIANCti'
44
+ xml['abs'].SeznamUdaju 'ObchodniNazev AdresaSidla ROBCti ROSCti RUIANCti'
32
45
  }
33
- xml['e20'].Zadost {
34
- xml['e20'].RosCtiIcoData {
46
+ xml['e256'].Zadost {
47
+ xml['e256'].RosCtiIco2Data {
35
48
  xml['ros'].Ico ico
36
49
  }
37
50
  }
@@ -39,8 +52,23 @@ module EgovUtils
39
52
  end
40
53
  end
41
54
 
55
+ def response_error_code
56
+ @response_error_code ||=
57
+ response_body.xpath('//VysledekSubKod').last&.text&.presence
58
+ end
59
+
60
+ def internal_error_code
61
+ return unless response_error_code
62
+
63
+ if response_error_code == 'ZAZNAM NENALEZEN'
64
+ "not_found"
65
+ elsif response_error_code == 'PREKROCEN POCET'
66
+ "multiple_records_found"
67
+ end
68
+ end
69
+
42
70
  def service_id
43
- 'E20'
71
+ 'E256'
44
72
  end
45
73
  end
46
74
  end
@@ -19,7 +19,7 @@ module EgovUtils
19
19
 
20
20
  def find_person_service
21
21
  if Rails.env.production?
22
- EgovUtils::Iszr::LegalPeople::ProdSearch
22
+ EgovUtils::Iszr::LegalPeople::CreateRequest
23
23
  else
24
24
  EgovUtils::Iszr::LegalPeople::DevSearch
25
25
  end
@@ -9,12 +9,20 @@ module EgovUtils
9
9
  string :remote_id
10
10
 
11
11
  def execute
12
- find_person
12
+ if Rails.env.production?
13
+ find_remote_person
14
+ else
15
+ find_local_person
16
+ end
13
17
  end
14
18
 
15
19
  private
16
20
 
17
- def find_person
21
+ def find_remote_person
22
+ EgovUtils::Iszr::FindPersonByIco.run!(remote_id:)
23
+ end
24
+
25
+ def find_local_person
18
26
  initialize_person.find do |person|
19
27
  person.remote_id == remote_id
20
28
  end
@@ -53,7 +53,6 @@ module EgovUtils
53
53
  birth_place: response_body.xpath('//Lokalita/Nazev').text,
54
54
  remote_id: response_body.xpath('//GlobalniAifo').text
55
55
  )
56
-
57
56
  end
58
57
 
59
58
  def search_stage_one
@@ -18,27 +18,27 @@
18
18
  = label_tag 'birth_date', 'Datum narození'
19
19
  = date_field_tag :birth_date, {}, class: 'form-control'
20
20
  = link_to 'Vyhledat', {}, class: 'btn btn-primary'
21
- .legal_person
22
- .row
23
- = form.fields_for(:legal_person, person.legal_person || EgovUtils::LegalPerson.new) do |fields|
24
- .col-12= fields.text_field(:name)
25
- .col-12.col-sm-6= fields.text_field(:ico)
26
- .col-12.col-sm-6= fields.select2 :legal_form, list_values_for_select(azahara_attribute_for(EgovUtils::LegalPerson, 'legal_form'))
27
- .row
28
- .col-12
29
- = form.fields_for(:residence, person.residence || EgovUtils::Address.new) do |fields|
30
- = render 'egov_utils/addresses/form', form: fields, address: fields.object
31
-
32
- -# .legal-person-row.identification-form.legal_person.row
33
- -# .col-12
34
- -# .card
35
- -# .card-header Ztotožnění právnické osoby
36
- -# .card-body
37
- -# .form
38
- -# .form-group
39
- -# = label_tag 'ico', 'IČO'
40
- -# = text_field_tag :ico, {}, class: 'form-control'
41
- -# = link_to 'Vyhledat', nil, class: 'btn btn-primary'
21
+ -# .legal_person
22
+ -# .row
23
+ -# = form.fields_for(:legal_person, person.legal_person || EgovUtils::LegalPerson.new) do |fields|
24
+ -# .col-12= fields.text_field(:name)
25
+ -# .col-12.col-sm-6= fields.text_field(:ico)
26
+ -# .col-12.col-sm-6= fields.select2 :legal_form, list_values_for_select(azahara_attribute_for(EgovUtils::LegalPerson, 'legal_form'))
27
+ -# .row
28
+ -# .col-12
29
+ -# = form.fields_for(:residence, person.residence || EgovUtils::Address.new) do |fields|
30
+ -# = render 'egov_utils/addresses/form', form: fields, address: fields.object
31
+
32
+ .legal-person-row.identification-form.legal_person.row
33
+ .col-12
34
+ .card
35
+ .card-header Ztotožnění právnické osoby
36
+ .card-body
37
+ .form
38
+ .form-group
39
+ = label_tag 'ico', 'IČO'
40
+ = text_field_tag :ico, {}, class: 'form-control'
41
+ = link_to 'Vyhledat', nil, class: 'btn btn-primary'
42
42
  = form.hidden_field :remote_id
43
43
 
44
44
  :javascript
@@ -1,3 +1,3 @@
1
1
  module EgovUtils
2
- VERSION = '1.5.0.alpha10'
2
+ VERSION = '1.5.0.alpha12'
3
3
  end
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.alpha10
4
+ version: 1.5.0.alpha12
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: 2024-09-30 00:00:00.000000000 Z
11
+ date: 2024-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -674,7 +674,9 @@ files:
674
674
  - app/services/egov_utils/iszr/addresses/fetch_for_natural_person/from_sample_data.rb
675
675
  - app/services/egov_utils/iszr/client.rb
676
676
  - app/services/egov_utils/iszr/find_address_by_aifo.rb
677
+ - app/services/egov_utils/iszr/find_address_by_ico.rb
677
678
  - app/services/egov_utils/iszr/find_person_by_aifo.rb
679
+ - app/services/egov_utils/iszr/find_person_by_ico.rb
678
680
  - app/services/egov_utils/iszr/legal_people/create_request.rb
679
681
  - app/services/egov_utils/iszr/legal_people/dev_search.rb
680
682
  - app/services/egov_utils/iszr/legal_people/prod_search.rb