shipping 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/shipping/ups.rb
CHANGED
@@ -24,6 +24,8 @@ module Shipping
|
|
24
24
|
|
25
25
|
API_VERSION = "1.0001"
|
26
26
|
|
27
|
+
# For current implementation docs, see http://www.ec.ups.com/ecommerce/techdocs/pdf/RatesandServiceHTML.pdf
|
28
|
+
# For upcoming XML implementation docs, see http://www.ups.com/gec/techdocs/pdf/dtk_RateXML_V1.zip
|
27
29
|
def price
|
28
30
|
@required = [:zip, :country, :sender_zip, :weight]
|
29
31
|
|
@@ -42,38 +44,41 @@ module Shipping
|
|
42
44
|
return price.to_f
|
43
45
|
end
|
44
46
|
|
47
|
+
# See http://www.ups.com/gec/techdocs/pdf/dtk_AddrValidateXML_V1.zip for API info
|
48
|
+
|
45
49
|
def valid_address?( delta = 1.0 )
|
46
50
|
@required = [:ups_account, :ups_user, :ups_password]
|
47
51
|
|
48
52
|
state = STATES.has_value?(@state.downcase) ? STATES.index(@state.downcase) : @state
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
54
|
+
@data = String.new
|
55
|
+
b = Builder::XmlMarkup.new :target => @data
|
56
|
+
|
57
|
+
b.instruct!
|
58
|
+
b.AccessRequest {|b|
|
59
|
+
b.AccessLicenseNumber @ups_account
|
60
|
+
b.UserId @ups_user
|
61
|
+
b.Password @ups_password
|
62
|
+
}
|
63
|
+
b.instruct!
|
64
|
+
b.AddressValidationRequest {|b|
|
65
|
+
b.Request {|b|
|
66
|
+
b.RequestAction "AV"
|
67
|
+
b.TransactionReference {|b|
|
68
|
+
b.CustomerContext "#{@city}, #{state} #{@zip}"
|
69
|
+
b.XpciVersion API_VERSION
|
70
|
+
}
|
71
|
+
}
|
72
|
+
b.Address {|b|
|
73
|
+
b.City @city
|
74
|
+
b.StateProvinceCode state
|
75
|
+
b.PostalCode @zip
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
72
79
|
get_response "https://wwwcie.ups.com/ups.app/xml/AV"
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if doc.root.elements["Response"].elements["ResponseStatusCode"].text == "1" && doc.root.elements["AddressValidationResult"].elements["Quality"].text.to_f >= delta
|
80
|
+
|
81
|
+
if REXML::XPath.first(@response, "//AddressValidationResponse/Response/ResponseStatusCode").text == "1" && REXML::XPath.first(@response, "//AddressValidationResponse/AddressValidationResult/Quality").text.to_f >= delta
|
77
82
|
return true
|
78
83
|
else
|
79
84
|
return false
|
data/lib/shipping.rb
CHANGED
@@ -24,6 +24,13 @@
|
|
24
24
|
# Copyright:: Copyright (c) 2005 Lucas Carlson
|
25
25
|
# License:: LGPL
|
26
26
|
|
27
|
+
begin
|
28
|
+
require 'rubygems'
|
29
|
+
require_gem 'builder', '~> 1.2'
|
30
|
+
rescue LoadError
|
31
|
+
require 'builder'
|
32
|
+
end
|
33
|
+
|
27
34
|
require 'yaml'
|
28
35
|
require 'rexml/document'
|
29
36
|
require 'net/http'
|
data/test/fedex/fedex_test.rb
CHANGED
@@ -5,6 +5,33 @@ class FedExTest < Test::Unit::TestCase
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def test_price
|
8
|
-
assert_equal
|
8
|
+
assert_equal 4.67, @ship.price
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_base_price
|
12
|
+
assert_equal 5.07, @ship.base_price
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_fails
|
16
|
+
ship = Shipping::FedEx.new :zip => 97202, :weight => 2
|
17
|
+
assert_raise(Shipping::ShippingError) { ship.price }
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_label
|
21
|
+
@ship.name = "Package Receiver"
|
22
|
+
@ship.phone = "555-555-5555"
|
23
|
+
@ship.email = "lucas@rufy.com"
|
24
|
+
@ship.address = "Some address"
|
25
|
+
@ship.city = "Portland"
|
26
|
+
|
27
|
+
@ship.sender_name = "Package Sender"
|
28
|
+
@ship.sender_phone = "333-333-3333"
|
29
|
+
@ship.sender_email = "john@doe.com"
|
30
|
+
@ship.sender_address = "Ok old address"
|
31
|
+
@ship.sender_city = "New York"
|
32
|
+
|
33
|
+
response = nil
|
34
|
+
# assert_nothing_raised { response = @ship.label }
|
35
|
+
# assert_equal 'PackageSen', response.image_userid
|
9
36
|
end
|
10
37
|
end
|
data/test/ups/ups_test.rb
CHANGED
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.10
|
3
3
|
specification_version: 1
|
4
4
|
name: shipping
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2005-
|
6
|
+
version: 1.1.0
|
7
|
+
date: 2005-06-02
|
8
8
|
summary: A general shipping module to find out the shipping prices via UPS or FedEx.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- test/base/base_test.rb
|
40
40
|
- test/fedex/fedex_test.rb
|
41
41
|
- test/ups/ups_test.rb
|
42
|
+
- LICENSE
|
42
43
|
- Rakefile
|
43
44
|
- README
|
44
45
|
- doc/classes
|
@@ -58,11 +59,14 @@ files:
|
|
58
59
|
- doc/classes/Shipping/ShippingError.html
|
59
60
|
- doc/classes/Shipping/UPS.html
|
60
61
|
- doc/classes/Shipping/UPS.src
|
61
|
-
- doc/classes/Shipping/Base.src/
|
62
|
-
- doc/classes/Shipping/Base.src/
|
63
|
-
- doc/classes/Shipping/Base.src/
|
62
|
+
- doc/classes/Shipping/Base.src/M000008.html
|
63
|
+
- doc/classes/Shipping/Base.src/M000009.html
|
64
|
+
- doc/classes/Shipping/Base.src/M000010.html
|
64
65
|
- doc/classes/Shipping/FedEx.src/M000003.html
|
65
66
|
- doc/classes/Shipping/FedEx.src/M000004.html
|
67
|
+
- doc/classes/Shipping/FedEx.src/M000005.html
|
68
|
+
- doc/classes/Shipping/FedEx.src/M000006.html
|
69
|
+
- doc/classes/Shipping/FedEx.src/M000007.html
|
66
70
|
- doc/classes/Shipping/UPS.src/M000001.html
|
67
71
|
- doc/classes/Shipping/UPS.src/M000002.html
|
68
72
|
- doc/files/lib
|
@@ -77,5 +81,16 @@ rdoc_options: []
|
|
77
81
|
extra_rdoc_files: []
|
78
82
|
executables: []
|
79
83
|
extensions: []
|
80
|
-
requirements:
|
81
|
-
|
84
|
+
requirements:
|
85
|
+
- An xml-builder library.
|
86
|
+
dependencies:
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: builder
|
89
|
+
version_requirement:
|
90
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
91
|
+
requirements:
|
92
|
+
-
|
93
|
+
- ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.2.0
|
96
|
+
version:
|