nuncium 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.overcommit.yml +49 -0
- data/.rspec +2 -0
- data/.rubocop.yml +26 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/DOCS.md +133 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +136 -0
- data/Guardfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +281 -0
- data/Rakefile +6 -0
- data/_config.yml +1 -0
- data/bin/console +7 -0
- data/lib/nuncium.rb +87 -0
- data/lib/nuncium/configuration.rb +82 -0
- data/lib/nuncium/data_box.rb +41 -0
- data/lib/nuncium/data_message.rb +136 -0
- data/lib/nuncium/request.rb +120 -0
- data/lib/nuncium/response.rb +18 -0
- data/lib/nuncium/responses/body.rb +19 -0
- data/lib/nuncium/responses/data_box.rb +14 -0
- data/lib/nuncium/responses/db/body.rb +9 -0
- data/lib/nuncium/responses/db/status.rb +13 -0
- data/lib/nuncium/responses/dm/body.rb +9 -0
- data/lib/nuncium/responses/dm/status.rb +13 -0
- data/lib/nuncium/responses/message.rb +21 -0
- data/lib/nuncium/responses/messages/attachment.rb +24 -0
- data/lib/nuncium/responses/messages/collection.rb +29 -0
- data/lib/nuncium/responses/messages/delivery_info.rb +23 -0
- data/lib/nuncium/responses/messages/envelope.rb +23 -0
- data/lib/nuncium/responses/messages/event.rb +14 -0
- data/lib/nuncium/responses/status.rb +19 -0
- data/lib/nuncium/utils/errors.rb +18 -0
- data/lib/nuncium/version.rb +3 -0
- data/lib/nuncium/web_services/db_access/.gitkeep +0 -0
- data/lib/nuncium/web_services/db_access/change_isds_password.rb +21 -0
- data/lib/nuncium/web_services/db_access/get_owner_info_from_login.rb +19 -0
- data/lib/nuncium/web_services/db_search/check_data_box.rb +17 -0
- data/lib/nuncium/web_services/db_search/d_t_info.rb +17 -0
- data/lib/nuncium/web_services/db_search/data_box_credit_info.rb +17 -0
- data/lib/nuncium/web_services/db_search/find_data_box.rb +25 -0
- data/lib/nuncium/web_services/db_search/find_personal_data_box.rb +22 -0
- data/lib/nuncium/web_services/db_search/get_data_box_activity_status.rb +17 -0
- data/lib/nuncium/web_services/db_search/get_data_box_list.rb +20 -0
- data/lib/nuncium/web_services/db_search/isds_search_2.rb +18 -0
- data/lib/nuncium/web_services/db_search/p_d_z_info.rb +17 -0
- data/lib/nuncium/web_services/db_search/p_d_z_send_info.rb +17 -0
- data/lib/nuncium/web_services/db_search/request.rb +19 -0
- data/lib/nuncium/web_services/db_search/response.rb +13 -0
- data/lib/nuncium/web_services/dm_info/confirm_delivery.rb +17 -0
- data/lib/nuncium/web_services/dm_info/erase_message.rb +17 -0
- data/lib/nuncium/web_services/dm_info/get_delivery_info.rb +25 -0
- data/lib/nuncium/web_services/dm_info/get_list_of_received_messages.rb +26 -0
- data/lib/nuncium/web_services/dm_info/get_list_of_sent_messages.rb +26 -0
- data/lib/nuncium/web_services/dm_info/get_message_author.rb +17 -0
- data/lib/nuncium/web_services/dm_info/get_message_state_changes.rb +17 -0
- data/lib/nuncium/web_services/dm_info/get_signed_delivery_info.rb +17 -0
- data/lib/nuncium/web_services/dm_info/mark_message_as_downloaded.rb +17 -0
- data/lib/nuncium/web_services/dm_info/message_envelope_download.rb +25 -0
- data/lib/nuncium/web_services/dm_info/request.rb +19 -0
- data/lib/nuncium/web_services/dm_info/response.rb +13 -0
- data/lib/nuncium/web_services/dm_info/verify_message.rb +17 -0
- data/lib/nuncium/web_services/dm_operations/authenticate_message.rb +17 -0
- data/lib/nuncium/web_services/dm_operations/create_message.rb +30 -0
- data/lib/nuncium/web_services/dm_operations/create_multiple_messages.rb +30 -0
- data/lib/nuncium/web_services/dm_operations/message_download.rb +25 -0
- data/lib/nuncium/web_services/dm_operations/ping.rb +15 -0
- data/lib/nuncium/web_services/dm_operations/request.rb +19 -0
- data/lib/nuncium/web_services/dm_operations/resign_isds_document.rb +17 -0
- data/lib/nuncium/web_services/dm_operations/response.rb +13 -0
- data/lib/nuncium/web_services/dm_operations/signed_message_download.rb +17 -0
- data/lib/nuncium/web_services/dm_operations/signed_sent_message_download.rb +17 -0
- data/nuncium.gemspec +47 -0
- data/wercker.yml +12 -0
- metadata +303 -0
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Andrej Antas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,281 @@
|
|
1
|
+
# Work in Progress
|
2
|
+
|
3
|
+
# Nuncium [![wercker status](https://app.wercker.com/status/04043d3ae16228db7dc8d9d3ae51d1e6/s/master "wercker status")](https://app.wercker.com/project/byKey/04043d3ae16228db7dc8d9d3ae51d1e6) [![Maintainability](https://api.codeclimate.com/v1/badges/eb20cde530fb8d1690cd/maintainability)](https://codeclimate.com/github/redrick/nuncium/maintainability)
|
4
|
+
|
5
|
+
Wrapper for API love [ISDS](https://www.datoveschranky.info/) shares with us through this XML API.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'nuncium'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install nuncium
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Before usage please add config (for rails initializer) with one of supported
|
26
|
+
auth strategies:
|
27
|
+
|
28
|
+
### Username + password
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
Nuncium.configure do |c|
|
32
|
+
c.data_box = 'data_box_id'
|
33
|
+
c.username = 'somebody'
|
34
|
+
c.password = 'data_box_password'
|
35
|
+
c.env = :development
|
36
|
+
end
|
37
|
+
```
|
38
|
+
### Server side system certificate
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Nuncium.configure do |c|
|
42
|
+
c.data_box = 'data_box_id'
|
43
|
+
c.cert_file = 'spec/factories/files/certifikat.pem'
|
44
|
+
c.key_file = 'spec/factories/files/test-key.key'
|
45
|
+
c.pass_phrase = 'andrej'
|
46
|
+
c.env = :development
|
47
|
+
end
|
48
|
+
```
|
49
|
+
here `data_box_id` if id of databox you will be accessing, you do not really
|
50
|
+
need id of databox used as point from where you access
|
51
|
+
|
52
|
+
you do not have to provide `env` in setup unless you go to production, gem
|
53
|
+
defaults to `:development` anyway...
|
54
|
+
|
55
|
+
This gem provides you with 2 basic classes and those are:
|
56
|
+
- `Nuncium::DataBox` (operations and manipulation around data box itself)
|
57
|
+
- `Nuncium::DataMessage` (operations and manipulation with message)
|
58
|
+
|
59
|
+
Kinda important to mention is that results of calls are trying to be the same each time of course and in form of neat object that looks like this:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
=> #<Nuncium::WebServices::DbSearch::Response:0x00007fd3d44f0fd8
|
63
|
+
@body=#<Nuncium::Responses::Db::Body:0x00007fd3d449b808 @ciRecords=nil, @currentCredit="596400", @notifEmail=nil>,
|
64
|
+
@response=
|
65
|
+
{"Envelope"=>
|
66
|
+
{"xmlns:SOAP_ENV"=>"http://schemas.xmlsoap.org/soap/envelope/",
|
67
|
+
"xmlns:xsd"=>"http://www.w3.org/2001/XMLSchema",
|
68
|
+
"Body"=>{"DataBoxCreditInfoResponse"=>{"xmlns:p"=>"http://isds.czechpoint.cz/v20", "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "currentCredit"=>"596400", "notifEmail"=>{"xsi:nil"=>"true"}, "ciRecords"=>nil, "dbStatus"=>{"dbStatusCode"=>"0000", "dbStatusMessage"=>"Provedeno úspěšně."}}}}},
|
69
|
+
@status=#<Nuncium::Responses::Db::Status:0x00007fd3d449be48 @code="0000", @message="Provedeno úspěšně.">>
|
70
|
+
```
|
71
|
+
|
72
|
+
To take it apart consist of:
|
73
|
+
- `body` -> in case of request for messages will be `messages` is parsed body taking original attribute names and their values
|
74
|
+
- inspect and use like so:
|
75
|
+
```ruby
|
76
|
+
> result.body.currentCredit
|
77
|
+
=> "596400"
|
78
|
+
```
|
79
|
+
- `status` -> always contains status information in form of `code` and `messsage`
|
80
|
+
- `response` -> simply whole original XML response parsed into Hash for better usage
|
81
|
+
|
82
|
+
Public API looks like so:
|
83
|
+
|
84
|
+
### Nuncium::DataBox
|
85
|
+
|
86
|
+
#### .check
|
87
|
+
|
88
|
+
checking the status
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
> Nuncium::DataBox.check
|
92
|
+
|
93
|
+
=> #<Nuncium::WebServices::DbSearch::Response:0x00007fd3d68487d8
|
94
|
+
@body=#<Nuncium::Responses::Db::Body:0x00007fd3d41ad2e0 @dbState="1">,
|
95
|
+
@response=
|
96
|
+
{"Envelope"=>
|
97
|
+
{"xmlns:SOAP_ENV"=>"http://schemas.xmlsoap.org/soap/envelope/",
|
98
|
+
"xmlns:xsd"=>"http://www.w3.org/2001/XMLSchema",
|
99
|
+
"Body"=>{"CheckDataBoxResponse"=>{"xmlns:p"=>"http://isds.czechpoint.cz/v20", "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "dbState"=>"1", "dbStatus"=>{"dbStatusCode"=>"0000", "dbStatusMessage"=>"Provedeno úspěšně."}}}}},
|
100
|
+
@status=#<Nuncium::Responses::Db::Status:0x00007fd3d41ae280 @code="0000", @message="Provedeno úspěšně.">>
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
#### .find_by
|
105
|
+
|
106
|
+
You can find any data box by searching like so:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
> Nuncium::DataBox.find_by(dbType: 'FO', pnLastName: 'Anta')
|
110
|
+
|
111
|
+
=> #<Nuncium::WebServices::DbSearch::Response:0x00007f9986b4c090
|
112
|
+
@body=#<Nuncium::Responses::Db::Body:0x00007f9987823f98 @dbResults=false>,
|
113
|
+
@response=
|
114
|
+
{"Envelope"=>
|
115
|
+
{"xmlns:SOAP_ENV"=>"http://schemas.xmlsoap.org/soap/envelope/",
|
116
|
+
"xmlns:xsd"=>"http://www.w3.org/2001/XMLSchema",
|
117
|
+
"Body"=>
|
118
|
+
{"FindDataBoxResponse"=>
|
119
|
+
{"xmlns:p"=>"http://isds.czechpoint.cz/v20",
|
120
|
+
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
|
121
|
+
"dbResults"=>
|
122
|
+
{"dbOwnerInfo"=>
|
123
|
+
{"dbID"=>"mxbf8u6",
|
124
|
+
"dbType"=>"FO",
|
125
|
+
"ic"=>{"xsi:nil"=>"true"},
|
126
|
+
"pnFirstName"=>"Andrej",
|
127
|
+
"pnMiddleName"=>{"xsi:nil"=>"true"},
|
128
|
+
"pnLastName"=>"Antaš",
|
129
|
+
"pnLastNameAtBirth"=>{"xsi:nil"=>"true"},
|
130
|
+
"firmName"=>{"xsi:nil"=>"true"},
|
131
|
+
"biDate"=>"1990-01-16",
|
132
|
+
"biCity"=>"*",
|
133
|
+
"biCounty"=>"*",
|
134
|
+
"biState"=>"*",
|
135
|
+
"adCity"=>"Praha 5",
|
136
|
+
"adStreet"=>"Pekařská",
|
137
|
+
"adNumberInStreet"=>"10a",
|
138
|
+
"adNumberInMunicipality"=>"695",
|
139
|
+
"adZipCode"=>"15500",
|
140
|
+
"adState"=>"CZ",
|
141
|
+
"nationality"=>"*",
|
142
|
+
"identifier"=>{"xsi:nil"=>"true"},
|
143
|
+
"registryCode"=>{"xsi:nil"=>"true"},
|
144
|
+
"dbState"=>"1",
|
145
|
+
"dbEffectiveOVM"=>"false",
|
146
|
+
"dbOpenAddressing"=>"true"}},
|
147
|
+
"dbStatus"=>{"dbStatusCode"=>"0000", "dbStatusMessage"=>"Provedeno úspěšně."}}}}},
|
148
|
+
@status=#<Nuncium::Responses::Db::Status:0x00007f9987828c50 @code="0000", @message="Provedeno úspěšně.">>
|
149
|
+
```
|
150
|
+
|
151
|
+
#### .credit_info
|
152
|
+
|
153
|
+
For checking your balance (post messages need payments), so you can make sure you have enough before sending a message:
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
> Nuncium::DataBox.credit_info
|
157
|
+
|
158
|
+
=> #<Nuncium::WebServices::DbSearch::Response:0x00007f8dd69b6e08
|
159
|
+
@body=#<Nuncium::Responses::Db::Body:0x00007f8dd699c1e8 @ciRecords=nil, @currentCredit="596400", @notifEmail=nil>,
|
160
|
+
@response=
|
161
|
+
{"Envelope"=>
|
162
|
+
{"xmlns:SOAP_ENV"=>"http://schemas.xmlsoap.org/soap/envelope/",
|
163
|
+
"xmlns:xsd"=>"http://www.w3.org/2001/XMLSchema",
|
164
|
+
"Body"=>{"DataBoxCreditInfoResponse"=>{"xmlns:p"=>"http://isds.czechpoint.cz/v20", "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "currentCredit"=>"596400", "notifEmail"=>{"xsi:nil"=>"true"}, "ciRecords"=>nil, "dbStatus"=>{"dbStatusCode"=>"0000", "dbStatusMessage"=>"Provedeno úspěšně."}}}}},
|
165
|
+
@status=#<Nuncium::Responses::Db::Status:0x00007f8dd699c3a0 @code="0000", @message="Provedeno úspěšně.">>
|
166
|
+
```
|
167
|
+
|
168
|
+
#### .received
|
169
|
+
|
170
|
+
Listing all received messages:
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
> Nuncium::DataBox.received
|
174
|
+
|
175
|
+
=> #<Nuncium::Responses::Messages::Collection:0x00007f99882e6048
|
176
|
+
@messages=
|
177
|
+
[
|
178
|
+
...
|
179
|
+
],
|
180
|
+
@status=#<Nuncium::Responses::Dm::Status:0x00007f9986c26718 @code="0000", @message="Provedeno úspěšně.">>
|
181
|
+
```
|
182
|
+
|
183
|
+
Message responses are stubbed here in response, will be explain down in DataMessage docs
|
184
|
+
|
185
|
+
#### .sent
|
186
|
+
|
187
|
+
|
188
|
+
Listing all received messages:
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
> Nuncium::DataBox.sent
|
192
|
+
|
193
|
+
=> #<Nuncium::Responses::Messages::Collection:0x00007f99882e6048
|
194
|
+
@messages=
|
195
|
+
[
|
196
|
+
...
|
197
|
+
],
|
198
|
+
@status=#<Nuncium::Responses::Dm::Status:0x00007f9986c26718 @code="0000", @message="Provedeno úspěšně.">>
|
199
|
+
```
|
200
|
+
|
201
|
+
Message responses are stubbed here in response, will be explain down in DataMessage docs
|
202
|
+
|
203
|
+
#### .state_changes
|
204
|
+
|
205
|
+
TODO
|
206
|
+
|
207
|
+
### Nuncium::DataMessage
|
208
|
+
|
209
|
+
#### .find
|
210
|
+
|
211
|
+
#### #download
|
212
|
+
|
213
|
+
#### #verify
|
214
|
+
|
215
|
+
#### #authenticate
|
216
|
+
|
217
|
+
#### #signed
|
218
|
+
|
219
|
+
#### #author
|
220
|
+
|
221
|
+
#### #delivery_info
|
222
|
+
|
223
|
+
#### #envelope
|
224
|
+
|
225
|
+
#### #confirm_delivery
|
226
|
+
|
227
|
+
#### #mark_as_downloaded
|
228
|
+
|
229
|
+
#### #destroy
|
230
|
+
|
231
|
+
#### #sent?
|
232
|
+
|
233
|
+
#### #received?
|
234
|
+
|
235
|
+
### Help
|
236
|
+
|
237
|
+
If in doubt, or my so called 'README' seems not that helpful, please refer to [ISDS provozni rad](https://www.datoveschranky.info/dulezite-informace/provozni-rad-isds)
|
238
|
+
|
239
|
+
#### Certificates
|
240
|
+
|
241
|
+
Just some helpfull information when you want to use certificate to access
|
242
|
+
databoxes:
|
243
|
+
|
244
|
+
How to setup and what not in ISDS: [https://www.czebox.cz/static/ISDS/help/page8.html#8_4](https://www.czebox.cz/static/ISDS/help/page8.html#8_4)
|
245
|
+
|
246
|
+
Working with DER/PEM and what not around the keys: [https://knowledge.digicert.com/solution/SO26449.html](https://knowledge.digicert.com/solution/SO26449.html)
|
247
|
+
|
248
|
+
How to convert windows pfx file exported from keychain into key you need here: [https://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/](https://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/)
|
249
|
+
|
250
|
+
Jus to note here, certificate accepted should be in PEM format and you have to add the private.key with the password to it.
|
251
|
+
|
252
|
+
## Development
|
253
|
+
|
254
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
255
|
+
|
256
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
257
|
+
|
258
|
+
## Contributing
|
259
|
+
|
260
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nuncium. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
261
|
+
|
262
|
+
## TODO
|
263
|
+
|
264
|
+
Still WIP although we test it already how this is going to turn out, so fingers
|
265
|
+
crossed... we still need to finish:
|
266
|
+
- massive portion of specs
|
267
|
+
- refactoring (a lot of same code and misused inheritance)
|
268
|
+
- sending messages...
|
269
|
+
- better documentation
|
270
|
+
|
271
|
+
## License
|
272
|
+
|
273
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
274
|
+
|
275
|
+
## Thanks
|
276
|
+
|
277
|
+
Many thanks to Petr Písař <petr.pisar@atlas.cz> for writing awesome libisds C library and compiling many usefull information around ISDS :)
|
278
|
+
|
279
|
+
## Code of Conduct
|
280
|
+
|
281
|
+
Everyone interacting in the Nuncium project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/nuncium/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-modernist
|
data/bin/console
ADDED
data/lib/nuncium.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'base64'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'active_support/core_ext/hash'
|
6
|
+
|
7
|
+
require 'nuncium/utils/errors'
|
8
|
+
|
9
|
+
require 'nuncium/version'
|
10
|
+
require 'nuncium/configuration'
|
11
|
+
require 'nuncium/request'
|
12
|
+
require 'nuncium/response'
|
13
|
+
|
14
|
+
require 'nuncium/data_box'
|
15
|
+
require 'nuncium/data_message'
|
16
|
+
|
17
|
+
require 'nuncium/responses/body'
|
18
|
+
require 'nuncium/responses/status'
|
19
|
+
require 'nuncium/responses/db/status'
|
20
|
+
require 'nuncium/responses/dm/status'
|
21
|
+
require 'nuncium/responses/dm/body'
|
22
|
+
require 'nuncium/responses/db/body'
|
23
|
+
require 'nuncium/responses/message'
|
24
|
+
require 'nuncium/responses/messages/event'
|
25
|
+
require 'nuncium/responses/messages/envelope'
|
26
|
+
require 'nuncium/responses/messages/attachment'
|
27
|
+
require 'nuncium/responses/messages/collection'
|
28
|
+
require 'nuncium/responses/messages/delivery_info'
|
29
|
+
|
30
|
+
require 'nuncium/web_services/db_search/response'
|
31
|
+
require 'nuncium/web_services/db_search/request'
|
32
|
+
require 'nuncium/web_services/db_search/find_data_box'
|
33
|
+
require 'nuncium/web_services/db_search/d_t_info'
|
34
|
+
require 'nuncium/web_services/db_search/get_data_box_activity_status'
|
35
|
+
require 'nuncium/web_services/db_search/check_data_box'
|
36
|
+
require 'nuncium/web_services/db_search/data_box_credit_info'
|
37
|
+
require 'nuncium/web_services/db_search/find_personal_data_box'
|
38
|
+
require 'nuncium/web_services/db_search/get_data_box_list'
|
39
|
+
require 'nuncium/web_services/db_search/isds_search_2'
|
40
|
+
require 'nuncium/web_services/db_search/p_d_z_info'
|
41
|
+
require 'nuncium/web_services/db_search/p_d_z_send_info'
|
42
|
+
|
43
|
+
require 'nuncium/web_services/db_access/change_isds_password'
|
44
|
+
require 'nuncium/web_services/db_access/get_owner_info_from_login'
|
45
|
+
|
46
|
+
require 'nuncium/web_services/dm_info/request'
|
47
|
+
require 'nuncium/web_services/dm_info/response'
|
48
|
+
require 'nuncium/web_services/dm_info/confirm_delivery'
|
49
|
+
require 'nuncium/web_services/dm_info/erase_message'
|
50
|
+
require 'nuncium/web_services/dm_info/get_delivery_info'
|
51
|
+
require 'nuncium/web_services/dm_info/get_list_of_received_messages'
|
52
|
+
require 'nuncium/web_services/dm_info/get_list_of_sent_messages'
|
53
|
+
require 'nuncium/web_services/dm_info/get_message_author'
|
54
|
+
require 'nuncium/web_services/dm_info/get_message_state_changes'
|
55
|
+
require 'nuncium/web_services/dm_info/get_signed_delivery_info'
|
56
|
+
require 'nuncium/web_services/dm_info/mark_message_as_downloaded'
|
57
|
+
require 'nuncium/web_services/dm_info/message_envelope_download'
|
58
|
+
require 'nuncium/web_services/dm_info/verify_message'
|
59
|
+
|
60
|
+
require 'nuncium/web_services/dm_operations/request'
|
61
|
+
require 'nuncium/web_services/dm_operations/response'
|
62
|
+
require 'nuncium/web_services/dm_operations/authenticate_message'
|
63
|
+
require 'nuncium/web_services/dm_operations/create_message'
|
64
|
+
require 'nuncium/web_services/dm_operations/create_multiple_messages'
|
65
|
+
require 'nuncium/web_services/dm_operations/message_download'
|
66
|
+
require 'nuncium/web_services/dm_operations/ping'
|
67
|
+
require 'nuncium/web_services/dm_operations/resign_isds_document'
|
68
|
+
require 'nuncium/web_services/dm_operations/signed_message_download'
|
69
|
+
require 'nuncium/web_services/dm_operations/signed_sent_message_download'
|
70
|
+
|
71
|
+
module Nuncium
|
72
|
+
def self.configuration
|
73
|
+
@configuration ||= Configuration.new
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.reset
|
77
|
+
@configuration = Configuration.new
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.configure
|
81
|
+
yield(configuration)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.ping
|
85
|
+
::Nuncium::WebServices::DmOperations::Ping.new.call
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Nuncium
|
2
|
+
class Configuration
|
3
|
+
attr_writer :data_box, :username, :password, :env, :api_url,
|
4
|
+
:cert_file, :key_file, :pass_phrase
|
5
|
+
attr_reader :pass_phrase
|
6
|
+
|
7
|
+
ALLOWED_PRODUCTION_SYNTAX = [:production, 'production'].freeze
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@username = nil
|
11
|
+
@password = nil
|
12
|
+
@data_box = nil
|
13
|
+
@env = nil
|
14
|
+
@cert_file = nil
|
15
|
+
@key_file = nil
|
16
|
+
@pass_phrase = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def data_box
|
20
|
+
raise ConfigNotSet, 'data_box' unless @data_box
|
21
|
+
@data_box
|
22
|
+
end
|
23
|
+
|
24
|
+
def username
|
25
|
+
raise ConfigNotSet, 'username' unless @username
|
26
|
+
@username
|
27
|
+
end
|
28
|
+
|
29
|
+
def password
|
30
|
+
raise ConfigNotSet, 'password' unless @password
|
31
|
+
@password
|
32
|
+
end
|
33
|
+
|
34
|
+
def cert_file
|
35
|
+
if @cert_file && (!@key_file && !@pass_phrase)
|
36
|
+
raise ConfigNotSet, 'pass_phrase and key_file'
|
37
|
+
end
|
38
|
+
return unless @cert_file
|
39
|
+
OpenSSL::X509::Certificate.new(File.read(@cert_file))
|
40
|
+
end
|
41
|
+
|
42
|
+
def key_file
|
43
|
+
return nil unless @key_file
|
44
|
+
File.read(@key_file)
|
45
|
+
end
|
46
|
+
|
47
|
+
def private_key
|
48
|
+
raise ConfigNotSet, 'pass_phrase' if @key_file && !@pass_phrase
|
49
|
+
raise ConfigNotSet, 'key_file' if !@key_file && @pass_phrase
|
50
|
+
OpenSSL::PKey::RSA.new(File.read(@key_file), @pass_phrase)
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# env values:
|
55
|
+
# :development (default)
|
56
|
+
# :production
|
57
|
+
#
|
58
|
+
def env
|
59
|
+
return :development unless @env
|
60
|
+
@env
|
61
|
+
end
|
62
|
+
|
63
|
+
def api_domain
|
64
|
+
if production?
|
65
|
+
return 'https://ws1c.mojedatovaschranka.cz/cert' if @cert_file
|
66
|
+
'https://ws1.mojedatovaschranka.cz'
|
67
|
+
else
|
68
|
+
return 'https://ws1c.czebox.cz/hspis' if @cert_file
|
69
|
+
'https://ws1.czebox.cz'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def xml_url
|
74
|
+
return 'mojedatovaschranka.cz' if production?
|
75
|
+
'czechpoint.cz'
|
76
|
+
end
|
77
|
+
|
78
|
+
def production?
|
79
|
+
ALLOWED_PRODUCTION_SYNTAX.include?(@env)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|