dhl-get_quote 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,6 +6,8 @@ Get shipping quotes from DHL's XML-PI Service.
6
6
 
7
7
  Use of the XML-PI Service requires you to have Site ID and Password from DHL. You can sign up here: https://myaccount.dhl.com/MyAccount/jsp/TermsAndConditionsIndex.htm
8
8
 
9
+ Many thanks to John Riff of DHL for his help during the development of this gem.
10
+
9
11
  ## Installation
10
12
 
11
13
  Add this line to your application's Gemfile:
@@ -31,8 +33,7 @@ Or install it yourself as:
31
33
  :test_mode => true # changes the url being hit
32
34
  )
33
35
 
34
- r.kilograms!
35
- r.centimeters!
36
+ r.metric_measurements!
36
37
 
37
38
  r.add_special_service("DD")
38
39
 
@@ -72,19 +73,40 @@ request = Dhl::GetQuote::Request.new(
72
73
 
73
74
  *NOTE*: You can also set default beforehand in, for example, an initializer. For more information on this, please see the section "Initializers with Dhl::GetQuote"
74
75
 
76
+ #### Setting Payment Account Number
77
+
78
+ If you are using a special account for shipping payments, you can specify it as
79
+
80
+ ```ruby
81
+ request.payment_account_number('12345678')
82
+ ```
83
+
84
+ To read the current payment account number (if set), use:
85
+
86
+ ```ruby
87
+ request.payment_accout_number
88
+ ```
89
+
90
+ It will return the current number or nil if none has been set.
91
+
75
92
  #### Package Source and Destination
76
93
 
77
94
  To set the source and destination, use the #to() and #from() methods:
78
95
 
79
- #to(_country_code_, _postal_code_), #from(_country_code_, _postal_code_)
96
+ #to(_country_code_, _postal_code_, city_name), #from(_country_code_, _postal_code_, city_name)
80
97
 
81
- The country code must be the two-letter capitalized ISO country code. The postal code will be cast in to a string.
98
+ The country code must be the two-letter capitalized ISO country code. The postal code will be cast in to a string. City name is optional.
82
99
 
83
100
  Example:
84
101
 
85
102
  ```ruby
103
+ # without city
86
104
  request.from('US', 84111)
87
105
  request.to('CA', 'T1H 0A1')
106
+
107
+ # with city
108
+ request.from('US', 84111, "Bountiful")
109
+ request.to('MX', "53950", 'Naucalpan de Juárez')
88
110
  ```
89
111
 
90
112
  #### Measurement Units
@@ -94,28 +116,21 @@ DHL can accept weights and measures in both Metric and US Customary units. Weig
94
116
  To set to US Customary, use:
95
117
 
96
118
  ```ruby
97
- request.inches! # set dimensions to inches
98
- request.pounds! # set weight to pounds
119
+ request.us_measurements! # set dimensions to inches and weight to pounds
99
120
  ```
100
121
 
101
122
  To set back to Metric, use
102
123
 
103
124
  ```ruby
104
- request.centimeters! # set dimensions to centimeters
105
- request.centimetres! # alternate spelling
106
-
107
- request.kilograms! # set weight to kilograms
108
- request.kilogrammes! # alternate spelling
125
+ request.metric_measurements! # set dimensions to centimeters and weight to kilograms
109
126
  ```
110
127
 
111
128
  To query what measurement system the object is currently using, use the following boolean calls:
112
129
 
113
130
  ```ruby
114
- request.inches?
115
- request.centimeters? # or request.centimetres?
131
+ request.us_measurements?
116
132
 
117
- request.pounds?
118
- request.kilograms? # or request.kilogrammes?
133
+ request.metric_measurements?
119
134
  ```
120
135
 
121
136
  You can also get the value directly:
@@ -129,11 +144,11 @@ You can also get the value directly:
129
144
 
130
145
  ! Note, this a breaking change from 0.4.x
131
146
 
132
- To set the duty on a shipment, use the dutiable!() method. It accepts the numeric value and an optional currency code. If not specified, the currency code default to US Dollars (USD).
147
+ To set the duty on a shipment, use the dutiable() method. It accepts the numeric value and an optional currency code. If not specified, the currency code default to US Dollars (USD).
133
148
 
134
149
  ```ruby
135
150
  # set the dutiable value at $100 in US Dollars
136
- request.dutiable!(100.00, 'USD')
151
+ request.dutiable(100.00, 'USD')
137
152
  ```
138
153
 
139
154
  To remove a previously set duty, use the not_dutiable!() method.
@@ -326,12 +341,10 @@ To do this, call Dhl::GetQuote::configure and pass a block:
326
341
 
327
342
  c.production_mode! # or test_mode!
328
343
 
329
- c.kilograms! # or kilogrammes!
330
- c.centimeters! # or centimetres!
331
- c.inches!
332
- c.pounds!
344
+ c.metric_measurements!
345
+ c.us_measurements!
333
346
 
334
- c.dutiable! # or not_dutiable!
347
+ c.dutiable(1.00, 'USD')
335
348
 
336
349
  end
337
350
  ```
@@ -43,16 +43,18 @@ class Dhl::GetQuote::Request
43
43
  @test_mode = false
44
44
  end
45
45
 
46
- def from(country_code, postal_code)
46
+ def from(country_code, postal_code, city=nil)
47
47
  @from_postal_code = postal_code.to_s
48
48
  validate_country_code!(country_code)
49
49
  @from_country_code = country_code
50
+ @from_city_name = city
50
51
  end
51
52
 
52
- def to(country_code, postal_code)
53
+ def to(country_code, postal_code, city=nil)
53
54
  @to_postal_code = postal_code.to_s
54
55
  validate_country_code!(country_code)
55
56
  @to_country_code = country_code
57
+ @to_city_name = city
56
58
  end
57
59
 
58
60
  def dutiable?
@@ -1,6 +1,6 @@
1
1
  class Dhl
2
2
  class GetQuote
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
 
5
5
  PostInstallMessage = <<EOS
6
6
 
@@ -63,6 +63,11 @@ describe Dhl::GetQuote::Request do
63
63
  subject.from('us', '84111')
64
64
  end.must raise_exception(Dhl::GetQuote::CountryCodeError)
65
65
  end
66
+
67
+ it 'must accept an optional city name' do
68
+ subject.from('US', '84111', "Bountiful")
69
+ subject.instance_variable_get(:@from_city_name).must == 'Bountiful'
70
+ end
66
71
  end
67
72
 
68
73
  describe '#to' do
@@ -94,6 +99,11 @@ describe Dhl::GetQuote::Request do
94
99
  subject.from('ca', 'T1H 0A1')
95
100
  end.must raise_exception(Dhl::GetQuote::CountryCodeError)
96
101
  end
102
+
103
+ it 'must accept an optional city name' do
104
+ subject.to('US', '84111', "Bountiful")
105
+ subject.instance_variable_get(:@to_city_name).must == 'Bountiful'
106
+ end
97
107
  end
98
108
 
99
109
  describe "#dutiable?" do
data/tpl/request.xml.erb CHANGED
@@ -10,6 +10,7 @@
10
10
  <From>
11
11
  <CountryCode><%= @from_country_code %></CountryCode>
12
12
  <Postalcode><%= @from_postal_code %></Postalcode>
13
+ <% if @from_city_name -%><City><%= @from_city_name %></City><% end -%>
13
14
  </From>
14
15
  <BkgDetails>
15
16
  <PaymentCountryCode><%= @from_country_code %></PaymentCountryCode>
@@ -38,6 +39,7 @@
38
39
  <To>
39
40
  <CountryCode><%= @to_country_code %></CountryCode>
40
41
  <Postalcode><%= @to_postal_code %></Postalcode>
42
+ <% if @to_city_name -%><City><%= @to_city_name %></City><% end -%>
41
43
  </To>
42
44
  <%- if dutiable? %>
43
45
  <Dutiable>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhl-get_quote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: