colissimo_label 0.3.0 → 0.4.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +51 -2
- data/lib/colissimo_label/find_relay_point.rb +78 -0
- data/lib/colissimo_label/version.rb +1 -1
- data/lib/colissimo_label.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b20cf6d60590b5b229d08dca579e8526540718702f0818282369af8de9568d7
|
4
|
+
data.tar.gz: 6138fdc5edc70493a52af72104ce6df8a5b8f6f060779d5eb3baf63821bae8ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4eb97e5a3e6d55a8fe22895bfb31b6cd7a5d5df0f7c6b21ee8edf40ed5b1e655c1aef84dd2d9017474ae240d51c96d49f46e4cdfef3dca7c8a3d505472b1bb0
|
7
|
+
data.tar.gz: 2b68731fb099899fe85e593dcfc6412e857cc02eb5cd28fec1d838681e11cc1adfb67a12dbe1a5481877f96908f1f01122228a3a7d683096a0237ddf723be6a4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -58,6 +58,55 @@ ColissimoLabel.colissimo_local_path = Rails.root.join('public', 'colissimo')
|
|
58
58
|
|
59
59
|
## Usage
|
60
60
|
|
61
|
+
### Fetch relay points
|
62
|
+
|
63
|
+
Colissimo webservices provides all relay points around an address.
|
64
|
+
|
65
|
+
To get all available relay :
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
relay_points = ColissimoLabel::FindRelayPoint.new(
|
69
|
+
{
|
70
|
+
address: 'Address',
|
71
|
+
city: 'City',
|
72
|
+
postcode: 'Postcode',
|
73
|
+
country_code: 'Normalized country code (ex: FR)'
|
74
|
+
},
|
75
|
+
(Date.today + 5.days).strftime('%d/%m/%Y'), # Estimated departure date of the package
|
76
|
+
1000 # Computed weight of the package (in grams)
|
77
|
+
).perform
|
78
|
+
```
|
79
|
+
|
80
|
+
It will return an array of relay points with the following data:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
{
|
84
|
+
:pickup_id,
|
85
|
+
:name,
|
86
|
+
:address,
|
87
|
+
:postcode,
|
88
|
+
:city,
|
89
|
+
:country,
|
90
|
+
:country_code,
|
91
|
+
:latitude,
|
92
|
+
:longitude,
|
93
|
+
:distance,
|
94
|
+
:max_weight,
|
95
|
+
:parking,
|
96
|
+
business_hours: {
|
97
|
+
:monday,
|
98
|
+
:tuesday,
|
99
|
+
:wednesday,
|
100
|
+
:thursday,
|
101
|
+
:friday,
|
102
|
+
:saturday,
|
103
|
+
:sunday
|
104
|
+
}
|
105
|
+
}
|
106
|
+
```
|
107
|
+
|
108
|
+
### Generate Colissimo label
|
109
|
+
|
61
110
|
To generate a new Colissimo label, use the following methods.
|
62
111
|
|
63
112
|
For a national address:
|
@@ -72,7 +121,7 @@ parcel_number = ColissimoLabel::GenerateLabel.new(
|
|
72
121
|
address: 'Address',
|
73
122
|
city: 'City',
|
74
123
|
postcode: 'Postcode',
|
75
|
-
country_code: 'Normalized country code'
|
124
|
+
country_code: 'Normalized country code (ex: FR)'
|
76
125
|
},
|
77
126
|
{
|
78
127
|
last_name: 'Last name of the addressee',
|
@@ -101,7 +150,7 @@ parcel_number = ColissimoLabel::GenerateLabel.new(
|
|
101
150
|
address: 'Address',
|
102
151
|
city: 'City',
|
103
152
|
postcode: 'Postcode',
|
104
|
-
country_code: 'Normalized country code'
|
153
|
+
country_code: 'Normalized country code (ex: DE)'
|
105
154
|
},
|
106
155
|
{
|
107
156
|
last_name: 'Last name of the addressee',
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'http'
|
4
|
+
|
5
|
+
class ColissimoLabel::FindRelayPoint
|
6
|
+
|
7
|
+
def initialize(addressee_data, estimated_delivery_date, weight_package)
|
8
|
+
@addressee_data = addressee_data
|
9
|
+
@estimated_delivery_date = estimated_delivery_date
|
10
|
+
@weight_package = weight_package
|
11
|
+
@errors = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform
|
15
|
+
response = perform_request
|
16
|
+
status = response.code
|
17
|
+
soap_response = response.to_param
|
18
|
+
|
19
|
+
raise StandardError, soap_response if status != 200
|
20
|
+
|
21
|
+
parse = Nokogiri::XML(soap_response)
|
22
|
+
root = parse.root
|
23
|
+
error_code = root.xpath('//errorCode').text
|
24
|
+
error_message = root.xpath('//errorMessage').text
|
25
|
+
|
26
|
+
raise StandardError, error_message if error_code != '0'
|
27
|
+
|
28
|
+
root.xpath('//listePointRetraitAcheminement').map do |point|
|
29
|
+
{
|
30
|
+
pickup_id: point.at_xpath('identifiant').text,
|
31
|
+
name: point.at_xpath('nom').text,
|
32
|
+
address: [point.at_xpath('adresse1'), point.at_xpath('adresse2'), point.at_xpath('adresse3')].map(&:text).select(&:present?).join(' '),
|
33
|
+
postcode: point.at_xpath('codePostal').text,
|
34
|
+
city: point.at_xpath('localite').text,
|
35
|
+
country: point.at_xpath('libellePays').text,
|
36
|
+
country_code: point.at_xpath('codePays').text,
|
37
|
+
latitude: point.at_xpath('coordGeolocalisationLatitude').text.to_f,
|
38
|
+
longitude: point.at_xpath('coordGeolocalisationLongitude').text.to_f,
|
39
|
+
distance: point.at_xpath('distanceEnMetre').text.to_i,
|
40
|
+
max_weight: point.at_xpath('poidsMaxi').text.to_i,
|
41
|
+
parking: point.at_xpath('parking').text.to_b,
|
42
|
+
business_hours: {
|
43
|
+
monday: point.at_xpath('horairesOuvertureLundi').text,
|
44
|
+
tuesday: point.at_xpath('horairesOuvertureMardi').text,
|
45
|
+
wednesday: point.at_xpath('horairesOuvertureMercredi').text,
|
46
|
+
thursday: point.at_xpath('horairesOuvertureJeudi').text,
|
47
|
+
friday: point.at_xpath('horairesOuvertureVendredi').text,
|
48
|
+
saturday: point.at_xpath('horairesOuvertureSamedi').text,
|
49
|
+
sunday: point.at_xpath('horairesOuvertureDimanche').text
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def perform_request
|
58
|
+
HTTP.get(service_url,
|
59
|
+
params: {
|
60
|
+
accountNumber: ColissimoLabel.contract_number,
|
61
|
+
password: ColissimoLabel.contract_password,
|
62
|
+
address: @addressee_data[:address],
|
63
|
+
zipCode: @addressee_data[:postcode],
|
64
|
+
city: @addressee_data[:city],
|
65
|
+
countryCode: @addressee_data[:country_code],
|
66
|
+
shippingDate: @estimated_delivery_date,
|
67
|
+
weight: @weight_package
|
68
|
+
}.compact)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Services =>
|
72
|
+
# findRDVPointRetraitAcheminement : à partir d’une adresse postale fournie en entrée, restitue les points de retrait les plus proches de cette adresse
|
73
|
+
# findPointRetraitAcheminementByID : à partir d’un Identifiant de Point Retrait (identifiant Point Retrait), restitue le détail des informations associé au Point Retrait transmis
|
74
|
+
def service_url(service = 'findRDVPointRetraitAcheminement')
|
75
|
+
"https://ws.colissimo.fr/pointretrait-ws-cxf/PointRetraitServiceWS/2.0/#{service}"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
data/lib/colissimo_label.rb
CHANGED
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.4.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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- bin/setup
|
160
160
|
- colissimo_label.gemspec
|
161
161
|
- lib/colissimo_label.rb
|
162
|
+
- lib/colissimo_label/find_relay_point.rb
|
162
163
|
- lib/colissimo_label/generate_label.rb
|
163
164
|
- lib/colissimo_label/logger.rb
|
164
165
|
- lib/colissimo_label/version.rb
|