colissimo_label 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +34 -3
- data/lib/colissimo_label/find_relay_point.rb +2 -0
- data/lib/colissimo_label/generate_label.rb +20 -10
- data/lib/colissimo_label/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: b85e62f1503ab7a596c1f5fadb2f0a9e1ea0d94bc34e61c027961aeb9f2d5dd9
|
4
|
+
data.tar.gz: b9d1cc9d6c14b846b61f33804093e50b759322d07af2fdc49aa0dda7c3c8063f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0282ebd5555cf445a89cdac2d320dc610ab4fa1d599bca81e305af3b68540c39fa0a41ae5dd18ceb89aa6ebf9ec36f6ac9c614089131ed893fabae0ab1aa2ea
|
7
|
+
data.tar.gz: 93167be7de54a135e7c15106c4e17aa7cba5e67932ee09a724db2bcc4c36fee7c529836d668bccf06949868d2daaa399746ae8945880a4cc29c67e96dd94e4e4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -79,7 +79,7 @@ To get all available relay :
|
|
79
79
|
|
80
80
|
It will return an array of relay points with the following data:
|
81
81
|
|
82
|
-
```
|
82
|
+
```
|
83
83
|
{
|
84
84
|
:pickup_id,
|
85
85
|
:name,
|
@@ -138,6 +138,37 @@ parcel_number = ColissimoLabel::GenerateLabel.new(
|
|
138
138
|
).perform
|
139
139
|
```
|
140
140
|
|
141
|
+
For a national address and delivered to a relay point:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
parcel_number = ColissimoLabel::GenerateLabel.new(
|
145
|
+
'label_filename', # Name of the file generated
|
146
|
+
'FR', # Normalized country code of the destination
|
147
|
+
9.99, # Amount of the shipping fees (paid by the customer)
|
148
|
+
{
|
149
|
+
company_name: 'Sender company name',
|
150
|
+
address: 'Address',
|
151
|
+
city: 'City',
|
152
|
+
postcode: 'Postcode',
|
153
|
+
country_code: 'Normalized country code (ex: FR)'
|
154
|
+
},
|
155
|
+
{
|
156
|
+
last_name: 'Last name of the addressee',
|
157
|
+
first_name: 'First name of the addressee',
|
158
|
+
address_bis: 'Address bis of the addressee',
|
159
|
+
address: 'Address of the addressee',
|
160
|
+
city: 'City of the addressee',
|
161
|
+
postcode: 'Postcode of the addressee',
|
162
|
+
country_code: 'Normalized country code of the addressee',
|
163
|
+
phone: 'Phone number of the addressee',
|
164
|
+
mobile: 'Mobile number of the addressee',
|
165
|
+
email: 'Email of the addressee'
|
166
|
+
},
|
167
|
+
pickup_id: 'pickup ID',
|
168
|
+
pickup_type: 'BPR or A2P'
|
169
|
+
).perform
|
170
|
+
```
|
171
|
+
|
141
172
|
For a foreign address (which required customs declaration):
|
142
173
|
|
143
174
|
```ruby
|
@@ -164,8 +195,8 @@ parcel_number = ColissimoLabel::GenerateLabel.new(
|
|
164
195
|
mobile: 'Mobile number of the addressee',
|
165
196
|
email: 'Email of the addressee'
|
166
197
|
},
|
167
|
-
2, # Total weight of the package
|
168
|
-
[ # Details content of your package
|
198
|
+
customs_total_weight: 2, # Total weight of the package
|
199
|
+
customs_data: [ # Details content of your package
|
169
200
|
{
|
170
201
|
description: 'Product description',
|
171
202
|
quantity: 1,
|
@@ -28,6 +28,8 @@ class ColissimoLabel::FindRelayPoint
|
|
28
28
|
root.xpath('//listePointRetraitAcheminement').map do |point|
|
29
29
|
{
|
30
30
|
pickup_id: point.at_xpath('identifiant').text,
|
31
|
+
pickup_type: point.at_xpath('typeDePoint
|
32
|
+
').text,
|
31
33
|
name: point.at_xpath('nom').text,
|
32
34
|
address: [point.at_xpath('adresse1'), point.at_xpath('adresse2'), point.at_xpath('adresse3')].map(&:text).select(&:present?).join(' '),
|
33
35
|
postcode: point.at_xpath('codePostal').text,
|
@@ -4,14 +4,16 @@ require 'http'
|
|
4
4
|
|
5
5
|
class ColissimoLabel::GenerateLabel
|
6
6
|
|
7
|
-
def initialize(filename, destination_country, shipping_fees, sender_data, addressee_data,
|
7
|
+
def initialize(filename, destination_country, shipping_fees, sender_data, addressee_data, options = {})
|
8
8
|
@filename = filename
|
9
9
|
@destination_country = destination_country
|
10
10
|
@shipping_fees = shipping_fees
|
11
11
|
@sender_data = sender_data
|
12
12
|
@addressee_data = addressee_data
|
13
|
-
@
|
14
|
-
@
|
13
|
+
@pickup_id = options.fetch(:pickup_id, nil)
|
14
|
+
@pickup_type = options.fetch(:pickup_type, nil)
|
15
|
+
@customs_total_weight = options.fetch(:customs_total_weight, nil)
|
16
|
+
@customs_data = options.fetch(:customs_data, nil)
|
15
17
|
@errors = []
|
16
18
|
end
|
17
19
|
|
@@ -67,14 +69,16 @@ class ColissimoLabel::GenerateLabel
|
|
67
69
|
},
|
68
70
|
"letter": {
|
69
71
|
"service": {
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
72
|
+
"commercialName": @sender_data[:company_name],
|
73
|
+
"productCode": product_code,
|
74
|
+
"depositDate": delivery_date.strftime('%F'),
|
75
|
+
"totalAmount": (@shipping_fees * 100).to_i,
|
73
76
|
# "returnTypeChoice": '2' # Retour à la maison en prioritaire
|
74
77
|
},
|
75
78
|
"parcel": {
|
76
|
-
|
77
|
-
|
79
|
+
"weight": format_weight,
|
80
|
+
"pickupLocationId": @pickup_id
|
81
|
+
}.compact,
|
78
82
|
"sender": {
|
79
83
|
"address": format_sender
|
80
84
|
},
|
@@ -118,7 +122,7 @@ class ColissimoLabel::GenerateLabel
|
|
118
122
|
"city": @addressee_data[:city], # Ville
|
119
123
|
"zipCode": @addressee_data[:postcode], # Code postal
|
120
124
|
"phoneNumber": @addressee_data[:phone], # Numéro de téléphone
|
121
|
-
"mobileNumber": @addressee_data[:mobile], # Numéro de portable
|
125
|
+
"mobileNumber": @addressee_data[:mobile], # Numéro de portable, obligatoire si pickup
|
122
126
|
"doorCode1": @addressee_data[:door_code_1], # Code porte 1
|
123
127
|
"doorCode2": @addressee_data[:door_code_2], # Code porte 2
|
124
128
|
"email": @addressee_data[:email], # Adresse courriel
|
@@ -175,11 +179,17 @@ class ColissimoLabel::GenerateLabel
|
|
175
179
|
%w[CH].include?(@destination_country)
|
176
180
|
end
|
177
181
|
|
178
|
-
# DOM : Colissimo France et International sans signature / DOS : Colissimo France et International avec signature
|
179
182
|
# Certains pays, comme l'Allemagne, requiert une signature pour la livraison
|
183
|
+
# DOM : Colissimo France et International sans signature
|
184
|
+
# DOS : Colissimo France et International avec signature
|
185
|
+
# Pays avec Point Relais : https://www.colissimo.entreprise.laposte.fr/fr/offre-europe
|
186
|
+
# BPR : Colissimo - Point Retrait – en Bureau de Poste
|
187
|
+
# A2P : Colissimo - Point Retrait – en relais Pickup ou en consigne Pickup Station
|
180
188
|
def product_code
|
181
189
|
if %w[DE IT GB LU].include?(@destination_country)
|
182
190
|
'DOS'
|
191
|
+
elsif !@pickup_id.nil? && %w[FR].include?(@destination_country)
|
192
|
+
@pickup_type || 'BPR'
|
183
193
|
else
|
184
194
|
'DOM'
|
185
195
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FloXcoder
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|