dhl-intraship 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 807f3bd9fa9722dc4516a4fe4b8aeaecdc9be281
4
+ data.tar.gz: 35c15d6d91b19b5ba137b0a8802201271a2e2381
5
+ SHA512:
6
+ metadata.gz: d5692e9baf56a22c1841ce7517e7e197362f78454ecb3c66b03878f5df7c005c9dd0e00209acea55d5bc10a23de629316c58b43a3ba1d7e7b197e47d35e1ad4d
7
+ data.tar.gz: 2b1ac932bae07c995c25ea8b46a86b48154fcee3dbfc6e9ad278f7e23d4a1314640419b7c56368936cc1062d5a37ad2de8e628108683f63472baa470f097b5b9
data/README.md CHANGED
@@ -28,19 +28,22 @@ api = Dhl::Intraship::API.new(config, options)
28
28
  Config is the following hash:
29
29
 
30
30
  ```ruby
31
- config = {user: 'your Intraship API user name', #mandatory
32
- signature: 'Your Intraship API user password', #mandatory
33
- ekp: 'Your DHL EKP (first part of your DHL Account number)', #mandatory
34
- procedure_id: 'The prodedureId (second part of your DHL Account number)', #optional, defaults to '01'
35
- partner_id: 'The partnerId (=attendance, third part of your DHL Account number)' #optional, defaults to '01'
36
- }
31
+ config = {
32
+ user: 'your Intraship API user name', #mandatory
33
+ signature: 'Your Intraship API user password', #mandatory
34
+ ekp: 'Your DHL EKP (first part of your DHL Account number)', #mandatory
35
+ procedure_id: 'The prodedureId (second part of your DHL Account number)', #optional, defaults to '01'
36
+ partner_id: 'The partnerId (=attendance, third part of your DHL Account number)' #optional, defaults to '01'
37
+ }
37
38
  ```
38
39
 
39
40
  Options is an optional parameter and can contain the following parameters:
40
41
 
41
42
  ```ruby
42
- options = {test: true, # If test is set, all API calls go against the Intraship test system
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
43
+ options = {
44
+ test: true, # If test is set, all API calls go against the Intraship test system
45
+ label_response_type: :xml # If it's set to XML the createShipment-Calls return the label data as XML instead of the PDF-Link
46
+ }
44
47
  ```
45
48
 
46
49
  ### Create a shipment
@@ -49,43 +52,71 @@ To create a shipment to DHL you need to create it first
49
52
 
50
53
 
51
54
  ```ruby
52
- sender_address = Dhl::Intraship::CompanyAddress.new(company: 'Team Europe Ventures',
53
- contact_person: 'John Smith',
54
- street: 'Mohrenstraße',
55
- house_number: '60',
56
- zip: '10117',
57
- city: 'Berlin',
58
- country_code: 'DE',
59
- email: 'info@teameurope.net')
60
- receiver_address = Dhl::Intraship::PersonAddress.new(firstname: 'John',
61
- lastname: 'Doe',
62
- street: 'Mainstreet',
63
- house_number: '10',
64
- street_additional: 'Appartment 2a',
65
- zip: '90210',
66
- city: 'Springfield',
67
- country_code: 'DE',
68
- email: 'john.doe@example.com')
69
- #Note that the weight parameter is in kg and the length/height/width in cm
70
- shipment = Dhl::Intraship::Shipment.new(sender_address: sender_address,
71
- receiver_address: receiver_address,
72
- shipment_date: Date.today,
73
- weight: 2,
74
- length: 30,
75
- height:15,
76
- width: 25)
55
+ sender_address =
56
+ Dhl::Intraship::CompanyAddress.new(company: 'Team Europe Ventures',
57
+ contact_person: 'John Smith',
58
+ street: 'Mohrenstraße',
59
+ house_number: '60',
60
+ zip: '10117',
61
+ city: 'Berlin',
62
+ country_code: 'DE',
63
+ email: 'info@teameurope.net')
64
+
65
+ receiver_address =
66
+ Dhl::Intraship::PersonAddress.new(firstname: 'John',
67
+ lastname: 'Doe',
68
+ street: 'Mainstreet',
69
+ house_number: '10',
70
+ street_additional: 'Appartment 2a',
71
+ zip: '90210',
72
+ city: 'Springfield',
73
+ country_code: 'DE',
74
+ email: 'john.doe@example.com')
75
+
76
+ # Use can use multiple parcels per shipment. Note that the weight
77
+ # parameter is in kg and the length/height/width in cm
78
+ shipment_item =
79
+ Dhl::Intraship::ShipmentItem.new(weight: 3,
80
+ length: 120,
81
+ width: 60,
82
+ height: 60)
83
+
84
+ shipment =
85
+ Dhl::Intraship::Shipment.new(sender_address: sender_address,
86
+ receiver_address: receiver_address,
87
+ shipment_items: shipment_item # give array for multiple parcel shipment
88
+ shipment_date: Date.today)
77
89
  ```
