czech_post_b2b_client 1.2.3 → 1.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2a85b06fa34faeb7213e1441a6545383e8643f33
4
- data.tar.gz: 91bc102f0d2f2686b9d0e64fdb42db9ba7f295e6
2
+ SHA256:
3
+ metadata.gz: 468b92710ed75993d00a0f30f9a66a1e40ae8b23607ed92796c9682a0493f237
4
+ data.tar.gz: c48017f58f179a0dae607662c309a1eabb0b7370f7372521acdfb655983eff44
5
5
  SHA512:
6
- metadata.gz: 25c9c40f2da073568cdb86f391caf378b6a2005c17433486d8e88354e24bad2e0b388e3c2e4331e0b15f241fee1845b6ad9d541db2f2c624e86d869a9e649196
7
- data.tar.gz: 6ef1357723687047dc2483f262214a2a01b91f368119af7b1c2608713c7a12d9649bb22da65f28d8b3d005106b07e3a192fa581a668cb0529c0fdbf51d3a478c
6
+ metadata.gz: 3b6dd0a6c4bb96f076cb37a42ec1dd0ce08346f28285109079831bf3fe94eb2d45d054156119b80e846b3f22ed9a18f2ded82856f2345b394e05c2c7e0560c2a
7
+ data.tar.gz: 2a461713e123f67b66d45a02fab03123c75f7a9b968dede63351bbadc123baa74ab7a0be8648124643008602f35d372a5fcaf86d24e768bac4165ec85ceed773
@@ -2,6 +2,10 @@
2
2
 
3
3
  All changes to the gem are documented here.
4
4
 
5
+ ## [1.2.4] - 2020-10-06
6
+
7
+ - Added `configuration.log_messages_at_least_as` option, to be able debug client behaviour when app log level is higher (eg. production)
8
+
5
9
  ## [1.2.3] - 2020-08-21
6
10
 
7
11
  - Corrected order in XML `sequence` elements
data/README.md CHANGED
@@ -1,3 +1,40 @@
1
+
2
+ # FRESH NEWS
3
+ 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
+ ```
5
+ <?xml version="1.0" encoding="UTF-8"?>
6
+ <v1:b2bSyncResponse xmlns:v1="https://b2b.postaonline.cz/schema/B2BCommon-v1" xmlns:v1_1="https://b2b.postaonline.cz/schema/POLServices-v1">
7
+ <v1:header>
8
+ <v1:b2bRequestHeader>
9
+ <v1:idExtTransaction>1</v1:idExtTransaction>
10
+ <v1:timeStamp>2020-08-22T07:32:20.496Z</v1:timeStamp>
11
+ <v1:idContract>356936003</v1:idContract>
12
+ </v1:b2bRequestHeader>
13
+ </v1:header>
14
+ <v1:serviceData><v1_1:parcelServiceSyncResponse>
15
+ <v1_1:responseHeader>
16
+ <v1_1:resultHeader>
17
+ <v1_1:responseCode>19</v1_1:responseCode>
18
+ <v1_1:responseText>BATCH_INVALID</v1_1:responseText>
19
+ </v1_1:resultHeader>
20
+ <v1_1:resultParcelData>
21
+ <v1_1:recordNumber>52427</v1_1:recordNumber>
22
+ <v1_1:parcelCode>RR950819194CZ</v1_1:parcelCode>
23
+ <v1_1:parcelDataResponse>
24
+ <v1_1:responseCode>1</v1_1:responseCode>
25
+ <v1_1:responseText>OK</v1_1:responseText>
26
+ </v1_1:parcelDataResponse>
27
+ </v1_1:resultParcelData>
28
+ </v1_1:responseHeader>
29
+ </v1_1:parcelServiceSyncResponse></v1:serviceData>
30
+ </v1:b2bSyncResponse>
31
+ ```
32
+
33
+ *Reality is, that Parcel IS NOT registered!*
34
+
35
+ They say, that this should be fixed in v1.10 release. But nobody knows, when it will be deployed. And I do not know if there is some public way how to find, which version is now in production.
36
+
37
+
1
38
  # CzechPostB2bClient
2
39
  Accessing B2B API of Czech Post for bulk processing of parcels ("B2B - WS PodáníOnline").
3
40
 
@@ -71,6 +108,7 @@ CzechPostB2bClient.configure do |config|
71
108
  # config.language => :cs # other languages are not supported now
72
109
  # config.logger => ::Rails.logger or ::Logger.new(STDOUT),
73
110
  # config.b2b_api_base_uri => 'https://b2b.postaonline.cz/services/POLService/v1'
