czech_post_b2b_client 1.2.8 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +7 -1
- data/README.md +6 -0
- data/lib/czech_post_b2b_client/printing_templates.rb +39 -32
- data/lib/czech_post_b2b_client/response_parsers/get_parcels_printing_parser.rb +18 -6
- data/lib/czech_post_b2b_client/services/address_sheets_generator.rb +2 -1
- data/lib/czech_post_b2b_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3625c919136ebf4fa10070dee900b1491f19880a7cdc96c77cc5029e95ce09f
|
4
|
+
data.tar.gz: 4e66d3911f876a85215306b6ac21f6d2fc8629acae3aba75ca6b0a966af61468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b353230a9e87d89d81a093d970292001d357efb26dea1705d904c79061350eea2a7e3e38f843b6670604c0f6393877d07624059a1917d10fd3d3ecec93cb5c
|
7
|
+
data.tar.gz: ae7566f678cd5235daed64d53dac229f4a6352e44c303f88b9f39d29519416110e0f3faf042b46c7145dc9301da6e1208cd7fe9e373737f8530646eda859ff94
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,14 @@
|
|
2
2
|
|
3
3
|
All changes to the gem are documented here.
|
4
4
|
|
5
|
+
## [1.3.0] - 2022-04-07
|
6
|
+
- checked currently available Print Templates codes
|
7
|
+
- enhanced address sheet printing with ability to print ZPL sheets (templates 200, 201 and 202).
|
8
|
+
Result of `AddressSheetGenerator` now have `pdf_content` and `zpl_content`.
|
9
|
+
- found new(?) API from Czech Post , see `documents/B2B-ZSKService-1.4.0.yaml` and https://www.ceskaposta.cz/napi/b2b.
|
10
|
+
|
5
11
|
## [1.2.8] - 2022-03-22
|
6
|
-
|
12
|
+
- added new response codes
|
7
13
|
|
8
14
|
## [1.2.6] - 2020-10-27
|
9
15
|
|
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
|
2
2
|
# FRESH NEWS
|
3
|
+
7.4.2022
|
4
|
+
Finally there is some online documentation about nAPI of Czech post (https://www.ceskaposta.cz/napi/b2b)
|
5
|
+
Not yet checked if this is the same api we use or new one. Seems that authorization is different.
|
6
|
+
|
7
|
+
|
8
|
+
26.8.2020
|
3
9
|
After full usage in production (vyvolej.to, squared.one), we found that Czech POst have trouble with `parcelServiceSync` (maybe `sendParcels` too). When You try to register package with `:customs_documents`, you get `INVALID_BATCH` response with no error, but with `parcelCode`:
|
4
10
|
```
|
5
11
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -9,6 +9,10 @@ module CzechPostB2bClient
|
|
9
9
|
class Base
|
10
10
|
class << self
|
11
11
|
attr_reader :id, :description, :page_dimensions
|
12
|
+
|
13
|
+
def content_type
|
14
|
+
:pdf
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
@@ -132,12 +136,6 @@ module CzechPostB2bClient
|
|
132
136
|
@page_dimensions = 'unverified'
|
133
137
|
end
|
134
138
|
|
135
|
-
class CODVoucherForCSOB < Base
|
136
|
-
@id = 13
|
137
|
-
@description = 'Dobírková složenka ČSOB'
|
138
|
-
@page_dimensions = 'unverified'
|
139
|
-
end
|
140
|
-
|
141
139
|
class RRLabels3x8 < Base
|
142
140
|
@id = 26
|
143
141
|
@description = 'štítky pro RR : 3x8'
|
@@ -175,29 +173,23 @@ module CzechPostB2bClient
|
|
175
173
|
@page_dimensions = 'A5 landscape (210 × 148 mm)'
|
176
174
|
end
|
177
175
|
|
178
|
-
class CN22FourOnPage < Base
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
class CN22WithCK < Base
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
class CN22WithCKFourOnPage < Base
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
class CN22FourOnPage < Base
|
198
|
-
@id = 74
|
199
|
-
@description = 'Celní prohlášení CN22 : 4x'
|
200
|
-
@page_dimensions = 'A4 portrait (210 × 297 mm)'
|
176
|
+
# class CN22FourOnPage < Base
|
177
|
+
# @id = 74
|
178
|
+
# @description = 'Celní prohlášení CN22 : 4x (A4)'
|
179
|
+
# @page_dimensions = 'unverified A4'
|
180
|
+
# end
|
181
|
+
|
182
|
+
# class CN22WithCK < Base
|
183
|
+
# @id = 75
|
184
|
+
# @description = 'Celní prohlášení CN22 s ČK (A4)'
|
185
|
+
# @page_dimensions = 'unverified A4'
|
186
|
+
# end
|
187
|
+
|
188
|
+
# class CN22WithCKFourOnPage < Base
|
189
|
+
# @id = 76
|
190
|
+
# @description = 'Celní prohlášení CN22 s ČK : 4x (A4)'
|
191
|
+
# @page_dimensions = 'unverified A4'
|
192
|
+
# end
|
201
193
|
end
|
202
194
|
|
203
195
|
module HarmonizedLabel
|
@@ -232,20 +224,28 @@ module CzechPostB2bClient
|
|
232
224
|
@description = 'Harmonizovaný štítek bianco - na výšku'
|
233
225
|
@page_dimensions = 'A6 landscape (148 × 105 mm)'
|
234
226
|
end
|
227
|
+
end
|
235
228
|
|
236
|
-
|
229
|
+
module ZebraLabel
|
230
|
+
class Base < CzechPostB2bClient::PrintingTemplates::Base
|
231
|
+
def self.content_type
|
232
|
+
:zpl
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
class Bianco105x148 < ZebraLabel::Base
|
237
237
|
@id = 200
|
238
238
|
@description = 'Harmonizovaný štítek bianco - (Zebra - 105x148); nejde o PDF'
|
239
239
|
@page_dimensions = 'unverified 105 × 148 mm'
|
240
240
|
end
|
241
241
|
|
242
|
-
class
|
242
|
+
class Bianco100x150 < ZebraLabel::Base
|
243
243
|
@id = 201
|
244
244
|
@description = 'Harmonizovaný štítek bianco - (Zebra - 100x150); nejde o PDF'
|
245
245
|
@page_dimensions = 'unverified 100 × 150 mm'
|
246
246
|
end
|
247
247
|
|
248
|
-
class
|
248
|
+
class Bianco100x125 < ZebraLabel::Base
|
249
249
|
@id = 202
|
250
250
|
@description = 'Harmonizovaný štítek bianco - (Zebra - 100x125); nejde o PDF'
|
251
251
|
@page_dimensions = 'unverified 100 × 125 mm'
|
@@ -257,5 +257,12 @@ module CzechPostB2bClient
|
|
257
257
|
base_class = CzechPostB2bClient::PrintingTemplates::Base
|
258
258
|
ObjectSpace.each_object(base_class.singleton_class).reject { |c| c == base_class }
|
259
259
|
end
|
260
|
+
|
261
|
+
def self.find(id)
|
262
|
+
klass = all_classes.detect { |k| k.id == id }
|
263
|
+
raise "PrintingTemplate with id: #{id} is unknown!" unless klass
|
264
|
+
|
265
|
+
klass
|
266
|
+
end
|
260
267
|
end
|
261
268
|
end
|
@@ -8,8 +8,8 @@ module CzechPostB2bClient
|
|
8
8
|
def build_result
|
9
9
|
super
|
10
10
|
@result[:response][:state] = state_hash_from(printing_response_header_result['doPrintingStateResponse'])
|
11
|
-
|
12
|
-
|
11
|
+
opt_hash = options_hash
|
12
|
+
@result[:printings] = { options: opt_hash }.merge(content_hash(opt_hash[:template_id]))
|
13
13
|
end
|
14
14
|
|
15
15
|
def options_hash
|
@@ -24,11 +24,23 @@ module CzechPostB2bClient
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
27
|
+
def content_hash(template_id)
|
28
|
+
if zpl_template?(template_id)
|
29
|
+
{ zpl_content: response_content.force_encoding('utf-8') }
|
30
|
+
else
|
31
|
+
{ pdf_content: response_content }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def zpl_template?(template_id)
|
36
|
+
CzechPostB2bClient::PrintingTemplates.find(template_id).content_type == :zpl
|
37
|
+
end
|
38
|
+
|
39
|
+
def response_content
|
40
|
+
content_encoded = response_root_node.dig('doPrintingDataResult', 'file')
|
41
|
+
return nil if content_encoded.nil?
|
30
42
|
|
31
|
-
::Base64.decode64(
|
43
|
+
::Base64.decode64(content_encoded)
|
32
44
|
end
|
33
45
|
|
34
46
|
def response_root_node_name
|
@@ -5,7 +5,7 @@ module CzechPostB2bClient
|
|
5
5
|
class AddressSheetsGenerator < CzechPostB2bClient::Services::Communicator
|
6
6
|
attr_reader :parcel_codes, :options
|
7
7
|
|
8
|
-
AddressSheetsGeneratorResult = Struct.new(:pdf_content, :state_text, :state_code, keyword_init: true)
|
8
|
+
AddressSheetsGeneratorResult = Struct.new(:pdf_content, :zpl_content, :state_text, :state_code, keyword_init: true)
|
9
9
|
|
10
10
|
def initialize(parcel_codes:, options: {})
|
11
11
|
super()
|
@@ -41,6 +41,7 @@ module CzechPostB2bClient
|
|
41
41
|
|
42
42
|
def build_result_from(response_hash)
|
43
43
|
AddressSheetsGeneratorResult.new(pdf_content: response_hash.dig(:printings, :pdf_content),
|
44
|
+
zpl_content: response_hash.dig(:printings, :zpl_content),
|
44
45
|
state_text: response_hash.dig(:response, :state, :text),
|
45
46
|
state_code: response_hash.dig(:response, :state, :code))
|
46
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: czech_post_b2b_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Mlčoch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ox
|