78
90
 
79
- Beware, that due to DHL Intraship restrictions, the sender address must be a
80
- CompanyAddress and requires a contact_person.
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)
91
+ Beware, that due to DHL Intraship restrictions, the sender address
92
+ must be a CompanyAddress and requires a contact_person. The actual
93
+ api-call takes an array of shipments, or a single shipment. The
94
+ result contains the "shipment_number", as well as the "label_url" (or
95
+ the "xml_label" when it was specified as repsonse type)
83
96
 
84
97
  ```ruby
85
98
  result = api.createShipmentDD(shipment)
86
99
  shipment_number = result[:shipment_number]
87
100
  label_url = result[:label_url] # Or result[:xml_label] in case XML label was set in the options
88
101
  ```
102
+ #### Deliver DHL Domestic Express Shipments
103
+
104
+ If your DHL Intraship Account can deliver DHL Express shipments, you have to do the following
105
+
106
+ ```ruby
107
+ shipment.product_code = Dhl::Intraship::ProductCode::DHL_DOMESTIC_EXPRESS # will set the product code to EXP
108
+ express_service = Dhl::Intraship::DhlExpressService.new(Dhl::Intraship::DhlExpressService::EXPRESS1200)
109
+ # You can choose between following possible service options:
110
+ # DeliveryOnTime DeliveryEarly Express0900 Express1000 Express1200 DeliveryAfternoon DeliveryEvening ExpressSaturday ExpressSunday
111
+ # If you are using the DeliveryOnTime service, you have to set the delivery time (format 'hh:mm'):
112
+ express_service = Dhl::Intraship::DhlExpressService.new(Dhl::Intraship::DhlExpressService::DELIVERY_ON_TIME, '14:00')
113
+ shipment.add_service(express_service)
114
+ ```
115
+
116
+ If the DHL Intraship Webservice returns: `1102 - Service 'SERVICE_ERT'
117
+ is not allowed for productcode 'EXP'`
118
+ your intraship account have not enough permissions to deliver
119
+ express shipments (maybe also multi parcel shipment is not permitted).
89
120
 
90
121
  #### Add cash on delivery
91
122
 
@@ -5,7 +5,12 @@ require "dhl-intraship/person_address"
5
5
  require "dhl-intraship/company_address"
6
6
  require "dhl-intraship/packstation_address"
7
7
  require "dhl-intraship/shipment"
8
+ require "dhl-intraship/shipment_item"
8
9
  require "dhl-intraship/product_code"
10
+ require "dhl-intraship/booking_information"
9
11
  require "dhl-intraship/bankdata"
10
12
  require "dhl-intraship/service"
11
- require "dhl-intraship/service/cod_service"
13
+ require "dhl-intraship/service/cod_service"
14
+ require "dhl-intraship/service/dhl_paket_multipack_service"
15
+ require "dhl-intraship/service/dhl_express_service"
16
+ require "dhl-intraship/service/higher_insurance_service"
@@ -6,13 +6,15 @@ module Dhl
6
6
  WORLD_PACKAGE = 'BPI'
7
7
  DHL_EURO_PACKAGE = 'EPI'
8
8
  DHL_EURO_PLUS = 'EUP'
9
+ DHL_DOMESTIC_EXPRESS = 'EXP'
9
10
 
10
11
  # Time definite product codes
11
12
  DOMESTIC_EXPRESS = 'DXM'
12
13
  STARTDAY_EXPRESS = 'TDK'
