shipping 1.0.0 → 1.1.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.
- data/LICENSE +429 -0
- data/Rakefile +4 -1
- data/doc/classes/Shipping/Base.html +85 -15
- data/doc/classes/Shipping/Base.src/{M000005.html → M000008.html} +2 -2
- data/doc/classes/Shipping/Base.src/{M000006.html → M000009.html} +1 -1
- data/doc/classes/Shipping/Base.src/{M000007.html → M000010.html} +1 -1
- data/doc/classes/Shipping/FedEx.html +87 -5
- data/doc/classes/Shipping/FedEx.src/M000003.html +3 -3
- data/doc/classes/Shipping/FedEx.src/M000004.html +3 -3
- data/doc/classes/Shipping/FedEx.src/M000005.html +39 -0
- data/doc/classes/Shipping/FedEx.src/M000006.html +50 -0
- data/doc/classes/Shipping/FedEx.src/M000007.html +155 -0
- data/doc/classes/Shipping/UPS.html +11 -0
- data/doc/classes/Shipping/UPS.src/M000001.html +1 -1
- data/doc/classes/Shipping/UPS.src/M000002.html +28 -27
- data/doc/classes/Shipping.html +5 -0
- data/doc/created.rid +1 -1
- data/doc/files/README.html +1 -1
- data/doc/files/lib/shipping/base_rb.html +1 -1
- data/doc/files/lib/shipping/fedex_rb.html +6 -1
- data/doc/files/lib/shipping/ups_rb.html +1 -1
- data/doc/files/lib/shipping_rb.html +3 -1
- data/doc/fr_method_index.html +7 -4
- data/lib/shipping/base.rb +13 -7
- data/lib/shipping/fedex.rb +321 -483
- data/lib/shipping/ups.rb +31 -26
- data/lib/shipping.rb +7 -0
- data/test/fedex/fedex_test.rb +28 -1
- data/test/ups/ups_test.rb +1 -1
- metadata +23 -8
@@ -135,6 +135,12 @@
|
|
135
135
|
</div>
|
136
136
|
|
137
137
|
<div class="method-description">
|
138
|
+
<p>
|
139
|
+
For current implementation docs, see <a
|
140
|
+
href="http://www.ec.ups.com/ecommerce/techdocs/pdf/RatesandServiceHTML.pdf">www.ec.ups.com/ecommerce/techdocs/pdf/RatesandServiceHTML.pdf</a>
|
141
|
+
For upcoming XML implementation docs, see <a
|
142
|
+
href="http://www.ups.com/gec/techdocs/pdf/dtk_RateXML_V1.zip">www.ups.com/gec/techdocs/pdf/dtk_RateXML_V1.zip</a>
|
143
|
+
</p>
|
138
144
|
</div>
|
139
145
|
</div>
|
140
146
|
|
@@ -149,6 +155,11 @@
|
|
149
155
|
</div>
|
150
156
|
|
151
157
|
<div class="method-description">
|
158
|
+
<p>
|
159
|
+
See <a
|
160
|
+
href="http://www.ups.com/gec/techdocs/pdf/dtk_AddrValidateXML_V1.zip">www.ups.com/gec/techdocs/pdf/dtk_AddrValidateXML_V1.zip</a>
|
161
|
+
for API info
|
162
|
+
</p>
|
152
163
|
</div>
|
153
164
|
</div>
|
154
165
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/shipping/ups.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/shipping/ups.rb, line 29</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">price</span>
|
15
15
|
<span class="ruby-ivar">@required</span> = [<span class="ruby-identifier">:zip</span>, <span class="ruby-identifier">:country</span>, <span class="ruby-identifier">:sender_zip</span>, <span class="ruby-identifier">:weight</span>]
|
16
16
|
|
@@ -10,39 +10,40 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/shipping/ups.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/shipping/ups.rb, line 49</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valid_address?</span>( <span class="ruby-identifier">delta</span> = <span class="ruby-value">1.0</span> )
|
15
15
|
<span class="ruby-ivar">@required</span> = [<span class="ruby-identifier">:ups_account</span>, <span class="ruby-identifier">:ups_user</span>, <span class="ruby-identifier">:ups_password</span>]
|
16
16
|
|
17
17
|
<span class="ruby-identifier">state</span> = <span class="ruby-constant">STATES</span>.<span class="ruby-identifier">has_value?</span>(<span class="ruby-ivar">@state</span>.<span class="ruby-identifier">downcase</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">STATES</span>.<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@state</span>.<span class="ruby-identifier">downcase</span>) <span class="ruby-operator">:</span> <span class="ruby-ivar">@state</span>
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
19
|
+
<span class="ruby-ivar">@data</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>
|
20
|
+
<span class="ruby-identifier">b</span> = <span class="ruby-constant">Builder</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMarkup</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">:target</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@data</span>
|
21
|
+
|
22
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-identifier">instruct!</span>
|
23
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">AccessRequest</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
|
24
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">AccessLicenseNumber</span> <span class="ruby-ivar">@ups_account</span>
|
25
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">UserId</span> <span class="ruby-ivar">@ups_user</span>
|
26
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">Password</span> <span class="ruby-ivar">@ups_password</span>
|
27
|
+
}
|
28
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-identifier">instruct!</span>
|
29
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">AddressValidationRequest</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
|
30
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">Request</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
|
31
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">RequestAction</span> <span class="ruby-value str">"AV"</span>
|
32
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">TransactionReference</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
|
33
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">CustomerContext</span> <span class="ruby-node">"#{@city}, #{state} #{@zip}"</span>
|
34
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">XpciVersion</span> <span class="ruby-constant">API_VERSION</span>
|
35
|
+
}
|
36
|
+
}
|
37
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">Address</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
|
38
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">City</span> <span class="ruby-ivar">@city</span>
|
39
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">StateProvinceCode</span> <span class="ruby-identifier">state</span>
|
40
|
+
<span class="ruby-identifier">b</span>.<span class="ruby-constant">PostalCode</span> <span class="ruby-ivar">@zip</span>
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
41
44
|
<span class="ruby-identifier">get_response</span> <span class="ruby-value str">"https://wwwcie.ups.com/ups.app/xml/AV"</span>
|
42
|
-
|
43
|
-
<span class="ruby-identifier">
|
44
|
-
|
45
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"Response"</span>].<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"ResponseStatusCode"</span>].<span class="ruby-identifier">text</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"1"</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"AddressValidationResult"</span>].<span class="ruby-identifier">elements</span>[<span class="ruby-value str">"Quality"</span>].<span class="ruby-identifier">text</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">delta</span>
|
45
|
+
|
46
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-ivar">@response</span>, <span class="ruby-value str">"//AddressValidationResponse/Response/ResponseStatusCode"</span>).<span class="ruby-identifier">text</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"1"</span> <span class="ruby-operator">&&</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-ivar">@response</span>, <span class="ruby-value str">"//AddressValidationResponse/AddressValidationResult/Quality"</span>).<span class="ruby-identifier">text</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">delta</span>
|
46
47
|
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
47
48
|
<span class="ruby-keyword kw">else</span>
|
48
49
|
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
data/doc/classes/Shipping.html
CHANGED
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Thu Jun 02 02:00:08 PDT 2005
|
data/doc/files/README.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Thu Jun 02 01:41:40 PDT 2005</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -80,6 +80,11 @@
|
|
80
80
|
|
81
81
|
</td></tr>
|
82
82
|
</table>
|
83
|
+
<p>
|
84
|
+
See <a
|
85
|
+
href="http://www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf?link=4">www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf?link=4</a>
|
86
|
+
for the full XML-based API
|
87
|
+
</p>
|
83
88
|
|
84
89
|
</div>
|
85
90
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Fri May 13 01:21:56 PDT 2005</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -87,6 +87,8 @@
|
|
87
87
|
<h3 class="section-bar">Required files</h3>
|
88
88
|
|
89
89
|
<div class="name-list">
|
90
|
+
rubygems
|
91
|
+
builder
|
90
92
|
yaml
|
91
93
|
rexml/document
|
92
94
|
net/http
|
data/doc/fr_method_index.html
CHANGED
@@ -21,11 +21,14 @@
|
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
23
|
<a href="classes/Shipping/FedEx.html#M000004">base_price (Shipping::FedEx)</a><br />
|
24
|
-
<a href="classes/Shipping/
|
25
|
-
<a href="classes/Shipping/Base.html#
|
26
|
-
<a href="classes/Shipping/
|
24
|
+
<a href="classes/Shipping/FedEx.html#M000005">express_service_availability (Shipping::FedEx)</a><br />
|
25
|
+
<a href="classes/Shipping/Base.html#M000009">fedex (Shipping::Base)</a><br />
|
26
|
+
<a href="classes/Shipping/FedEx.html#M000007">label (Shipping::FedEx)</a><br />
|
27
|
+
<a href="classes/Shipping/Base.html#M000008">new (Shipping::Base)</a><br />
|
27
28
|
<a href="classes/Shipping/FedEx.html#M000003">price (Shipping::FedEx)</a><br />
|
28
|
-
<a href="classes/Shipping/
|
29
|
+
<a href="classes/Shipping/UPS.html#M000001">price (Shipping::UPS)</a><br />
|
30
|
+
<a href="classes/Shipping/FedEx.html#M000006">register (Shipping::FedEx)</a><br />
|
31
|
+
<a href="classes/Shipping/Base.html#M000010">ups (Shipping::Base)</a><br />
|
29
32
|
<a href="classes/Shipping/UPS.html#M000002">valid_address? (Shipping::UPS)</a><br />
|
30
33
|
</div>
|
31
34
|
</div>
|
data/lib/shipping/base.rb
CHANGED
@@ -3,20 +3,22 @@
|
|
3
3
|
# License:: LGPL
|
4
4
|
|
5
5
|
module Shipping
|
6
|
-
class ShippingError < StandardError; end
|
6
|
+
class ShippingError < StandardError; end
|
7
7
|
|
8
8
|
class Base
|
9
|
-
attr_reader :data, :response, :required
|
9
|
+
attr_reader :data, :response, :plain_response, :required
|
10
10
|
|
11
11
|
attr_writer :ups_account, :ups_user, :ups_password
|
12
12
|
attr_writer :fedex_account, :fedex_meter, :fedex_url
|
13
13
|
|
14
|
-
attr_accessor :city, :state, :zip, :country
|
15
|
-
attr_accessor :sender_city, :sender_state, :sender_zip, :sender_country
|
14
|
+
attr_accessor :name, :phone, :email, :address, :city, :state, :zip, :country
|
15
|
+
attr_accessor :sender_name, :sender_phone, :sender_email, :sender_address, :sender_city, :sender_state, :sender_zip, :sender_country
|
16
16
|
|
17
|
-
attr_accessor :weight, :weight_units, :insured_value, :declared_value, :transaction_type
|
17
|
+
attr_accessor :weight, :weight_units, :insured_value, :declared_value, :transaction_type, :description
|
18
18
|
attr_accessor :package_total, :packaging_type, :service_type
|
19
19
|
|
20
|
+
attr_accessor :ship_date, :dropoff_type, :pay_type, :currency_code
|
21
|
+
|
20
22
|
def initialize(options = {})
|
21
23
|
prefs = File.expand_path(options[:prefs] || "~/.shipping.yml")
|
22
24
|
YAML.load(File.open(prefs)).each {|pref, value| eval("@#{pref} = #{value.inspect}")} if File.exists?(prefs)
|
@@ -26,7 +28,7 @@ module Shipping
|
|
26
28
|
# include all provided data
|
27
29
|
options.each do |method, value|
|
28
30
|
instance_variable_set("@#{method}", value)
|
29
|
-
end
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
# Initializes an instance of Shipping::FedEx with the same instance variables as the base object
|
@@ -55,7 +57,11 @@ module Shipping
|
|
55
57
|
http.use_ssl = true
|
56
58
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
57
59
|
end
|
58
|
-
@
|
60
|
+
@response_plain = http.post(uri.path, @data).body
|
61
|
+
@response = @response_plain.include?('<?xml') ? REXML::Document.new(@response_plain) : @response_plain
|
62
|
+
|
63
|
+
@response.instance_variable_set "@response_plain", @response_plain
|
64
|
+
def @response.plain; @response_plain; end
|
59
65
|
end
|
60
66
|
|
61
67
|
# Make sure that the required fields are not empty
|