egon_gate 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +34 -0
- data/lib/egon_gate.rb +7 -0
- data/lib/egon_gate/egsb/config.rb +23 -0
- data/lib/egon_gate/egsb/message.rb +76 -0
- data/lib/egon_gate/egsb/messages/e37_vyhledej_adresu.rb +37 -0
- data/lib/egon_gate/egsb/request.rb +12 -0
- data/lib/egon_gate/kobra/message.rb +45 -0
- data/lib/egon_gate/kobra/request.rb +21 -0
- data/lib/egon_gate/kobra/response.rb +36 -0
- data/lib/egon_gate/version.rb +3 -0
- data/lib/tasks/egon_gate_tasks.rake +4 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 40dbfc3afea3666e656c88fc85739a274135560d
|
4
|
+
data.tar.gz: 7d1648411fac09617edf01d81029f6c4baeedd24
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c83358e9b89ccc2f7e57661831dec0d9907d654dca26c1b4f675f918c2f77db03e8d55979c1b68e2bbb453dde6f5b6dafe215830ad0d074a727ad7791f5ba5ff
|
7
|
+
data.tar.gz: d155435dd674cd064ac3e9f0f0c29b8640bb9467ef2aa13076668c22ab1ceac916e7bb65e87352c698f071bf7eacc9acffdda5e8a941949a68ac997c43e94304
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Ondřej Ezr
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# EgonGate
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'egon_gate'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install egon_gate
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'EgonGate'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
data/lib/egon_gate.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'gyoku'
|
2
|
+
require 'egon_gate/egsb/config'
|
3
|
+
|
4
|
+
module EgonGate
|
5
|
+
module Egsb
|
6
|
+
class Message
|
7
|
+
|
8
|
+
class_attribute :attributes
|
9
|
+
|
10
|
+
def config
|
11
|
+
@config ||= EgonGate::Egsb::Config.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def message_id
|
15
|
+
@message_id ||= SecureRandom.uuid
|
16
|
+
end
|
17
|
+
|
18
|
+
def message_code
|
19
|
+
raise NotImplementedError.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def message_tag
|
23
|
+
raise NotImplementedError.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def message_request_tag
|
27
|
+
raise NotImplementedError.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def header
|
31
|
+
{
|
32
|
+
'reg:CasZadosti' => Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%:z'),
|
33
|
+
'reg:Agenda' => config.agenda,
|
34
|
+
'reg:AgendovaRole' => config.role_of_agenda,
|
35
|
+
'reg:Ovm' => config.ovm_code,
|
36
|
+
'reg:Ais' => config.ais_code,
|
37
|
+
'reg:Uzivatel' => 'OEzr',
|
38
|
+
'reg:AgendaZadostId' => message_id
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def namespace_definitions
|
43
|
+
{
|
44
|
+
'xmlns:abs' => 'urn:cz:isvs:iszr:schemas:IszrAbstract:v1',
|
45
|
+
'xmlns:reg' => 'urn:cz:isvs:reg:schemas:RegTypy:v1'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def message_body
|
50
|
+
{}
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def message
|
55
|
+
{
|
56
|
+
message_tag => {
|
57
|
+
'abs:ZadostInfo' => header,
|
58
|
+
'nsgon:Zadost' => {
|
59
|
+
message_request_tag => message_body
|
60
|
+
}
|
61
|
+
},
|
62
|
+
attributes!: { message_tag => namespace_definitions }
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse_response(response)
|
67
|
+
response[:ruian_vyhledej_adresu_response][:ruian_odpoved][:ruian_vyhledej_adresu_data_response][:adresy][:adresa]
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_s
|
71
|
+
Gyoku.xml(message, key_converter: :camelcase)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module EgonGate
|
2
|
+
module Egsb
|
3
|
+
module Messages
|
4
|
+
class E37VyhledejAdresu < Message
|
5
|
+
|
6
|
+
self.attributes = [:obec_nazev, :cast_obce_nazev, :ulice_nazev, :posta_nazev, :posta_kod, :typ_cisla_domovniho_kod, :cislo_domovni, :cislo_orientacni, :cislo_orientacni_pismeno]
|
7
|
+
|
8
|
+
attr_accessor *attributes
|
9
|
+
|
10
|
+
def message_code
|
11
|
+
'E37'
|
12
|
+
end
|
13
|
+
|
14
|
+
def namespace_definitions
|
15
|
+
super.merge({
|
16
|
+
'xmlns:nsgon' => 'urn:cz:isvs:iszr:schemas:IszrRuianVyhledejAdresu:v1',
|
17
|
+
'xmlns:nscr' => 'urn:cz:isvs:ruian:schemas:VyhledejAdresa:v1'
|
18
|
+
})
|
19
|
+
end
|
20
|
+
|
21
|
+
def message_tag
|
22
|
+
'nsgon:RuianVyhledejAdresu'
|
23
|
+
end
|
24
|
+
|
25
|
+
def message_request_tag
|
26
|
+
'nsgon:RuianVyhledejAdresuData'
|
27
|
+
end
|
28
|
+
|
29
|
+
def message_body
|
30
|
+
{
|
31
|
+
'nscr:Podminka' => self.class.attributes.each_with_object({}) {|attribute, obj| v = self.public_send(attribute); obj['nscr:'+attribute.to_s.camelize] = v if v }
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'gyoku'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module EgonGate
|
5
|
+
module Kobra
|
6
|
+
class Message
|
7
|
+
|
8
|
+
def initialize(egsb_message, mode='sync')
|
9
|
+
@egsb_message = egsb_message
|
10
|
+
@mode = mode
|
11
|
+
end
|
12
|
+
|
13
|
+
def config
|
14
|
+
{
|
15
|
+
is_id: 124
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def body
|
20
|
+
Base64.encode64 @egsb_message.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def message_details
|
24
|
+
{class: @egsb_message.message_code, attributes!: {class: {mode: @mode}}}
|
25
|
+
end
|
26
|
+
|
27
|
+
def message_hash
|
28
|
+
{ gate_message: {
|
29
|
+
version: '2.0',
|
30
|
+
header: {
|
31
|
+
message_details: message_details,
|
32
|
+
sender_details: {authentication: {'ISId' => config[:is_id]}, attributes!: { authentication: {type: 'clear'} }},
|
33
|
+
attributes!: {message_details: {type: 'request'}}
|
34
|
+
},
|
35
|
+
body: body
|
36
|
+
}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
Gyoku.xml(message_hash, key_converter: :camelcase)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'egon_gate/kobra/message'
|
2
|
+
require 'egon_gate/kobra/response'
|
3
|
+
|
4
|
+
module EgonGate
|
5
|
+
module Kobra
|
6
|
+
class Request
|
7
|
+
|
8
|
+
def client
|
9
|
+
@client ||= Savon.client(wsdl: 'https://serviszr01.servis.justice.cz/GateService/GateService.svc?wsdl', convert_request_keys_to: :camelcase,
|
10
|
+
ssl_verify_mode: :none, log: true, pretty_print_xml: true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def send_message(egsb_message)
|
14
|
+
message = Message.new(egsb_message)
|
15
|
+
res = client.call(:get_data, message: { 'inputXml' => message.to_s }, attributes: {'xmlns' => 'http://tempuri.org/'})
|
16
|
+
EgonGate::Kobra::Response.new(res)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "nori"
|
2
|
+
|
3
|
+
module EgonGate
|
4
|
+
module Kobra
|
5
|
+
class Response
|
6
|
+
|
7
|
+
def initialize(soap_response)
|
8
|
+
@soap_response = soap_response
|
9
|
+
@egsb_string = soap_response.body[:get_data_response][:get_data_result]
|
10
|
+
end
|
11
|
+
|
12
|
+
def pure_xml
|
13
|
+
@responsed_body ||= nori.parse(@egsb_string)
|
14
|
+
end
|
15
|
+
|
16
|
+
def egsb_response
|
17
|
+
@response ||= nori.parse( Base64.decode64 pure_xml[:gate_message][:body] )
|
18
|
+
end
|
19
|
+
|
20
|
+
def error?
|
21
|
+
egsb_response.values.first[:odpoved_info][:status][:vysledek_kod] != "OK"
|
22
|
+
end
|
23
|
+
|
24
|
+
def error_message
|
25
|
+
egsb_response.values.first[:odpoved_info][:status][:vysledek_detail][:vysledek_sub_kod]
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def nori
|
31
|
+
@soap_response.__send__(:nori)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: egon_gate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ondřej Ezr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: savon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.11.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.11.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Egon is here to make eGon communication as easy as possible.
|
42
|
+
email:
|
43
|
+
- oezr@msp.justice.cz
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- lib/egon_gate.rb
|
52
|
+
- lib/egon_gate/egsb/config.rb
|
53
|
+
- lib/egon_gate/egsb/message.rb
|
54
|
+
- lib/egon_gate/egsb/messages/e37_vyhledej_adresu.rb
|
55
|
+
- lib/egon_gate/egsb/request.rb
|
56
|
+
- lib/egon_gate/kobra/message.rb
|
57
|
+
- lib/egon_gate/kobra/request.rb
|
58
|
+
- lib/egon_gate/kobra/response.rb
|
59
|
+
- lib/egon_gate/version.rb
|
60
|
+
- lib/tasks/egon_gate_tasks.rake
|
61
|
+
homepage: https://git.justice.cz/libraries/egon_gate.git
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.5.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Egon Gate makes easy to use eGon services from Ruby language
|
85
|
+
test_files: []
|