13
14
  DHL_EXPRESS_WORLDWIDE = 'WPX'
14
15
 
15
- VALID_PRODUCT_CODES = [DHL_PACKAGE, WORLD_PACKAGE, DHL_EURO_PACKAGE, DHL_EURO_PLUS, DOMESTIC_EXPRESS, STARTDAY_EXPRESS, DHL_EXPRESS_WORLDWIDE]
16
+ VALID_PRODUCT_CODES = [DHL_PACKAGE, WORLD_PACKAGE, DHL_EURO_PACKAGE, DHL_EURO_PLUS, DHL_DOMESTIC_EXPRESS,
17
+ DOMESTIC_EXPRESS, STARTDAY_EXPRESS, DHL_EXPRESS_WORLDWIDE]
16
18
  end
17
19
  end
18
20
  end
@@ -0,0 +1,45 @@
1
+ module Dhl
2
+ module Intraship
3
+ class DhlExpressService < Service
4
+
5
+ # Bundles following services for domestic time-definite products
6
+ # offered by DHL Express. One of the services must be chosen, if
7
+ # this service bundle is invoked
8
+
9
+ DELIVERY_ON_TIME = 'DeliveryOnTime'
10
+ DELIVERY_EARLY = 'DeliveryEarly'
11
+ EXPRESS0900 = 'Express0900'
12
+ EXPRESS1000 = 'Express1000'
13
+ EXPRESS1200 = 'Express1200'
14
+ DELIVERY_AFTERNOON = 'DeliveryAfternoon'
15
+ DELIVERY_EVENING = 'DeliveryEvening'
16
+ EXPRESS_SATURDAY = 'ExpressSaturday'
17
+ EXPRESS_SUNDAY = 'Expresssunday'
18
+
19
+ VALID_EXPRESS_SERVICES = [DELIVERY_ON_TIME, DELIVERY_EARLY, EXPRESS0900, EXPRESS1000, EXPRESS1200,
20
+ DELIVERY_AFTERNOON, DELIVERY_EVENING, EXPRESS_SATURDAY, EXPRESS_SUNDAY]
21
+
22
+
23
+ def initialize(service, time = nil)
24
+ @service, @time = service, time
25
+ unless VALID_EXPRESS_SERVICES.include?(@service)
26
+ raise "No valid express service #{@service}"
27
+ end
28
+
29
+ if @service == DELIVERY_ON_TIME
30
+ raise "Time is missing while DeliveryOnTime is specified." if time.blank?
31
+ raise "Invalid time format (use hh::mm)." if time !~ /^\d\d:\d\d$/
32
+ end
33
+ end
34
+
35
+ def append_to_xml(xml)
36
+ xml.Service do |xml|
37
+ xml.ServiceGroupDateTimeOption do |xml|
38
+ xml.tag! @service, @time || 'True'
39
+ end
40
+ end
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,15 @@
1
+ module Dhl
2
+ module Intraship
3
+ class DhlPaketMultipackService < Service
4
+
5
+ def append_to_xml(xml)
6
+ xml.Service do |xml|
7
+ xml.ServiceGroupDHLPaket do |xml|
8
+ xml.Multipack 'True'
9
+ end
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ module Dhl
2
+ module Intraship
3
+ class HigherInsuranceService < Service
4
+
5
+ def initialize(amount = 2500, currency = 'EUR')
6
+ @amount, @currency = amount, currency
7
+
8
+ unless [2500, 25000].include?(@amount)
9
+ raise 'The insurance amount have to be 2500 or 25000!'
10
+ end
11
+ end
12
+
13
+ def append_to_xml(xml)
14
+ xml.Service do |xml|
15
+ xml.ServiceGroupOther do |xml|
16
+ xml.HigherInsurance do |xml|
17
+ xml.InsuranceAmount(@amount)
18
+ xml.InsuranceCurrency(@currency)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -1,16 +1,26 @@
1
- require "dhl-intraship/product_code"
2
-
3
1
  module Dhl
4
2
  module Intraship
5
3
  class Shipment
6
- PACKAGE_TYPE = 'PK'
7
4
 
