colissimo_label 0.13.0 → 0.18.0

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: 3839699e6df747be915fcfdbcdf6e4c1379d5a4416d8abb2192c6f375e304b20
4
- data.tar.gz: af49d9fa2eabdee0eab4e7f66a26143936c6bad91ce3941c75909b92b97fbb9e
3
+ metadata.gz: e85c64c5c035a54da59c9695851ad8be29dc0083353f10065dc2b35e9088ee5e
4
+ data.tar.gz: 863ca8375cdf9bacafde3fea451fd695051d3bee5b5b52d1f2f44c606637a441
5
5
  SHA512:
6
- metadata.gz: a75c052a57417f1026dc313bf2a1145864fdf0a33c0d5d01a226c6ce7128ee06d9658ee19fcc81739c4c6a09ea14aa0fe7cfdcada17db27e7fca2a36025a0887
7
- data.tar.gz: ff5615cbdc6966a449edbfca3de8fc1410ca02ff931c0b0ed1f901b244260c5318e216425c7f39e1f51d3d6020f215e7dce122268026edeea28b8d25c435e8d1
6
+ metadata.gz: 395bd4aa3613b9e253dd641e38d74ed3205768e47ada8d6d07a06372225aa2afd5476b99c4736393b163192e405d832ef08059b3eabeef589a3877887d94e7a0
7
+ data.tar.gz: 4982d55a321d6579a3655c0a3306bd09396a34db819a410fc308931439701a55178da0bdee852674ec2becfa749a71a4c9eb363c1c7a10bcacdcd628f03088b9
@@ -1,3 +1,23 @@
1
+ ## 0.18.0
2
+
3
+ - Add new fields for UK after Brexit
4
+
5
+ ## 0.17.0
6
+
7
+ - Add Sweden to mandatory signature countries
8
+
9
+ ## 0.16.0
10
+
11
+ - Use correct default value for insurance
12
+
13
+ ## 0.15.0
14
+
15
+ - Comment insurance value
16
+
17
+ ## 0.14.0
18
+
19
+ - Ensure local path is present
20
+
1
21
  ## 0.13.0
2
22
 
3
23
  - Multiple improvements
@@ -16,7 +16,8 @@ class ColissimoLabel::GenerateLabel
16
16
  @customs_total_weight = options.fetch(:customs_total_weight, nil)
17
17
  @customs_data = options.fetch(:customs_data, nil)
18
18
  @with_signature = options.fetch(:with_signature, false)
19
- @insurance_value = options.fetch(:insurance_value, false)
19
+ @insurance_value = options.fetch(:insurance_value, nil)
20
+ @eori_number = options.fetch(:eori_number, nil)
20
21
  @label_output_format = options.fetch(:label_output_format, 'PDF_10x15_300dpi')
21
22
  @errors = []
22
23
  end
@@ -26,7 +27,7 @@ class ColissimoLabel::GenerateLabel
26
27
  status = response.code
27
28
  parts = response.to_a.last.force_encoding('BINARY').split('Content-ID: ')
28
29
  label_filename = @filename + '.' + file_format
29
- local_path = ColissimoLabel.colissimo_local_path.chomp('/')
30
+ local_path = ColissimoLabel.colissimo_local_path&.chomp('/')
30
31
 
31
32
  if ColissimoLabel.s3_bucket
32
33
  colissimo_pdf = ColissimoLabel.s3_bucket.object(ColissimoLabel.s3_path.chomp('/') + '/' + label_filename)
@@ -50,7 +51,7 @@ class ColissimoLabel::GenerateLabel
50
51
  end
51
52
  end
52
53
 
53
- if status == 400
54
+ if status == 400 || status == 500
54
55
  error_message = response.body.to_s.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').scan(/"messageContent":"(.*?)"/).last&.first
55
56
  raise StandardError, error_message
56
57
  elsif status == 503
@@ -98,8 +99,9 @@ class ColissimoLabel::GenerateLabel
98
99
  "addressee": {
99
100
  "address": format_addressee
100
101
  }
101
- }.merge(customs)
102
- }.compact)
102
+ }.merge(customs_letter)
103
+ }.merge(customs_fields)
104
+ .compact)
103
105
  end
104
106
 
105
107
  # Services =>
@@ -168,7 +170,7 @@ class ColissimoLabel::GenerateLabel
168
170
  end
169
171
 
170
172
  # Déclaration douanière de type CN23
171
- def customs
173
+ def customs_letter
172
174
  if require_customs?
173
175
  {
174
176
  "customsDeclarations": {
@@ -203,8 +205,25 @@ class ColissimoLabel::GenerateLabel
203
205
  end
204
206
  end
205
207
 
208
+ def customs_fields
209
+ if require_customs?
210
+ {
211
+ "fields": {
212
+ "customField": [
213
+ {
214
+ "key": 'EORI',
215
+ "value": @eori_number
216
+ }
217
+ ]
218
+ }
219
+ }
220
+ else
221
+ {}
222
+ end
223
+ end
224
+
206
225
  def require_customs?
207
- %w[CH NO US].include?(@destination_country)
226
+ %w[CH NO US GB].include?(@destination_country)
208
227
  end
209
228
 
210
229
  # Certains pays, comme l'Allemagne, requiert une signature pour la livraison
@@ -214,7 +233,7 @@ class ColissimoLabel::GenerateLabel
214
233
  # BPR : Colissimo - Point Retrait – en Bureau de Poste
215
234
  # A2P : Colissimo - Point Retrait – en relais Pickup ou en consigne Pickup Station
216
235
  def product_code
217
- if %w[DE IT ES GB LU NL DK AT].include?(@destination_country)
236
+ if %w[DE IT ES GB LU NL DK AT SE].include?(@destination_country)
218
237
  'DOS'
219
238
  elsif !@pickup_id.nil? && %w[FR].include?(@destination_country)
220
239
  @pickup_type || 'BPR'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ColissimoLabel
4
- VERSION = '0.13.0'.freeze
4
+ VERSION = '0.18.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colissimo_label
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FloXcoder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-07 00:00:00.000000000 Z
11
+ date: 2021-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  - !ruby/object:Gem::Version
183
183
  version: '0'
184
184
  requirements: []
185
- rubygems_version: 3.1.3
185
+ rubygems_version: 3.2.4
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Generate Colissimo label for all countries