shippinglogic 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/CHANGELOG.rdoc +55 -0
- data/LICENSE +20 -0
- data/README.rdoc +175 -0
- data/Rakefile +37 -0
- data/VERSION.yml +5 -0
- data/init.rb +1 -0
- data/lib/shippinglogic.rb +3 -0
- data/lib/shippinglogic/attributes.rb +121 -0
- data/lib/shippinglogic/error.rb +22 -0
- data/lib/shippinglogic/fedex.rb +84 -0
- data/lib/shippinglogic/fedex/cancel.rb +47 -0
- data/lib/shippinglogic/fedex/enumerations.rb +348 -0
- data/lib/shippinglogic/fedex/error.rb +47 -0
- data/lib/shippinglogic/fedex/rate.rb +229 -0
- data/lib/shippinglogic/fedex/request.rb +134 -0
- data/lib/shippinglogic/fedex/response.rb +72 -0
- data/lib/shippinglogic/fedex/service.rb +11 -0
- data/lib/shippinglogic/fedex/ship.rb +238 -0
- data/lib/shippinglogic/fedex/signature.rb +68 -0
- data/lib/shippinglogic/fedex/track.rb +124 -0
- data/lib/shippinglogic/proxy.rb +23 -0
- data/lib/shippinglogic/service.rb +42 -0
- data/lib/shippinglogic/ups.rb +83 -0
- data/lib/shippinglogic/ups/cancel.rb +52 -0
- data/lib/shippinglogic/ups/enumerations.rb +56 -0
- data/lib/shippinglogic/ups/error.rb +42 -0
- data/lib/shippinglogic/ups/label.rb +50 -0
- data/lib/shippinglogic/ups/rate.rb +228 -0
- data/lib/shippinglogic/ups/request.rb +49 -0
- data/lib/shippinglogic/ups/response.rb +58 -0
- data/lib/shippinglogic/ups/service.rb +11 -0
- data/lib/shippinglogic/ups/ship_accept.rb +53 -0
- data/lib/shippinglogic/ups/ship_confirm.rb +170 -0
- data/lib/shippinglogic/ups/track.rb +118 -0
- data/lib/shippinglogic/validation.rb +32 -0
- data/shippinglogic.gemspec +120 -0
- data/spec/attributes_spec.rb +67 -0
- data/spec/config/fedex_credentials.example.yml +4 -0
- data/spec/config/ups_credentials.example.yml +3 -0
- data/spec/error_spec.rb +43 -0
- data/spec/fedex/cancel_spec.rb +10 -0
- data/spec/fedex/error_spec.rb +26 -0
- data/spec/fedex/rate_spec.rb +87 -0
- data/spec/fedex/request_spec.rb +15 -0
- data/spec/fedex/responses/blank.xml +0 -0
- data/spec/fedex/responses/cancel_not_found.xml +7 -0
- data/spec/fedex/responses/failed_authentication.xml +7 -0
- data/spec/fedex/responses/malformed.xml +8 -0
- data/spec/fedex/responses/rate_defaults.xml +7 -0
- data/spec/fedex/responses/rate_insurance.xml +9 -0
- data/spec/fedex/responses/rate_no_services.xml +7 -0
- data/spec/fedex/responses/rate_non_custom_packaging.xml +7 -0
- data/spec/fedex/responses/ship_defaults.xml +7 -0
- data/spec/fedex/responses/ship_with_no_signature.xml +7 -0
- data/spec/fedex/responses/signature_defaults.xml +7 -0
- data/spec/fedex/responses/track_defaults.xml +7 -0
- data/spec/fedex/responses/unexpected.xml +1 -0
- data/spec/fedex/service_spec.rb +19 -0
- data/spec/fedex/ship_spec.rb +37 -0
- data/spec/fedex/signature_spec.rb +11 -0
- data/spec/fedex/spec_helper.rb +84 -0
- data/spec/fedex/track_spec.rb +37 -0
- data/spec/fedex_spec.rb +16 -0
- data/spec/lib/interceptor.rb +17 -0
- data/spec/proxy_spec.rb +42 -0
- data/spec/service_spec.rb +23 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/ups/responses/blank.xml +0 -0
- data/spec/ups/responses/track_defaults.xml +2 -0
- data/spec/ups/spec_helper.rb +43 -0
- data/spec/ups_spec.rb +16 -0
- data/spec/validation_spec.rb +49 -0
- metadata +163 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require "shippinglogic/error"
|
2
|
+
|
3
|
+
module Shippinglogic
|
4
|
+
# This module is more for application integration, so you can do something like:
|
5
|
+
#
|
6
|
+
# tracking = fedex.tracking
|
7
|
+
# if tracking.valid?
|
8
|
+
# # render a successful response
|
9
|
+
# else
|
10
|
+
# # do something with the errors: fedex.errors
|
11
|
+
# end
|
12
|
+
module Validation
|
13
|
+
# Just an array of errors that were encounted if valid? returns false.
|
14
|
+
def errors
|
15
|
+
@errors ||= []
|
16
|
+
end
|
17
|
+
|
18
|
+
# Allows you to determine if the request is valid or not. All validation is delegated to the API
|
19
|
+
# services, so what this does is make a call to the API and rescue any errors, then it puts those
|
20
|
+
# errors into the 'errors' array.
|
21
|
+
def valid?
|
22
|
+
begin
|
23
|
+
target
|
24
|
+
true
|
25
|
+
rescue Error => e
|
26
|
+
errors.clear
|
27
|
+
self.errors << e.message
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "shippinglogic"
|
8
|
+
s.version = "1.2.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ben Johnson of Binary Logic"]
|
12
|
+
s.date = "2012-04-20"
|
13
|
+
s.description = "Easily use FedEx, UPS, USPS web services with an elegant and simple syntax."
|
14
|
+
s.email = "bjohnson@binarylogic.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"CHANGELOG.rdoc",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION.yml",
|
26
|
+
"init.rb",
|
27
|
+
"lib/shippinglogic.rb",
|
28
|
+
"lib/shippinglogic/attributes.rb",
|
29
|
+
"lib/shippinglogic/error.rb",
|
30
|
+
"lib/shippinglogic/fedex.rb",
|
31
|
+
"lib/shippinglogic/fedex/cancel.rb",
|
32
|
+
"lib/shippinglogic/fedex/enumerations.rb",
|
33
|
+
"lib/shippinglogic/fedex/error.rb",
|
34
|
+
"lib/shippinglogic/fedex/rate.rb",
|
35
|
+
"lib/shippinglogic/fedex/request.rb",
|
36
|
+
"lib/shippinglogic/fedex/response.rb",
|
37
|
+
"lib/shippinglogic/fedex/service.rb",
|
38
|
+
"lib/shippinglogic/fedex/ship.rb",
|
39
|
+
"lib/shippinglogic/fedex/signature.rb",
|
40
|
+
"lib/shippinglogic/fedex/track.rb",
|
41
|
+
"lib/shippinglogic/proxy.rb",
|
42
|
+
"lib/shippinglogic/service.rb",
|
43
|
+
"lib/shippinglogic/ups.rb",
|
44
|
+
"lib/shippinglogic/ups/cancel.rb",
|
45
|
+
"lib/shippinglogic/ups/enumerations.rb",
|
46
|
+
"lib/shippinglogic/ups/error.rb",
|
47
|
+
"lib/shippinglogic/ups/label.rb",
|
48
|
+
"lib/shippinglogic/ups/rate.rb",
|
49
|
+
"lib/shippinglogic/ups/request.rb",
|
50
|
+
"lib/shippinglogic/ups/response.rb",
|
51
|
+
"lib/shippinglogic/ups/service.rb",
|
52
|
+
"lib/shippinglogic/ups/ship_accept.rb",
|
53
|
+
"lib/shippinglogic/ups/ship_confirm.rb",
|
54
|
+
"lib/shippinglogic/ups/track.rb",
|
55
|
+
"lib/shippinglogic/validation.rb",
|
56
|
+
"shippinglogic.gemspec",
|
57
|
+
"spec/attributes_spec.rb",
|
58
|
+
"spec/config/fedex_credentials.example.yml",
|
59
|
+
"spec/config/ups_credentials.example.yml",
|
60
|
+
"spec/error_spec.rb",
|
61
|
+
"spec/fedex/cancel_spec.rb",
|
62
|
+
"spec/fedex/error_spec.rb",
|
63
|
+
"spec/fedex/rate_spec.rb",
|
64
|
+
"spec/fedex/request_spec.rb",
|
65
|
+
"spec/fedex/responses/blank.xml",
|
66
|
+
"spec/fedex/responses/cancel_not_found.xml",
|
67
|
+
"spec/fedex/responses/failed_authentication.xml",
|
68
|
+
"spec/fedex/responses/malformed.xml",
|
69
|
+
"spec/fedex/responses/rate_defaults.xml",
|
70
|
+
"spec/fedex/responses/rate_insurance.xml",
|
71
|
+
"spec/fedex/responses/rate_no_services.xml",
|
72
|
+
"spec/fedex/responses/rate_non_custom_packaging.xml",
|
73
|
+
"spec/fedex/responses/ship_defaults.xml",
|
74
|
+
"spec/fedex/responses/ship_with_no_signature.xml",
|
75
|
+
"spec/fedex/responses/signature_defaults.xml",
|
76
|
+
"spec/fedex/responses/track_defaults.xml",
|
77
|
+
"spec/fedex/responses/unexpected.xml",
|
78
|
+
"spec/fedex/service_spec.rb",
|
79
|
+
"spec/fedex/ship_spec.rb",
|
80
|
+
"spec/fedex/signature_spec.rb",
|
81
|
+
"spec/fedex/spec_helper.rb",
|
82
|
+
"spec/fedex/track_spec.rb",
|
83
|
+
"spec/fedex_spec.rb",
|
84
|
+
"spec/lib/interceptor.rb",
|
85
|
+
"spec/proxy_spec.rb",
|
86
|
+
"spec/service_spec.rb",
|
87
|
+
"spec/spec_helper.rb",
|
88
|
+
"spec/ups/responses/blank.xml",
|
89
|
+
"spec/ups/responses/track_defaults.xml",
|
90
|
+
"spec/ups/spec_helper.rb",
|
91
|
+
"spec/ups_spec.rb",
|
92
|
+
"spec/validation_spec.rb"
|
93
|
+
]
|
94
|
+
s.homepage = "http://github.com/binarylogic/shippinglogic"
|
95
|
+
s.require_paths = ["lib"]
|
96
|
+
s.rubygems_version = "1.8.17"
|
97
|
+
s.summary = "A simple and clean library to interface with shipping carriers"
|
98
|
+
|
99
|
+
if s.respond_to? :specification_version then
|
100
|
+
s.specification_version = 3
|
101
|
+
|
102
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
103
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
104
|
+
s.add_development_dependency(%q<fakeweb>, [">= 0"])
|
105
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.4.4"])
|
106
|
+
s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
|
107
|
+
else
|
108
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
109
|
+
s.add_dependency(%q<fakeweb>, [">= 0"])
|
110
|
+
s.add_dependency(%q<httparty>, [">= 0.4.4"])
|
111
|
+
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
112
|
+
end
|
113
|
+
else
|
114
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
115
|
+
s.add_dependency(%q<fakeweb>, [">= 0"])
|
116
|
+
s.add_dependency(%q<httparty>, [">= 0.4.4"])
|
117
|
+
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Service Attributes" do
|
4
|
+
before(:all) do
|
5
|
+
class ::ServiceWithAttributes
|
6
|
+
include Shippinglogic::Attributes
|
7
|
+
|
8
|
+
attribute :tracking_number, :string
|
9
|
+
attribute :packaging_type, :string, :default => "YOUR_PACKAGING"
|
10
|
+
attribute :special_services_requested, :array
|
11
|
+
attribute :ship_time, :datetime, :default => lambda { |shipment| Time.now }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:all) do
|
16
|
+
Object.send(:remove_const, :ServiceWithAttributes)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should allow setting attributes upon initialization" do
|
20
|
+
service = ServiceWithAttributes.new(:tracking_number => "TEST")
|
21
|
+
service.tracking_number.should == "TEST"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should allow setting attributes individually" do
|
25
|
+
service = ServiceWithAttributes.new
|
26
|
+
service.tracking_number = "TEST"
|
27
|
+
service.tracking_number.should == "TEST"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should allow setting attributes with a hash" do
|
31
|
+
service = ServiceWithAttributes.new
|
32
|
+
service.attributes = {:tracking_number => "TEST"}
|
33
|
+
service.tracking_number.should == "TEST"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should allow reading attributes" do
|
37
|
+
service = ServiceWithAttributes.new
|
38
|
+
service.attributes = {:tracking_number => "TEST"}
|
39
|
+
service.attributes.should be_a(Hash)
|
40
|
+
service.attributes.should have_key(:tracking_number)
|
41
|
+
service.attributes[:tracking_number].should == "TEST"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should implement defaults" do
|
45
|
+
service = ServiceWithAttributes.new
|
46
|
+
service.packaging_type.should == "YOUR_PACKAGING"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should use blank array as defaults for arrays" do
|
50
|
+
service = ServiceWithAttributes.new
|
51
|
+
service.special_services_requested.should == []
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should call procs during run time if a default is a proc" do
|
55
|
+
service = ServiceWithAttributes.new
|
56
|
+
service.ship_time.to_s.should == Time.now.to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should parse string representations of times" do
|
60
|
+
service = ServiceWithAttributes.new
|
61
|
+
service.ship_time = "19551105000000"
|
62
|
+
service.ship_time.should be_a(Time)
|
63
|
+
service.ship_time.strftime("%B") == "November"
|
64
|
+
service.ship_time.day.should == 5
|
65
|
+
service.ship_time.year.should == 1955
|
66
|
+
end
|
67
|
+
end
|
data/spec/error_spec.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Shippinglogic Errors" do
|
4
|
+
before(:each) do
|
5
|
+
@error = Shippinglogic::Error.new("", "")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should inherit from StandardError" do
|
9
|
+
@error.should be_a(StandardError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should contain an array of errors" do
|
13
|
+
@error.errors.should == []
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be able to add error hashes" do
|
17
|
+
@error.errors.size.should == 0
|
18
|
+
@error.add_error("MESSAGE")
|
19
|
+
@error.errors.size.should == 1
|
20
|
+
@error.errors.last.should be_a(Hash)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should append (not prepend) error hashes" do
|
24
|
+
@error.add_error("FIRST")
|
25
|
+
@error.errors.last[:message].should == "FIRST"
|
26
|
+
@error.add_error("LAST")
|
27
|
+
@error.errors.last[:message].should == "LAST"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have error hashes containing a required message" do
|
31
|
+
@error.add_error("MESSAGE")
|
32
|
+
@error.errors.last.should have_key(:message)
|
33
|
+
@error.errors.last[:message].should == "MESSAGE"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have error hashes containing an optional code" do
|
37
|
+
@error.add_error("WITHOUT")
|
38
|
+
@error.errors.last.should have_key(:code)
|
39
|
+
@error.errors.last[:code].should be_nil
|
40
|
+
@error.add_error("WITH", "CODE")
|
41
|
+
@error.errors.last[:code].should == "CODE"
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "FedEx Track" do
|
4
|
+
it "should cancel the shipment" do
|
5
|
+
use_response(:cancel_not_found)
|
6
|
+
fedex = new_fedex
|
7
|
+
cancel = fedex.cancel(:tracking_number => fedex_tracking_number)
|
8
|
+
lambda { cancel.perform }.should raise_error(Shippinglogic::FedEx::Error, "Unable to retrieve record from database")
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "FedEx Error" do
|
4
|
+
it "should handle blank response errors" do
|
5
|
+
use_response(:blank)
|
6
|
+
lambda { new_fedex.track(:tracking_number => fedex_tracking_number).size }.should raise_error(Shippinglogic::FedEx::Error, "The response from FedEx was blank.")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should pass through malformed errors" do
|
10
|
+
use_response(:malformed, :content_type => "")
|
11
|
+
lambda { new_fedex.track(:tracking_number => fedex_tracking_number).size }.should raise_error(Shippinglogic::FedEx::Error, "The response from FedEx was malformed and was not in a valid XML format.")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should pass through authentication errors" do
|
15
|
+
use_response(:failed_authentication)
|
16
|
+
fedex = Shippinglogic::FedEx.new("", "", "", "")
|
17
|
+
lambda { fedex.track(:tracking_number => fedex_tracking_number).size }.should raise_error(Shippinglogic::FedEx::Error, "Authentication Failed")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should pass through unexpected errors" do
|
21
|
+
use_response(:unexpected)
|
22
|
+
lambda { new_fedex.track(:tracking_number => fedex_tracking_number).size }.should raise_error(Shippinglogic::FedEx::Error, "There was a problem with your fedex request, and " +
|
23
|
+
"we couldn't locate a specific error message. This means your response was in an unexpected format. You might try glancing at the raw response " +
|
24
|
+
"by using the 'response' method on this error object.")
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "FedEx Rate" do
|
4
|
+
it "should rate the shipment" do
|
5
|
+
use_response(:rate_defaults)
|
6
|
+
|
7
|
+
fedex = new_fedex
|
8
|
+
rates = fedex.rate
|
9
|
+
|
10
|
+
rates.attributes = fedex_shipper
|
11
|
+
rates.attributes = fedex_recipient
|
12
|
+
rates.attributes = fedex_package
|
13
|
+
rates.size.should == 6
|
14
|
+
|
15
|
+
rate = rates.first
|
16
|
+
rate.name.should == "First Overnight"
|
17
|
+
rate.type.should == "FIRST_OVERNIGHT"
|
18
|
+
rate.saturday.should == false
|
19
|
+
rate.delivered_by.should == Time.parse("Fri Aug 07 08:00:00 -0400 2009")
|
20
|
+
rate.speed.should == 86400 # 1.day
|
21
|
+
rate.rate.should == 70.01
|
22
|
+
rate.currency.should == "USD"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not require package dimensions when not using custom packaging" do
|
26
|
+
use_response(:rate_non_custom_packaging)
|
27
|
+
|
28
|
+
fedex = new_fedex
|
29
|
+
rates = fedex.rate
|
30
|
+
|
31
|
+
rates.attributes = fedex_shipper
|
32
|
+
rates.attributes = fedex_recipient
|
33
|
+
rates.packaging_type = "FEDEX_ENVELOPE"
|
34
|
+
rates.package_weight = 0.1
|
35
|
+
|
36
|
+
rates.size.should == 5
|
37
|
+
|
38
|
+
rate = rates.first
|
39
|
+
rate.name.should == "First Overnight"
|
40
|
+
rate.type.should == "FIRST_OVERNIGHT"
|
41
|
+
rate.saturday.should == false
|
42
|
+
rate.delivered_by.should == Time.parse("Mon Aug 10 08:00:00 -0400 2009")
|
43
|
+
rate.speed.should == 86400 # 1.day
|
44
|
+
rate.rate.should == 50.43
|
45
|
+
rate.currency.should == "USD"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should handle responses with no services" do
|
49
|
+
use_response(:rate_no_services)
|
50
|
+
|
51
|
+
fedex = new_fedex
|
52
|
+
rates = fedex.rate
|
53
|
+
|
54
|
+
rates.attributes = fedex_shipper
|
55
|
+
rates.attributes = fedex_recipient
|
56
|
+
rates.packaging_type = "FEDEX_ENVELOPE"
|
57
|
+
rates.package_weight = 2
|
58
|
+
rates.size.should == 0
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should remove any services that don't meet the deadline" do
|
62
|
+
use_response(:rate_defaults)
|
63
|
+
|
64
|
+
fedex = new_fedex
|
65
|
+
rates = fedex.rate
|
66
|
+
|
67
|
+
rates.attributes = fedex_shipper
|
68
|
+
rates.attributes = fedex_recipient
|
69
|
+
rates.attributes = fedex_package
|
70
|
+
rates.delivery_deadline = Time.parse("Aug 07 08:01:00 -0400 2009")
|
71
|
+
rates.size.should == 1
|
72
|
+
rates.first.delivered_by.should == Time.parse("Fri Aug 07 08:00:00 -0400 2009")
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should rate the shipment with an insured value" do
|
76
|
+
use_response(:rate_insurance)
|
77
|
+
|
78
|
+
fedex = new_fedex
|
79
|
+
rates = fedex.rate
|
80
|
+
|
81
|
+
rates.attributes = fedex_shipper
|
82
|
+
rates.attributes = fedex_recipient
|
83
|
+
rates.attributes = fedex_package
|
84
|
+
rates.insured_value = 200
|
85
|
+
rates.size.should == 6
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "FedEx Attributes" do
|
4
|
+
it "should convert full country names to country codes" do
|
5
|
+
fedex = new_fedex
|
6
|
+
rates = fedex.rate
|
7
|
+
rates.send(:country_code, "United States").should == "US"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should convert full state names to state codes" do
|
11
|
+
fedex = new_fedex
|
12
|
+
rates = fedex.rate
|
13
|
+
rates.send(:state_code, "Texas").should == "TX"
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<v6:ShipmentReply xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:v6="http://fedex.com/ws/ship/v6"><v6:HighestSeverity>ERROR</v6:HighestSeverity><v6:Notifications><v6:Severity>ERROR</v6:Severity><v6:Source>ship</v6:Source><v6:Code>8149</v6:Code><v6:Message>Unable to retrieve record from database</v6:Message><v6:LocalizedMessage>Unable to retrieve record from database</v6:LocalizedMessage></v6:Notifications><v6:Version>
|
3
|
+
<v6:ServiceId>ship</v6:ServiceId>
|
4
|
+
<v6:Major>6</v6:Major>
|
5
|
+
<v6:Intermediate>0</v6:Intermediate>
|
6
|
+
<v6:Minor>0</v6:Minor>
|
7
|
+
</v6:Version></v6:ShipmentReply>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ns:TrackReply xmlns:ns="http://fedex.com/ws/track/v3"><ns:HighestSeverity>ERROR</ns:HighestSeverity><ns:Notifications><ns:Severity>ERROR</ns:Severity><ns:Source>prof</ns:Source><ns:Code>1000</ns:Code><ns:Message>Authentication Failed</ns:Message></ns:Notifications><ns:Version>
|
3
|
+
<ns:ServiceId>trck</ns:ServiceId>
|
4
|
+
<ns:Major>3</ns:Major>
|
5
|
+
<ns:Intermediate>0</ns:Intermediate>
|
6
|
+
<ns:Minor>0</ns:Minor>
|
7
|
+
</ns:Version></ns:TrackReply>
|