8
- attr_accessor :sender_address, :receiver_address, :shipment_date, :weight, :length, :height, :width, :product_code,
9
- :customer_reference, :services
5
+ attr_accessor :sender_address, :receiver_address, :shipment_date, :product_code,
6
+ :customer_reference, :services, :shipment_items, :dhl_express_service
10
7
 
11
8
  def initialize(attributes = {})
12
9
  self.product_code = ProductCode::DHL_PACKAGE
13
10
  self.services = []
11
+ self.shipment_items = []
12
+
13
+ # If an initial shipment is given we have to create a new
14
+ # ShipmentItem (for backward compatibility). Maybe we can drop
15
+ # this in a new major release ...
16
+ if attributes.has_key?(:weight) or attributes.has_key?(:length) or
17
+ attributes.has_key?(:width) or attributes.has_key?(:height)
18
+ warn "[DEPRECATION] The single shipment constructor is deprecated, please pass in a ShipmentItem"
19
+ @shipment_items << ShipmentItem.new(attributes)
20
+ else
21
+ @shipment_items.push(*attributes.delete(:shipment_items))
22
+ end
23
+
14
24
  attributes.each do |key, value|
15
25
  setter = :"#{key.to_s}="
16
26
  if self.respond_to?(setter)
@@ -20,18 +30,30 @@ module Dhl
20
30
  end
21
31
 
22
32
  def add_service(newservice)
33
+ case newservice
34
+ when DhlExpressService
35
+ unless dhl_domestic_express?
36
+ end
37
+ end
23
38
  @services << newservice
24
39
  end
25
40
 
41
+ def add_shipment_item(shipment_item)
42
+ @shipment_items << shipment_item
43
+ end
44
+
26
45
  def product_code=(product_code)
27
46
  raise "No valid product code #{product_code}" unless ProductCode::VALID_PRODUCT_CODES.include?(product_code)
28
47
  @product_code = product_code
29
48
  end
30
49
 
31
50
  def append_to_xml(ekp, partner_id, xml)
32
- raise "Shipment date must be set!" if shipment_date.nil?
33
- raise "Sender address must be set!" if sender_address.nil?
34
- raise "Receiver address must be set!" if sender_address.nil?
51
+ raise "Shipment date must be set!" if shipment_date.blank?
52
+ raise "Sender address must be set!" if sender_address.blank?
53
+ raise "Receiver address must be set!" if receiver_address.blank?
54
+
55
+ add_and_validate_service_dependencies
56
+
35
57
  xml.Shipment do |xml|
36
58
  xml.ShipmentDetails do |xml|
37
59
  xml.ProductCode(product_code)
@@ -41,12 +63,10 @@ module Dhl
41
63
  xml.cis(:partnerID, partner_id)
42
64
  end
43
65
  xml.CustomerReference(customer_reference) unless customer_reference.blank?
44
- xml.ShipmentItem do |xml|
45
- xml.WeightInKG(weight)
46
- xml.LengthInCM(length) unless length.nil?
47
- xml.WidthInCM(width) unless width.nil?
48
- xml.HeightInCM(height) unless height.nil?
49
- xml.PackageType(PACKAGE_TYPE)
66
+
67
+ # multiple parcels
68
+ shipment_items.each do |shipment_item|
69
+ shipment_item.append_to_xml(xml)
50
70
  end
51
71
  services.each do |service|
52
72
  service.append_to_xml(xml)
@@ -62,6 +82,40 @@ module Dhl
62
82
  end
63
83
  end
64
84
  end
85
+
86
+ private
87
+
88
+ def add_and_validate_service_dependencies
89
+ # for using multiple parcels for product code EPN or EXP there
90
+ # is an extra service ServiceGroupDHLPaket.Multipack that
91
+ # needs to be add
92
+ if add_dhl_paket_multipack_service?
93
+ add_service(DhlPaketMultipackService.new)
94
+ end
95
+
96
+ if dhl_domestic_express? and not has_service?(HigherInsuranceService)
97
+ # we also need a higher insurance service if not set already
98
+ add_service(HigherInsuranceService.new)
99
+ end
100
+
101
+ # check service constraints
102
+ if has_service?(DhlExpressService) and not dhl_domestic_express?
103
+ raise 'The DhlExpressService can only be add to DHL Domestic Express (EXP) shipments.'
104
+ end
105
+ end
106
+
107
+ def has_service?(service_class)
108
+ services.map(&:class).include?(service_class)
109
+ end
110
+
111
+ def dhl_domestic_express?
112
+ product_code == ProductCode::DHL_DOMESTIC_EXPRESS
113
+ end
114
+
115
+ def add_dhl_paket_multipack_service?
116
+ shipment_items.size > 1 and
117
+ ([ProductCode::DHL_DOMESTIC_EXPRESS, ProductCode::DHL_PACKAGE].include?(product_code))
118
+ end
65
119
  end
