dhl-intraship 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +40 -10
- data/dhl-intraship.gemspec +3 -3
- data/lib/dhl-intraship/address.rb +2 -12
- data/lib/dhl-intraship/api.rb +112 -47
- data/lib/dhl-intraship/booking_information.rb +46 -0
- data/lib/dhl-intraship/version.rb +1 -1
- data/spec/dhl-intraship/book_pickup_spec.rb +62 -0
- data/spec/dhl-intraship/create_shipment_dd_spec.rb +1 -1
- data/spec/dhl-intraship/do_manifest_dd_spec.rb +81 -0
- data/spec/spec_helper.rb +5 -5
- metadata +14 -11
- data/spec/dhl-intraship/address_spec.rb +0 -16
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Dhl::Intraship
|
2
2
|
|
3
|
-
This is a simple gem to wrap the DHL Intraship SOAP Api. Note that currently only
|
4
|
-
|
3
|
+
This is a simple gem to wrap the DHL Intraship SOAP Api. Note that currently only "national day definite shipment" usecases are implemented (Sending, deleting and manifesting national day definite packages without any extra services.)
|
4
|
+
Booking a pickup is implemented as prototype, but not yet supported by DHL itself.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -43,7 +43,10 @@ options = {test: true, # If test is set, all API calls go against the Intraship
|
|
43
43
|
label_response_type: :xml} # If it's set to XML the createShipment-Calls return the label data as XML instead of the PDF-Link
|
44
44
|
```
|
45
45
|
|
46
|
-
|
46
|
+
### Create a shipment
|
47
|
+
|
48
|
+
To create a shipment to DHL you need to create it first
|
49
|
+
|
47
50
|
|
48
51
|
```ruby
|
49
52
|
sender_address = Dhl::Intraship::CompanyAddress.new(company: 'Team Europe Ventures',
|
@@ -54,7 +57,6 @@ sender_address = Dhl::Intraship::CompanyAddress.new(company: 'Team Europe Ventur
|
|
54
57
|
city: 'Berlin',
|
55
58
|
country_code: 'DE',
|
56
59
|
email: 'info@teameurope.net')
|
57
|
-
|
58
60
|
receiver_address = Dhl::Intraship::PersonAddress.new(firstname: 'John',
|
59
61
|
lastname: 'Doe',
|
60
62
|
street: 'Mainstreet',
|
@@ -64,8 +66,7 @@ receiver_address = Dhl::Intraship::PersonAddress.new(firstname: 'John',
|
|
64
66
|
city: 'Springfield',
|
65
67
|
country_code: 'DE',
|
66
68
|
email: 'john.doe@example.com')
|
67
|
-
|
68
|
-
# Note that the weight parameter is in kg and the length/height/width in cm
|
69
|
+
#Note that the weight parameter is in kg and the length/height/width in cm
|
69
70
|
shipment = Dhl::Intraship::Shipment.new(sender_address: sender_address,
|
70
71
|
receiver_address: receiver_address,
|
71
72
|
shipment_date: Date.today,
|
@@ -74,15 +75,44 @@ shipment = Dhl::Intraship::Shipment.new(sender_address: sender_address,
|
|
74
75
|
height:15,
|
75
76
|
width: 25)
|
76
77
|
```
|
77
|
-
|
78
|
+
|
79
|
+
Beware, that due to DHL Intraship restrictions, the sender address must be a
|
78
80
|
CompanyAddress and requires a contact_person.
|
79
|
-
|
81
|
+
The actual api-call takes an array of shipments, or a single shipment.
|
82
|
+
The result contains the "shipment_number", as well as the "label_url" (or the "xml_label" when it was specified as repsonse type)
|
80
83
|
|
81
84
|
```ruby
|
82
|
-
result = api.createShipmentDD(
|
85
|
+
result = api.createShipmentDD(shipment)
|
86
|
+
shipment_number = result[:shipment_number]
|
87
|
+
label_url = result[:label_url] # Or result[:xml_label] in case XML label was set in the options
|
83
88
|
```
|
84
89
|
|
85
|
-
|
90
|
+
### Delete a shipment
|
91
|
+
|
92
|
+
You can create and delete shipments as much as you like, they will not get into the "real" DHL system until you manifest them.
|
93
|
+
To delete a shipment call deleteShipmentDD with the shipment number for a non-manifested shipment:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
api.deleteShipmentDD(shipment_number)
|
97
|
+
```
|
98
|
+
|
99
|
+
### Manifesting a shipment
|
100
|
+
|
101
|
+
A shipment created in Intraship is only transferred to the "real" DHL systems after the shipment is manifested.
|
102
|
+
If "manifestShipment" is not called manually, it should be automatically manifested after the time that is configured in the Intraship backend.
|
103
|
+
To manifest the shipment manually call:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
api.doManifestDD(shipment_number)
|
107
|
+
```
|
108
|
+
|
109
|
+
*Note that the label has to be downloaded at least once, or Intraship will reply with status code 2030: shipment not printed*
|
110
|
+
|
111
|
+
### Booking a pickup
|
112
|
+
|
113
|
+
*The "book pickup"-call is defined in the Intraship API and also supported in this gem, but not implemented and supported in Intraship itself*
|
114
|
+
|
115
|
+
The API will complain if no "contact orderer" is specified, although it's supposed to be optional. Furthermore issuing a "book pickup" call will yield a "Please select a product in the shipment details." (1102) error, although the call is completely valid.
|
86
116
|
|
87
117
|
## Contributing
|
88
118
|
|
data/dhl-intraship.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.summary = %q{This wraps the DHL Intraship SOAP Interface for creating shipments}
|
9
9
|
gem.homepage = "https://github.com/teameurope/dhl-intraship"
|
10
10
|
|
11
|
-
gem.add_dependency "savon", "~>
|
12
|
-
gem.add_development_dependency "rspec", "~> 2.
|
13
|
-
gem.add_development_dependency "savon_spec", "~>
|
11
|
+
gem.add_dependency "savon", "~> 1.1.0"
|
12
|
+
gem.add_development_dependency "rspec", "~> 2.11.0"
|
13
|
+
gem.add_development_dependency "savon_spec", "~> 1.3.0"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($\)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -2,7 +2,7 @@ module Dhl
|
|
2
2
|
module Intraship
|
3
3
|
class Address
|
4
4
|
attr_accessor :street, :house_number, :street_additional, :street_additional_above_street,
|
5
|
-
:zip, :city, :country_code, :email
|
5
|
+
:zip, :city, :country_code, :email, :phone
|
6
6
|
|
7
7
|
def initialize(attributes = {})
|
8
8
|
self.street_additional_above_street = true
|
@@ -27,17 +27,6 @@ module Dhl
|
|
27
27
|
@country_code = country_code
|
28
28
|
end
|
29
29
|
|
30
|
-
# Note: DHL rejects valid email addresses containing the + sign
|
31
|
-
def email=(email)
|
32
|
-
split = email.split('@')
|
33
|
-
local_part = split[0]
|
34
|
-
if local_part.include?('+')
|
35
|
-
local_part = local_part.split('+')[0]
|
36
|
-
end
|
37
|
-
|
38
|
-
@email = "#{local_part}@#{split[1]}"
|
39
|
-
end
|
40
|
-
|
41
30
|
def append_to_xml(xml)
|
42
31
|
xml.Company do |xml|
|
43
32
|
company_xml(xml)
|
@@ -61,6 +50,7 @@ module Dhl
|
|
61
50
|
end
|
62
51
|
end
|
63
52
|
xml.Communication do |xml|
|
53
|
+
xml.cis(:phone, self.phone) unless self.phone.blank?
|
64
54
|
xml.cis(:email, self.email) unless self.email.blank?
|
65
55
|
communication_xml(xml)
|
66
56
|
end
|
data/lib/dhl-intraship/api.rb
CHANGED
@@ -15,38 +15,38 @@ module Dhl
|
|
15
15
|
INTRASHIP_TEST_WSDL = "http://test-intraship.dhl.com/ws/1_0/ISService/DE.wsdl"
|
16
16
|
INTRASHIP_TEST_ENDPOINT = "http://test-intraship.dhl.com/ws/1_0/de/ISService"
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
18
|
+
def initialize(config, options = {})
|
19
|
+
raise "User must be specified" if config[:user].nil?
|
20
|
+
raise "Signature (password) must be specified" if config[:signature].nil?
|
21
|
+
raise "EKP (first part of the DHL account number) must be specified" if config[:ekp].nil?
|
22
|
+
|
23
|
+
if options[:test]
|
24
|
+
wsdl_url = INTRASHIP_TEST_WSDL
|
25
|
+
endpoint = INTRASHIP_TEST_ENDPOINT
|
26
|
+
else
|
27
|
+
wsdl_url = INTRASHIP_WSDL
|
28
|
+
endpoint = INTRASHIP_ENDPOINT
|
29
|
+
end
|
30
|
+
|
31
|
+
@user = config[:user]
|
32
|
+
@signature = config[:signature]
|
33
|
+
@ekp = config[:ekp]
|
34
|
+
@procedure_id = config[:procedure_id] || '01'
|
35
|
+
@partner_id = config[:partner_id] || '01'
|
36
|
+
|
37
|
+
@options = options
|
38
|
+
@client = ::Savon::Client.new do
|
39
|
+
wsdl.document = wsdl_url
|
40
|
+
wsdl.endpoint = endpoint
|
41
|
+
end
|
42
|
+
end
|
43
43
|
|
44
44
|
def createShipmentDD(shipments)
|
45
45
|
begin
|
46
46
|
shipments = [shipments] unless shipments.respond_to?('each')
|
47
47
|
|
48
48
|
# For some reason the class instance variables are not accessible inside of the request block
|
49
|
-
|
49
|
+
ekp = @ekp
|
50
50
|
partner_id = @partner_id
|
51
51
|
|
52
52
|
returnXML = @config && @config[:label_response_type] && @config[:label_response_type] == :xml;
|
@@ -58,10 +58,7 @@ module Dhl
|
|
58
58
|
end
|
59
59
|
xml.soapenv(:Body) do |xml|
|
60
60
|
xml.de(:"CreateShipmentDDRequest") do |xml|
|
61
|
-
xml
|
62
|
-
xml.cis(:majorRelease, '1')
|
63
|
-
xml.cis(:minorRelease, '0')
|
64
|
-
end
|
61
|
+
add_version_information(xml)
|
65
62
|
xml.ShipmentOrder do |xml|
|
66
63
|
xml.SequenceNumber('1')
|
67
64
|
shipments.each do |shipment|
|
@@ -96,39 +93,80 @@ module Dhl
|
|
96
93
|
|
97
94
|
def deleteShipmentDD(shipment_number)
|
98
95
|
begin
|
99
|
-
result =
|
96
|
+
result = do_simple_shipment_number_only_request('DeleteShipmentDDRequest', shipment_number)
|
97
|
+
r = result.to_hash[:delete_shipment_response]
|
98
|
+
|
99
|
+
# Return true if successful
|
100
|
+
raise "Intraship call failed with code #{r[:status][:status_code]}: #{r[:status][:status_message]} (Status messages: #{r[:deletion_state][:status].to_s})" unless r[:status][:status_code] == '0'
|
101
|
+
|
102
|
+
true
|
103
|
+
rescue Savon::Error => error
|
104
|
+
raise error
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def doManifestDD(shipment_number)
|
109
|
+
begin
|
110
|
+
result = do_simple_shipment_number_only_request('DoManifestDDRequest', shipment_number)
|
111
|
+
r = result.to_hash[:do_manifest_response]
|
112
|
+
|
113
|
+
raise "Intraship call failed with code #{r[:status][:status_code]}: #{r[:status][:status_message]} (Status messages: #{r[:manifest_state][:status].to_s})" unless r[:status][:status_code] == '0'
|
114
|
+
|
115
|
+
true
|
116
|
+
rescue Savon::Error => error
|
117
|
+
raise error
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def bookPickup(booking_information, pickup_address, contact_orderer = nil)
|
122
|
+
warn "DHL does not yet support the book pickup call"
|
123
|
+
|
124
|
+
raise "Booking information must be of type BookingInformation! Is #{booking_information}" unless booking_information.kind_of? BookingInformation
|
125
|
+
raise "Pickup_address must be of type Address! Is #{pickup_address.class}" unless pickup_address.kind_of? Address
|
126
|
+
raise "Contact orderer must be of type Address! Is #{contact_orderer.class}" unless contact_orderer.nil? or contact_orderer.kind_of? Address
|
127
|
+
|
128
|
+
if booking_information.account.nil? and [:DDI, :DDN].includes?(booking_information.product_id)
|
129
|
+
booking_information.account = @ekp
|
130
|
+
end
|
131
|
+
if booking_information.attendance.nil?
|
132
|
+
booking_information.attendance = @partner_id
|
133
|
+
end
|
134
|
+
|
135
|
+
begin
|
136
|
+
result = @client.request "de:BookPickupRequest" do
|
100
137
|
soap.xml do |xml|
|
101
138
|
xml.soapenv(:Envelope, DEFAULT_NAMESPACES) do |xml|
|
102
139
|
xml.soapenv(:Header) do |xml|
|
103
140
|
append_default_header_to_xml(xml)
|
104
141
|
end
|
105
142
|
xml.soapenv(:Body) do |xml|
|
106
|
-
xml.de(:"
|
107
|
-
xml
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
xml.ShipmentNumber do |xml|
|
112
|
-
xml.cis(:shipmentNumber, shipment_number)
|
143
|
+
xml.de(:"BookPickupRequest") do |xml|
|
144
|
+
add_version_information(xml)
|
145
|
+
booking_information.append_to_xml(xml)
|
146
|
+
xml.PickupAddress do |xml|
|
147
|
+
pickup_address.append_to_xml(xml)
|
113
148
|
end
|
149
|
+
xml.ContactOrderer do |xml|
|
150
|
+
contact_orderer.append_to_xml(xml)
|
151
|
+
end unless contact_orderer.nil?
|
114
152
|
end
|
115
153
|
end
|
116
154
|
end
|
117
|
-
|
155
|
+
end
|
118
156
|
end
|
119
|
-
r = result.to_hash[:
|
157
|
+
r = result.to_hash[:book_pickup_response]
|
120
158
|
|
121
|
-
|
122
|
-
raise "Intraship call failed with code #{r[:status][:status_code]}: #{r[:status][:status_message]} (Status messages: #{r[:deletion_state][:status].to_s})" unless r[:status][:status_code] == '0'
|
159
|
+
raise "Intraship call failed with code #{r[:status][:status_code]}: #{r[:status][:status_message]}" unless r[:status][:status_code] == '0'
|
123
160
|
|
124
|
-
|
125
|
-
|
161
|
+
r[:confirmation_number]
|
162
|
+
rescue Savon::Error => error
|
126
163
|
raise error
|
127
164
|
end
|
128
165
|
end
|
129
166
|
|
130
|
-
protected
|
131
|
-
|
167
|
+
protected
|
168
|
+
|
169
|
+
def append_default_header_to_xml(xml)
|
132
170
|
# For some reason the class instance variables are not accessible inside of the request block
|
133
171
|
user = @user
|
134
172
|
signature = @signature
|
@@ -142,7 +180,34 @@ protected
|
|
142
180
|
xml.cis(:accountNumber, "#{ekp}|#{procedure_id}|#{partner_id}")
|
143
181
|
xml.cis(:type, '0')
|
144
182
|
end
|
145
|
-
|
183
|
+
end
|
184
|
+
|
185
|
+
def add_version_information(xml)
|
186
|
+
xml.cis(:Version) do |xml|
|
187
|
+
xml.cis(:majorRelease, '1')
|
188
|
+
xml.cis(:minorRelease, '0')
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def do_simple_shipment_number_only_request(request_name, shipment_number)
|
193
|
+
@client.request "de:#{request_name}" do
|
194
|
+
soap.xml do |xml|
|
195
|
+
xml.soapenv(:Envelope, DEFAULT_NAMESPACES) do |xml|
|
196
|
+
xml.soapenv(:Header) do |xml|
|
197
|
+
append_default_header_to_xml(xml)
|
198
|
+
end
|
199
|
+
xml.soapenv(:Body) do |xml|
|
200
|
+
xml.de(request_name.to_sym) do |xml|
|
201
|
+
add_version_information(xml)
|
202
|
+
xml.ShipmentNumber do |xml|
|
203
|
+
xml.cis(:shipmentNumber, shipment_number)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
146
211
|
end
|
147
212
|
end
|
148
213
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Dhl
|
2
|
+
module Intraship
|
3
|
+
class BookingInformation
|
4
|
+
attr_accessor :product_id, :pickup_date, :ready_by_time, :closing_time, :remark, :attendance, :pickup_location, :amount_of_pieces, :amount_of_pallets,
|
5
|
+
:weight_in_kg, :count_of_shipments, :total_volume_weight, :max_length_in_cm, :max_width_in_cm, :max_height_in_cm, :account
|
6
|
+
|
7
|
+
VALID_PRODUCT_IDS = [:TDI, :TDN, :DDI, :DDN]
|
8
|
+
|
9
|
+
def initialize(attributes = {})
|
10
|
+
self.product_id = :DDN
|
11
|
+
attributes.each do |key, value|
|
12
|
+
setter = :"#{key.to_s}="
|
13
|
+
if self.respond_to?(setter)
|
14
|
+
self.send(setter, value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def product_id=(new_product_id)
|
20
|
+
raise "Invalid product id '#{new_product_id}'. Please use one of #{VALID_PRODUCT_IDS}" unless VALID_PRODUCT_IDS.include?(new_product_id)
|
21
|
+
@product_id = new_product_id
|
22
|
+
end
|
23
|
+
|
24
|
+
def append_to_xml(xml)
|
25
|
+
product_id = @product_id
|
26
|
+
xml.BookingInformation do |xml|
|
27
|
+
xml.ProductID(product_id)
|
28
|
+
xml.Account(account)
|
29
|
+
xml.Attendance(attendance) if attendance
|
30
|
+
xml.PickupDate(pickup_date)
|
31
|
+
xml.ReadyByTime(ready_by_time)
|
32
|
+
xml.ClosingTime(closing_time)
|
33
|
+
xml.PickupLocation(pickup_location) if pickup_location
|
34
|
+
xml.AmountOfPieces(amount_of_pieces) if amount_of_pieces
|
35
|
+
xml.AmountOfPallets(amount_of_pallets) if amount_of_pallets
|
36
|
+
xml.WeightInKG(weight_in_kg) if weight_in_kg
|
37
|
+
xml.CountOfShipments(count_of_shipments) if count_of_shipments
|
38
|
+
xml.TotalVolumeWeight(total_volume_weight) if total_volume_weight
|
39
|
+
xml.MaxLengthInCM(max_height_in_cm) if max_length_in_cm
|
40
|
+
xml.MaxWidthInCM(max_width_in_cm) if max_width_in_cm
|
41
|
+
xml.MaxHeightInCM(max_height_in_cm) if max_length_in_cm
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Dhl
|
6
|
+
module Intraship
|
7
|
+
|
8
|
+
ERROR_PICKUP_RESPONSE = <<EOS
|
9
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
10
|
+
<soapenv:Body>
|
11
|
+
<ns4:BookPickupResponse xmlns:ns4="http://de.ws.intraship">
|
12
|
+
<Version xmlns="http://dhl.de/webservice/cisbase">
|
13
|
+
<majorRelease>1</majorRelease>
|
14
|
+
<minorRelease>0</minorRelease>
|
15
|
+
<build>14</build>
|
16
|
+
</Version>
|
17
|
+
<Status>
|
18
|
+
<StatusCode>2120</StatusCode>
|
19
|
+
<StatusMessage>Please select a product in the shipment details. | Ordereraddress company name required | Ordereraddress ZIP required | The current ZIP format doesn´t correspond to the required format of the country of receiver. Further informations will be available in the online-help. | House number is missing at the Ordereraddress. | Ordereraddress phone required | Ordereraddress contact required | Street is missing at the Ordereraddress. | House number is missing at the Ordereraddress. | Ordereraddress city required</StatusMessage>
|
20
|
+
</Status>
|
21
|
+
</ns4:BookPickupResponse>
|
22
|
+
</soapenv:Body>
|
23
|
+
</soapenv:Envelope>
|
24
|
+
EOS
|
25
|
+
|
26
|
+
PICKUP_RESPONSE = <<EOS
|
27
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
28
|
+
<soapenv:Body>
|
29
|
+
<ns2:BookPickupResponse xmlns:ns2="http://de.ws.intraship">
|
30
|
+
<Version xmlns="http://dhl.de/webservice/cisbase">
|
31
|
+
<majorRelease>1</majorRelease>
|
32
|
+
<minorRelease>0</minorRelease>
|
33
|
+
<build>11</build>
|
34
|
+
</Version>
|
35
|
+
<Status>
|
36
|
+
<StatusCode>0</StatusCode>
|
37
|
+
<StatusMessage>We have received your Individual Collection DHL Parcel under order number '123'.</StatusMessage>
|
38
|
+
</Status>
|
39
|
+
<ConfirmationNumber>123</ConfirmationNumber>
|
40
|
+
</ns2:BookPickupResponse>
|
41
|
+
</soapenv:Body>
|
42
|
+
</soapenv:Envelope>
|
43
|
+
EOS
|
44
|
+
|
45
|
+
describe API do
|
46
|
+
before(:each) do
|
47
|
+
config = {user: 'user', signature: 'signature', ekp: 'ekp12345'}
|
48
|
+
options = {test: true}
|
49
|
+
@api = API.new(config, options)
|
50
|
+
@booking_information = BookingInformation.new(pickup_date: Date.today, ready_by_time: '10:00', closing_time: '14:00')
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should raise an exception on a failed call" do
|
54
|
+
savon.expects("de:BookPickupRequest").returns( code: 200, headers: {},body: ERROR_PICKUP_RESPONSE )
|
55
|
+
|
56
|
+
expect { @api.bookPickup(@booking_information, CompanyAddress.new) }.should raise_error
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Dhl
|
4
|
+
module Intraship
|
5
|
+
|
6
|
+
ERROR_MANIFEST_RESPONSE = <<EOS
|
7
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
8
|
+
<soapenv:Body>
|
9
|
+
<ns4:DoManifestResponse xmlns:ns4="http://de.ws.intraship">
|
10
|
+
<Version xmlns="http://dhl.de/webservice/cisbase">
|
11
|
+
<majorRelease>1</majorRelease>
|
12
|
+
<minorRelease>0</minorRelease>
|
13
|
+
<build>14</build>
|
14
|
+
</Version>
|
15
|
+
<Status>
|
16
|
+
<StatusCode>1050</StatusCode>
|
17
|
+
<StatusMessage>at least on shipment could not be manifested</StatusMessage>
|
18
|
+
</Status>
|
19
|
+
<ManifestState>
|
20
|
+
<ShipmentNumber>
|
21
|
+
<ns1:shipmentNumber xmlns:ns1="http://dhl.de/webservice/cisbase">123</ns1:shipmentNumber>
|
22
|
+
</ShipmentNumber>
|
23
|
+
<Status>
|
24
|
+
<StatusCode>2030</StatusCode>
|
25
|
+
<StatusMessage>shipment not printed</StatusMessage>
|
26
|
+
</Status>
|
27
|
+
</ManifestState>
|
28
|
+
</ns4:DoManifestResponse>
|
29
|
+
</soapenv:Body>
|
30
|
+
</soapenv:Envelope>
|
31
|
+
EOS
|
32
|
+
|
33
|
+
MANIFEST_RESPONSE = <<EOS
|
34
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
35
|
+
<soapenv:Body>
|
36
|
+
<ns4:DoManifestResponse xmlns:ns4="http://de.ws.intraship">
|
37
|
+
<Version xmlns="http://dhl.de/webservice/cisbase">
|
38
|
+
<majorRelease>1</majorRelease>
|
39
|
+
<minorRelease>0</minorRelease>
|
40
|
+
<build>14</build>
|
41
|
+
</Version>
|
42
|
+
<Status>
|
43
|
+
<StatusCode>0</StatusCode>
|
44
|
+
<StatusMessage>ok</StatusMessage>
|
45
|
+
</Status>
|
46
|
+
<ManifestState>
|
47
|
+
<ShipmentNumber>
|
48
|
+
<ns1:shipmentNumber xmlns:ns1="http://dhl.de/webservice/cisbase">123</ns1:shipmentNumber>
|
49
|
+
</ShipmentNumber>
|
50
|
+
<Status>
|
51
|
+
<StatusCode>0</StatusCode>
|
52
|
+
<StatusMessage>ok</StatusMessage>
|
53
|
+
</Status>
|
54
|
+
</ManifestState>
|
55
|
+
</ns4:DoManifestResponse>
|
56
|
+
</soapenv:Body>
|
57
|
+
</soapenv:Envelope>
|
58
|
+
EOS
|
59
|
+
|
60
|
+
describe API do
|
61
|
+
before(:each) do
|
62
|
+
config = {user: 'user', signature: 'signature', ekp: 'ekp12345'}
|
63
|
+
options = {test: true}
|
64
|
+
@api = API.new(config, options)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
it "should raise an exception on a failed call" do
|
69
|
+
savon.expects("de:DoManifestDDRequest").returns( code: 200, headers: {},body: ERROR_MANIFEST_RESPONSE )
|
70
|
+
|
71
|
+
expect { @api.doManifestDD("123") }.should raise_error
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return true on successful call" do
|
75
|
+
savon.expects("de:DoManifestDDRequest").returns( code: 200, headers: {},body: MANIFEST_RESPONSE )
|
76
|
+
@api.doManifestDD("123").should be_true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'savon/spec'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
|
3
|
+
Dir[File.join(File.dirname(__FILE__), '../lib/dhl-intraship/*.rb')].each { |f| require f }
|
4
|
+
|
5
|
+
# Prevent warnings: http://stackoverflow.com/questions/5009838/httpi-tried-to-user-the-httpi-adapter-error-using-savon-soap-library
|
6
|
+
HTTPI.log = false
|
7
7
|
|
8
8
|
RSpec.configure do |config|
|
9
9
|
config.include Savon::Spec::Macros
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dhl-intraship
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.1.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 2.11.0
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 2.11.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: savon_spec
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 1.3.0
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.3.0
|
62
62
|
description: A simple gem to access the DHL Intraship API
|
63
63
|
email:
|
64
64
|
- a.kops@teameurope.net
|
@@ -75,14 +75,16 @@ files:
|
|
75
75
|
- lib/dhl-intraship.rb
|
76
76
|
- lib/dhl-intraship/address.rb
|
77
77
|
- lib/dhl-intraship/api.rb
|
78
|
+
- lib/dhl-intraship/booking_information.rb
|
78
79
|
- lib/dhl-intraship/company_address.rb
|
79
80
|
- lib/dhl-intraship/person_address.rb
|
80
81
|
- lib/dhl-intraship/product_code.rb
|
81
82
|
- lib/dhl-intraship/shipment.rb
|
82
83
|
- lib/dhl-intraship/version.rb
|
83
|
-
- spec/dhl-intraship/
|
84
|
+
- spec/dhl-intraship/book_pickup_spec.rb
|
84
85
|
- spec/dhl-intraship/create_shipment_dd_spec.rb
|
85
86
|
- spec/dhl-intraship/delete_shipment_dd_spec.rb
|
87
|
+
- spec/dhl-intraship/do_manifest_dd_spec.rb
|
86
88
|
- spec/spec_helper.rb
|
87
89
|
homepage: https://github.com/teameurope/dhl-intraship
|
88
90
|
licenses: []
|
@@ -104,12 +106,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
106
|
version: '0'
|
105
107
|
requirements: []
|
106
108
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.8.
|
109
|
+
rubygems_version: 1.8.23
|
108
110
|
signing_key:
|
109
111
|
specification_version: 3
|
110
112
|
summary: This wraps the DHL Intraship SOAP Interface for creating shipments
|
111
113
|
test_files:
|
112
|
-
- spec/dhl-intraship/
|
114
|
+
- spec/dhl-intraship/book_pickup_spec.rb
|
113
115
|
- spec/dhl-intraship/create_shipment_dd_spec.rb
|
114
116
|
- spec/dhl-intraship/delete_shipment_dd_spec.rb
|
117
|
+
- spec/dhl-intraship/do_manifest_dd_spec.rb
|
115
118
|
- spec/spec_helper.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Dhl
|
4
|
-
module Intraship
|
5
|
-
|
6
|
-
describe Address do
|
7
|
-
before{@address = Address.new}
|
8
|
-
|
9
|
-
it "should remove the part after a + from the email address" do
|
10
|
-
@address.email = "test+part@teameurope.net"
|
11
|
-
@address.email.should == "test@teameurope.net"
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|