111
+ # config.log_messages_at_least_as = :debug
74
112
  end
75
113
  ```
76
114
 
@@ -5,6 +5,7 @@ require 'stepped_service'
5
5
 
6
6
  require 'czech_post_b2b_client/version'
7
7
  require 'czech_post_b2b_client/configuration'
8
+ require 'czech_post_b2b_client/logger'
8
9
 
9
10
  require 'czech_post_b2b_client/b2b_errors'
10
11
  require 'czech_post_b2b_client/response_codes'
@@ -26,7 +27,7 @@ module CzechPostB2bClient
26
27
  end
27
28
 
28
29
  def self.logger
29
- self.configuration.logger
30
+ CzechPostB2bClient::Logger.new(self.configuration)
30
31
  end
31
32
 
32
33
  def self.root
@@ -16,7 +16,8 @@ module CzechPostB2bClient
16
16
  :logger,
17
17
  :b2b_api_base_uri,
18
18
  :print_options,
19
- :custom_card_number
19
+ :custom_card_number,
20
+ :log_messages_at_least_as
20
21
 
21
22
  def initialize
22
23
  # set defaults here
@@ -34,6 +35,9 @@ module CzechPostB2bClient
34
35
  @logger = defined?(Rails) ? ::Rails.logger : ::Logger.new(STDOUT)
35
36
  @b2b_api_base_uri = 'https://b2b.postaonline.cz/services/POLService/v1'
36
37
  @sending_post_office_location_number = 1
38
+
39
+ # set this to :error in production for API debug logs in production.log
40
+ @log_messages_at_least_as = :debug # so all logs keeps their level
37
41
  end
38
42
  end
39
43
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module CzechPostB2bClient
6
+ class Logger
7
+ attr_reader :target_logger, :min_log_level
8
+
9
+ LEVELS = { debug: 0, info: 1, error: 2 }.freeze
10
+
11
+ def initialize(configuration)
12
+ @target_logger = configuration.logger
13
+ @min_log_level = configuration.log_messages_at_least_as
14
+ end
15
+
16
+ def log(original_level, message)
17
+ puts("#{message} #{original_level} => #{modified_log_level(original_level)}")
18
+ target_logger.send(modified_log_level(original_level), message)
19
+ end
20
+
21
+ LEVELS.each_key do |level|
22
+ define_method(level) { |message| log(level, message) }
23
+ end
24
+
25
+ private
26
+
27
+ def modified_log_level(original_level)
28
+ LEVELS[original_level] > LEVELS[min_log_level] ? original_level : min_log_level
29
+ end
30
+ end
31
+ end
@@ -29,7 +29,7 @@ module CzechPostB2bClient
29
29
 
30
30
  def service_data_struct
31
31
  new_element('serviceData').tap do |srv_data|
32
- add_element_to(srv_data, send_parcels)
32
+ add_element_to(srv_data, parcel_service_sync)
33
33
  end
34
34
  end
35
35
 
@@ -65,7 +65,7 @@ module CzechPostB2bClient
65
65
  end
66
66
  end
67
67
 
68
- def send_parcels
68
+ def parcel_service_sync
69
69
  new_element('ns2:parcelServiceSyncRequest').tap do |ps_sync_request|
70
70
  add_element_to(ps_sync_request, do_parcel_header) # REQUIRED
71
71
  add_element_to(ps_sync_request, do_parcel_data) # optional
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CzechPostB2bClient
4
- VERSION = '1.2.3'
4
+ VERSION = '1.2.4'
5
5
  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.2.3
4
+ version: 1.2.4
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: 2020-08-21 00:00:00.000000000 Z
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ox
@@ -614,6 +614,7 @@ files:
614
614
  - lib/czech_post_b2b_client.rb
615
615
  - lib/czech_post_b2b_client/b2b_errors.rb
616
616
  - lib/czech_post_b2b_client/configuration.rb
617
+ - lib/czech_post_b2b_client/logger.rb
617
618
  - lib/czech_post_b2b_client/post_services.rb
618
619
  - lib/czech_post_b2b_client/printing_templates.rb
619
620
  - lib/czech_post_b2b_client/request_builders.rb
@@ -674,8 +675,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
674
675
  - !ruby/object:Gem::Version
675
676
  version: '0'
676
677
  requirements: []
677
- rubyforge_project:
678
- rubygems_version: 2.6.11
678
+ rubygems_version: 3.1.2
679
679
  signing_key:
680
680
  specification_version: 4
681
681
  summary: Accessing B2B API of Czech Post for bulk processing of packages ("B2B - WS