66
120
  end
67
121
  end
@@ -0,0 +1,32 @@
1
+ module Dhl
2
+ module Intraship
3
+ class ShipmentItem
4
+
5
+ attr_accessor :weight, :length, :height, :width
6
+ attr_writer :package_type
7
+ def package_type
8
+ @package_type || 'PK'
9
+ end
10
+
11
+ def initialize(attributes = {})
12
+ attributes.each do |key, value|
13
+ setter = :"#{key.to_s}="
14
+ if self.respond_to?(setter)
15
+ self.send(setter, value)
16
+ end
17
+ end
18
+ end
19
+
20
+ def append_to_xml(xml)
21
+ xml.ShipmentItem do |xml|
22
+ xml.WeightInKG(weight)
23
+ xml.LengthInCM(length) unless length.nil?
24
+ xml.WidthInCM(width) unless width.nil?
25
+ xml.HeightInCM(height) unless height.nil?
26
+ xml.PackageType(package_type)
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Dhl
2
2
  module Intraship
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -53,10 +53,10 @@ EOS
53
53
  it "should raise an exception on a failed call" do
54
54
  savon.expects("de:BookPickupRequest").returns( code: 200, headers: {},body: ERROR_PICKUP_RESPONSE )
55
55
 
56
- expect { @api.bookPickup(@booking_information, CompanyAddress.new) }.should raise_error
56
+ expect { @api.bookPickup(@booking_information, CompanyAddress.new) }.to raise_error
57
57
  end
58
58
 
59
59
  end
60
60
 
61
61
  end
62
- end
62
+ end
@@ -35,25 +35,63 @@ module Dhl
35
35
  </soapenv:Envelope>
36
36
  EOS
37
37
 
38
+
38
39
  describe API do
39
40
  before(:each) do
40
- config = {user: 'user', signature: 'signature', ekp: 'ekp12345'}
41
- options = {test: true}
41
+ savon.expects("de:CreateShipmentDDRequest").returns(code: 200, headers: {}, body: CREATE_RESPONSE)
42
+
43
+ config = { user: 'user', signature: 'signature', ekp: 'ekp12345' }
44
+ options = { test: true }
42
45
  @api = API.new(config, options)
46
+ @shipment = Shipment.new(shipment_date: Date.today + 1,
47
+ sender_address: CompanyAddress.new,
48
+ receiver_address: PersonAddress.new,
49
+ shipment_items: ShipmentItem.new(weight: 2.5, length: 11, width: 13, height: 3))
43
50
  end
44
51
 
45
52
  it "should create an API call" do
46
- savon.expects("de:CreateShipmentDDRequest" ).returns( code: 200, headers: {},body: CREATE_RESPONSE )
53
+ @api.createShipmentDD(@shipment).should_not be_nil
54
+ end
47
55
 
48
- shipment = Shipment.new(shipment_date: Date.today + 1)
56
+ it "should not add multipack service with only one shipment item" do
57
+ savon.expects('de:CreateShipmentDDRequest').with do |request|
58
+ request.soap.to_xml.should_not include('Multipack')
59
+ end.returns(code: 200, headers: {}, body: CREATE_RESPONSE)
49
60
 
50
- sender = CompanyAddress.new
51
- receiver = PersonAddress.new
52
- shipment.receiver_address=receiver
53
- shipment.sender_address=sender
61
+ @api.createShipmentDD(@shipment).should_not be_nil
62
+ end
54
63
 
55
- @api.createShipmentDD(shipment).should_not be_nil
64
+ it "should add multipack service" do
65
+ @shipment.add_shipment_item(ShipmentItem.new(weight: 2.5, length: 11, width: 13, height: 3))
66
+ savon.expects('de:CreateShipmentDDRequest').with do |request|
67
+ request_xml = request.soap.to_xml
68
+ request_xml.should include('<ServiceGroupDHLPaket>')
69
+ request_xml.should include('<Multipack>True</Multipack>')
70
+ end.returns(code: 200, headers: {}, body: CREATE_RESPONSE)
71
+ @api.createShipmentDD(@shipment).should_not be_nil
56
72
  end
73
+
74
+ it "should add dhl express service with higher insurance server" do
75
+ dhl_express_service = DhlExpressService.new(DhlExpressService::DELIVERY_ON_TIME, '13:51')
76
+ @shipment.product_code = ProductCode::DHL_DOMESTIC_EXPRESS
77
+ @shipment.add_service(dhl_express_service)
78
+ savon.expects('de:CreateShipmentDDRequest').with do |request|
79
+ request_xml = request.soap.to_xml
80
+ request_xml.should include('<ServiceGroupDateTimeOption>')
81
+ request_xml.should include('<DeliveryOnTime>')
82
+ request_xml.should include('13:51')
83
+ request_xml.should include('<HigherInsurance>')
84
+ request_xml.should include('<InsuranceAmount>2500</InsuranceAmount>')
85
+ end.returns(code: 200, headers: {}, body: CREATE_RESPONSE)
86
+ @api.createShipmentDD(@shipment).should_not be_nil
87
+ end
88
+
89
+ it "should validate service dependencies" do
90
+ dhl_express_service = DhlExpressService.new(DhlExpressService::DELIVERY_ON_TIME, '13:51')
91
+ @shipment.add_service(dhl_express_service)
92
+ expect { @api.createShipmentDD(@shipment) }.to raise_error(RuntimeError, 'The DhlExpressService can only be add to DHL Domestic Express (EXP) shipments.')
93
+ end
94
+
57
95
  end
58
96
 
59
97
  end
@@ -56,22 +56,21 @@ DELETE_RESPONSE = <<EOS
56
56
  EOS
57
57
 
58
58
  describe API do
59
- before(:each) do
60
- config = {user: 'user', signature: 'signature', ekp: 'ekp12345'}
61
- options = {test: true}
62
- @api = API.new(config, options)
59
+ before do
60
+ @config = { user: 'user', signature: 'signature', ekp: 'ekp12345' }
61
+ @options = { test: true }
63
62
  end
64
63
 
65
64
  it "should raise an exception on a failed call" do
66
- savon.expects("de:DeleteShipmentDDRequest").returns( code: 200, headers: {},body: ERROR_DELETE_RESPONSE )
67
-
68
- expect { @api.deleteShipmentDD("123") }.should raise_error
65
+ savon.expects("de:DeleteShipmentDDRequest").returns(code: 200, headers: {}, body: ERROR_DELETE_RESPONSE)
66
+ api = API.new(@config, @options)
67
+ expect { api.deleteShipmentDD("123") }.to raise_error
69
68
  end
70
69
 
71
70
  it "should return true on successful call" do
72
- savon.expects("de:DeleteShipmentDDRequest").returns( code: 200, headers: {},body: DELETE_RESPONSE )
73
-
74
- @api.deleteShipmentDD("123").should be_true
71
+ savon.expects("de:DeleteShipmentDDRequest").returns(code: 200, headers: {}, body: DELETE_RESPONSE)
72
+ api = API.new(@config, @options)
73
+ api.deleteShipmentDD("123").should be_true
75
74
  end
76
75
  end
77
76
 
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ module Dhl
4
+ module Intraship
5
+
6
+ describe DhlExpressService do
7
+ it "should build object" do
8
+ DhlExpressService.new(DhlExpressService::EXPRESS1200).should_not be_nil
9
+ end
10
+
11
+ it "should raise exception if invalid time given" do
12
+ expect { DhlExpressService.new('invalid_option') }.to raise_error(RuntimeError, /No valid express service/)
13
+ end
14
+
15
+ it "should raise exception if invalid time given" do
16
+ expect { DhlExpressService.new(DhlExpressService::DELIVERY_ON_TIME, '13:AD') }.to raise_error(RuntimeError, 'Invalid time format (use hh::mm).')
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -68,7 +68,7 @@ EOS
68
68
  it "should raise an exception on a failed call" do
69
69
  savon.expects("de:DoManifestDDRequest").returns( code: 200, headers: {},body: ERROR_MANIFEST_RESPONSE )
70
70
 
71
- expect { @api.doManifestDD("123") }.should raise_error
71
+ expect { @api.doManifestDD("123") }.to raise_error
72
72
  end
73
73
 
74
74
  it "should return true on successful call" do
@@ -78,4 +78,4 @@ EOS
78
78
  end
79
79
 
80
80
  end
81
- end
81
+ end
@@ -1,10 +1,10 @@
1
1
  require 'savon/spec'
2
2
 
3
- Dir[File.join(File.dirname(__FILE__), '../lib/dhl-intraship/*.rb')].each { |f| require f }
3
+ require "dhl-intraship"
4
4
 
5
5
  # Prevent warnings: http://stackoverflow.com/questions/5009838/httpi-tried-to-user-the-httpi-adapter-error-using-savon-soap-library
6
6
  HTTPI.log = false
7
7
 
8
8
  RSpec.configure do |config|
9
9
  config.include Savon::Spec::Macros
10
- end
10
+ end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhl-intraship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alexander Kops
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-08 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: savon
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.1.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.1.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.11.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.11.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: savon_spec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.3.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.3.0
62
55
  description: A simple gem to access the DHL Intraship API
@@ -66,7 +59,7 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - .gitignore
62
+ - ".gitignore"
70
63
  - Gemfile
71
64
  - LICENSE
72
65
  - README.md
@@ -83,40 +76,45 @@ files:
83
76
  - lib/dhl-intraship/product_code.rb
84
77
  - lib/dhl-intraship/service.rb
85
78
  - lib/dhl-intraship/service/cod_service.rb
79
+ - lib/dhl-intraship/service/dhl_express_service.rb
80
+ - lib/dhl-intraship/service/dhl_paket_multipack_service.rb
81
+ - lib/dhl-intraship/service/higher_insurance_service.rb
86
82
  - lib/dhl-intraship/shipment.rb
83
+ - lib/dhl-intraship/shipment_item.rb
87
84
  - lib/dhl-intraship/version.rb
88
85
  - spec/dhl-intraship/book_pickup_spec.rb
89
86
  - spec/dhl-intraship/create_shipment_dd_spec.rb
90
87
  - spec/dhl-intraship/delete_shipment_dd_spec.rb
88
+ - spec/dhl-intraship/dhl_express_service_spec.rb
91
89
  - spec/dhl-intraship/do_manifest_dd_spec.rb
92
90
  - spec/spec_helper.rb
93
91
  homepage: https://github.com/teameurope/dhl-intraship
94
92
  licenses: []
93
+ metadata: {}
95
94
  post_install_message:
96
95
  rdoc_options: []
97
96
  require_paths:
98
97
  - lib
99
98
  required_ruby_version: !ruby/object:Gem::Requirement
100
- none: false
101
99
  requirements:
102
- - - ! '>='
100
+ - - ">="
103
101
  - !ruby/object:Gem::Version
104
102
  version: '0'
105
103
  required_rubygems_version: !ruby/object:Gem::Requirement
106
- none: false
107
104
  requirements:
108
- - - ! '>='
105
+ - - ">="
109
106
  - !ruby/object:Gem::Version
110
107
  version: '0'
111
108
  requirements: []
112
109
  rubyforge_project:
113
- rubygems_version: 1.8.24
110
+ rubygems_version: 2.2.1
114
111
  signing_key:
115
- specification_version: 3
112
+ specification_version: 4
116
113
  summary: This wraps the DHL Intraship SOAP Interface for creating shipments
117
114
  test_files:
118
115
  - spec/dhl-intraship/book_pickup_spec.rb
119
116
  - spec/dhl-intraship/create_shipment_dd_spec.rb
120
117
  - spec/dhl-intraship/delete_shipment_dd_spec.rb
118
+ - spec/dhl-intraship/dhl_express_service_spec.rb
121
119
  - spec/dhl-intraship/do_manifest_dd_spec.rb
122
120
  - spec/spec_helper.rb