active_shipping 1.9.2 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/active_shipping.gemspec +1 -1
- data/lib/active_shipping.rb +1 -0
- data/lib/active_shipping/address_validation_response.rb +30 -0
- data/lib/active_shipping/carriers/fedex.rb +51 -28
- data/lib/active_shipping/carriers/ups.rb +108 -1
- data/lib/active_shipping/version.rb +1 -1
- data/test/fixtures/xml/fedex/tracking_response_unable_to_process.xml +32 -0
- data/test/fixtures/xml/ups/address_validation_request.xml +14 -0
- data/test/fixtures/xml/ups/address_validation_response.xml +25 -0
- data/test/fixtures/xml/ups/address_validation_response_ambiguous.xml +38 -0
- data/test/fixtures/xml/ups/address_validation_response_no_candidates.xml +8 -0
- data/test/remote/fedex_test.rb +2 -0
- data/test/unit/carriers/fedex_test.rb +30 -16
- data/test/unit/carriers/ups_test.rb +28 -0
- metadata +17 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6478be87d7d470eaec0ca8142a1bc13bd9385eec
|
4
|
+
data.tar.gz: 68dc6e8aa2821f4d86f15543eef680be9a34f798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a9870708b91d2bbcf436d295cfef6d73537090f9b1de4d3e9372bf58759a977e1e79b1c735b0fbdd460fc25602bb5e40abc00ef405e53bf70c071e7b8d7ec62
|
7
|
+
data.tar.gz: f533ab6e93abd4395da473620be33f8330e2ab8c530a95c141b44dd3fc097cd60b85b80604e72229b2e45d0c3c64b1d5775e9ec1f130b26b99610cc3fd875766
|
data/active_shipping.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency("quantified", "~> 1.0.1")
|
22
22
|
s.add_dependency("activesupport", ">= 3.2", "< 5.1.0")
|
23
23
|
s.add_dependency("active_utils", "~> 3.2.0")
|
24
|
-
s.add_dependency("nokogiri", "
|
24
|
+
s.add_dependency("nokogiri", "= 1.6.8")
|
25
25
|
|
26
26
|
s.add_development_dependency("minitest")
|
27
27
|
s.add_development_dependency("rake")
|
data/lib/active_shipping.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module ActiveShipping
|
2
|
+
|
3
|
+
# Response object class for calls to {ActiveShipping::Carrier#validate_address}.
|
4
|
+
#
|
5
|
+
# @!attribute location
|
6
|
+
# The Location to be validated
|
7
|
+
# @return [String]
|
8
|
+
class AddressValidationResponse < Response
|
9
|
+
attr_reader :validity, :classification, :candidate_addresses, :options, :params
|
10
|
+
|
11
|
+
def initialize(success, message, params = {}, options = {})
|
12
|
+
@validity = options[:validity]
|
13
|
+
@candidate_addresses = options[:candidate_addresses]
|
14
|
+
@classification = options[:classification]
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def address_match?
|
19
|
+
@validity == :valid
|
20
|
+
end
|
21
|
+
|
22
|
+
def residential?
|
23
|
+
@classification == :residential
|
24
|
+
end
|
25
|
+
|
26
|
+
def commercial?
|
27
|
+
@classification == :commercial
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -590,7 +590,12 @@ module ActiveShipping
|
|
590
590
|
message = response_message(xml)
|
591
591
|
|
592
592
|
if success
|
593
|
-
|
593
|
+
tracking_details_root = xml.at('CompletedTrackDetails')
|
594
|
+
success = response_success?(tracking_details_root)
|
595
|
+
message = response_message(tracking_details_root)
|
596
|
+
end
|
597
|
+
|
598
|
+
if success
|
594
599
|
delivery_signature = nil
|
595
600
|
shipment_events = []
|
596
601
|
|
@@ -599,13 +604,28 @@ module ActiveShipping
|
|
599
604
|
when 1
|
600
605
|
all_tracking_details.first
|
601
606
|
when 0
|
602
|
-
|
607
|
+
message = "The response did not contain tracking details"
|
608
|
+
return TrackingResponse.new(
|
609
|
+
false,
|
610
|
+
message,
|
611
|
+
Hash.from_xml(response),
|
612
|
+
carrier: @@name,
|
613
|
+
xml: response,
|
614
|
+
request: last_request
|
615
|
+
)
|
603
616
|
else
|
604
617
|
all_unique_identifiers = xml.root.xpath('CompletedTrackDetails/TrackDetails/TrackingNumberUniqueIdentifier').map(&:text)
|
605
|
-
|
618
|
+
message = "Multiple matches were found. Specify a unqiue identifier: #{all_unique_identifiers.join(', ')}"
|
619
|
+
return TrackingResponse.new(
|
620
|
+
false,
|
621
|
+
message,
|
622
|
+
Hash.from_xml(response),
|
623
|
+
carrier: @@name,
|
624
|
+
xml: response,
|
625
|
+
request: last_request
|
626
|
+
)
|
606
627
|
end
|
607
628
|
|
608
|
-
|
609
629
|
first_notification = tracking_details.at('Notification')
|
610
630
|
severity = first_notification.at('Severity').text
|
611
631
|
if severity == 'ERROR' || severity == 'FAILURE'
|
@@ -634,11 +654,11 @@ module ActiveShipping
|
|
634
654
|
end
|
635
655
|
end
|
636
656
|
|
637
|
-
if origin_node = tracking_details.at('OriginLocationAddress')
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
657
|
+
origin = if origin_node = tracking_details.at('OriginLocationAddress')
|
658
|
+
Location.new(
|
659
|
+
country: origin_node.at('CountryCode').text,
|
660
|
+
province: origin_node.at('StateOrProvinceCode').text,
|
661
|
+
city: origin_node.at('City').text
|
642
662
|
)
|
643
663
|
end
|
644
664
|
|
@@ -667,26 +687,29 @@ module ActiveShipping
|
|
667
687
|
|
668
688
|
shipment_events << ShipmentEvent.new(description, zoneless_time, location, description, type_code)
|
669
689
|
end
|
670
|
-
shipment_events = shipment_events.sort_by(&:time)
|
671
690
|
|
691
|
+
shipment_events = shipment_events.sort_by(&:time)
|
672
692
|
end
|
673
693
|
|
674
|
-
TrackingResponse.new(
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
694
|
+
TrackingResponse.new(
|
695
|
+
success,
|
696
|
+
message,
|
697
|
+
Hash.from_xml(response),
|
698
|
+
carrier: @@name,
|
699
|
+
xml: response,
|
700
|
+
request: last_request,
|
701
|
+
status: status,
|
702
|
+
status_code: status_code,
|
703
|
+
status_description: status_description,
|
704
|
+
ship_time: ship_time,
|
705
|
+
scheduled_delivery_date: scheduled_delivery_time,
|
706
|
+
actual_delivery_date: actual_delivery_time,
|
707
|
+
delivery_signature: delivery_signature,
|
708
|
+
shipment_events: shipment_events,
|
709
|
+
shipper_address: (shipper_address.nil? || shipper_address.unknown?) ? nil : shipper_address,
|
710
|
+
origin: origin,
|
711
|
+
destination: destination,
|
712
|
+
tracking_number: tracking_number
|
690
713
|
)
|
691
714
|
end
|
692
715
|
|
@@ -701,13 +724,13 @@ module ActiveShipping
|
|
701
724
|
end
|
702
725
|
|
703
726
|
def response_success?(document)
|
704
|
-
highest_severity = document.
|
727
|
+
highest_severity = document.at('HighestSeverity')
|
705
728
|
return false if highest_severity.nil?
|
706
729
|
%w(SUCCESS WARNING NOTE).include?(highest_severity.text)
|
707
730
|
end
|
708
731
|
|
709
732
|
def response_message(document)
|
710
|
-
notifications = document.
|
733
|
+
notifications = document.at('Notifications')
|
711
734
|
return "" if notifications.nil?
|
712
735
|
|
713
736
|
"#{notifications.at('Severity').text} - #{notifications.at('Code').text}: #{notifications.at('Message').text}"
|
@@ -18,7 +18,8 @@ module ActiveShipping
|
|
18
18
|
:ship_confirm => 'ups.app/xml/ShipConfirm',
|
19
19
|
:ship_accept => 'ups.app/xml/ShipAccept',
|
20
20
|
:delivery_dates => 'ups.app/xml/TimeInTransit',
|
21
|
-
:void => 'ups.app/xml/Void'
|
21
|
+
:void => 'ups.app/xml/Void',
|
22
|
+
:validate_address => 'ups.app/xml/XAV'
|
22
23
|
}
|
23
24
|
|
24
25
|
PICKUP_CODES = HashWithIndifferentAccess.new(
|
@@ -232,6 +233,21 @@ module ActiveShipping
|
|
232
233
|
35
|
233
234
|
end
|
234
235
|
|
236
|
+
# Validates a location with the Street Level Validation service
|
237
|
+
#
|
238
|
+
# @param location [Location] The Location to validate
|
239
|
+
# @return [ActiveShipping::AddressValidationResponse] The response from the validation endpoint. This
|
240
|
+
# response will determine if the given address is valid or not, its commercial/residential classification,
|
241
|
+
# and the cleaned-up address and/or potential candidate addresses if the passed location can't be found
|
242
|
+
def validate_address(location, options = {})
|
243
|
+
location = upsified_location(location)
|
244
|
+
options = @options.merge(options)
|
245
|
+
access_request = build_access_request
|
246
|
+
address_validation_request = build_address_validation_request(location, options)
|
247
|
+
response = commit(:validate_address, save_request(access_request + address_validation_request), options[:test])
|
248
|
+
parse_address_validation_response(location, response, options)
|
249
|
+
end
|
250
|
+
|
235
251
|
protected
|
236
252
|
|
237
253
|
def upsified_location(location)
|
@@ -963,6 +979,97 @@ module ActiveShipping
|
|
963
979
|
end
|
964
980
|
end
|
965
981
|
|
982
|
+
def build_address_validation_request(location, options = {})
|
983
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
984
|
+
xml.AddressValidationRequest do
|
985
|
+
xml.Request do
|
986
|
+
xml.RequestAction('XAV')
|
987
|
+
xml.RequestOption('3')
|
988
|
+
|
989
|
+
if options[:customer_context]
|
990
|
+
xml.TransactionReference do
|
991
|
+
xml.CustomerContext(options[:customer_context])
|
992
|
+
xml.XpciVersion("1.0")
|
993
|
+
end
|
994
|
+
end
|
995
|
+
end
|
996
|
+
|
997
|
+
xml.AddressKeyFormat do
|
998
|
+
xml.AddressLine(location.address1)
|
999
|
+
if location.address2.present?
|
1000
|
+
xml.AddressLine(location.address2)
|
1001
|
+
end
|
1002
|
+
xml.PoliticalDivision2(location.city)
|
1003
|
+
xml.PoliticalDivision1(location.state)
|
1004
|
+
xml.PostcodePrimaryLow(location.postal_code)
|
1005
|
+
xml.CountryCode(location.country_code)
|
1006
|
+
end
|
1007
|
+
end
|
1008
|
+
end
|
1009
|
+
|
1010
|
+
xml_builder.to_xml
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
def parse_address_validation_response(address, response, options={})
|
1014
|
+
xml = build_document(response, 'AddressValidationResponse')
|
1015
|
+
success = response_success?(xml)
|
1016
|
+
message = response_message(xml)
|
1017
|
+
|
1018
|
+
validity = nil
|
1019
|
+
classification_code = nil
|
1020
|
+
classification_description = nil
|
1021
|
+
addresses = []
|
1022
|
+
|
1023
|
+
if success
|
1024
|
+
if xml.at('AddressClassification/Code').present?
|
1025
|
+
classification_code = xml.at('AddressClassification/Code').text
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
classification = case classification_code
|
1029
|
+
when "1"
|
1030
|
+
:commercial
|
1031
|
+
when "2"
|
1032
|
+
:residential
|
1033
|
+
else
|
1034
|
+
:unknown
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
validity = if xml.at("ValidAddressIndicator").present?
|
1038
|
+
:valid
|
1039
|
+
elsif xml.at("AmbiguousAddressIndicator").present?
|
1040
|
+
:ambiguous
|
1041
|
+
elsif xml.at("NoCandidatesIndicator").present?
|
1042
|
+
:invalid
|
1043
|
+
else
|
1044
|
+
:unknown
|
1045
|
+
end
|
1046
|
+
|
1047
|
+
addresses = xml.css('AddressKeyFormat').collect { |node| location_from_address_key_format_node(node) }
|
1048
|
+
end
|
1049
|
+
|
1050
|
+
params = Hash.from_xml(response).values.first
|
1051
|
+
response = AddressValidationResponse.new(success, message, params, :validity => validity, :classification => classification, :candidate_addresses => addresses, :xml => response, :request => last_request)
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
# Converts from a AddressKeyFormat XML node to a Location
|
1055
|
+
def location_from_address_key_format_node(address)
|
1056
|
+
return nil unless address
|
1057
|
+
country = address.at('CountryCode').try(:text)
|
1058
|
+
country = 'US' if country == 'ZZ' # Sometimes returned by SUREPOST in the US
|
1059
|
+
|
1060
|
+
address_lines = address.css('AddressLine')
|
1061
|
+
|
1062
|
+
Location.new(
|
1063
|
+
:country => country,
|
1064
|
+
:postal_code => address.at('PostcodePrimaryLow').try(:text),
|
1065
|
+
:province => address.at('PoliticalDivision1').try(:text),
|
1066
|
+
:city => address.at('PoliticalDivision2').try(:text),
|
1067
|
+
:address1 => address_lines[0].try(:text),
|
1068
|
+
:address2 => address_lines[1].try(:text),
|
1069
|
+
:address3 => address_lines[2].try(:text),
|
1070
|
+
)
|
1071
|
+
end
|
1072
|
+
|
966
1073
|
def location_from_address_node(address)
|
967
1074
|
return nil unless address
|
968
1075
|
country = address.at('CountryCode').try(:text)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<TrackReply xmlns="http://fedex.com/ws/track/v7" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<HighestSeverity>SUCCESS</HighestSeverity>
|
4
|
+
<Notifications>
|
5
|
+
<Severity>SUCCESS</Severity>
|
6
|
+
<Source>trck</Source>
|
7
|
+
<Code>0</Code>
|
8
|
+
<Message>Request was successfully processed.</Message>
|
9
|
+
<LocalizedMessage>Request was successfully processed.</LocalizedMessage>
|
10
|
+
</Notifications>
|
11
|
+
<TransactionDetail>
|
12
|
+
<CustomerTransactionId>ActiveShipping</CustomerTransactionId>
|
13
|
+
</TransactionDetail>
|
14
|
+
<Version>
|
15
|
+
<ServiceId>trck</ServiceId>
|
16
|
+
<Major>7</Major>
|
17
|
+
<Intermediate>0</Intermediate>
|
18
|
+
<Minor>0</Minor>
|
19
|
+
</Version>
|
20
|
+
<CompletedTrackDetails>
|
21
|
+
<HighestSeverity>FAILURE</HighestSeverity>
|
22
|
+
<Notifications>
|
23
|
+
<Severity>FAILURE</Severity>
|
24
|
+
<Source>trck</Source>
|
25
|
+
<Code>6330</Code>
|
26
|
+
<Message>Sorry, we are unable to process your tracking request. Please retry later, or contact Customer Service at 1.800.Go.FedEx(R) 800.463.3339.</Message>
|
27
|
+
<LocalizedMessage>Sorry, we are unable to process your tracking request. Please retry later, or contact Customer Service at 1.800.Go.FedEx(R) 800.463.3339.</LocalizedMessage>
|
28
|
+
</Notifications>
|
29
|
+
<DuplicateWaybill>false</DuplicateWaybill>
|
30
|
+
<MoreData>false</MoreData>
|
31
|
+
</CompletedTrackDetails>
|
32
|
+
</TrackReply>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<AddressValidationRequest>
|
3
|
+
<Request>
|
4
|
+
<RequestAction>XAV</RequestAction>
|
5
|
+
<RequestOption>3</RequestOption>
|
6
|
+
</Request>
|
7
|
+
<AddressKeyFormat>
|
8
|
+
<AddressLine>55 Glenlake Parkway NE</AddressLine>
|
9
|
+
<PoliticalDivision2>Atlanta</PoliticalDivision2>
|
10
|
+
<PoliticalDivision1>GA</PoliticalDivision1>
|
11
|
+
<PostcodePrimaryLow>30328</PostcodePrimaryLow>
|
12
|
+
<CountryCode>US</CountryCode>
|
13
|
+
</AddressKeyFormat>
|
14
|
+
</AddressValidationRequest>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<AddressValidationResponse>
|
2
|
+
<Response>
|
3
|
+
<TransactionReference />
|
4
|
+
<ResponseStatusCode>1</ResponseStatusCode>
|
5
|
+
<ResponseStatusDescription>Success</ResponseStatusDescription>
|
6
|
+
</Response>
|
7
|
+
<ValidAddressIndicator />
|
8
|
+
<AddressClassification>
|
9
|
+
<Code>1</Code>
|
10
|
+
<Description>Commercial</Description>
|
11
|
+
</AddressClassification>
|
12
|
+
<AddressKeyFormat>
|
13
|
+
<AddressClassification>
|
14
|
+
<Code>1</Code>
|
15
|
+
<Description>Commercial</Description>
|
16
|
+
</AddressClassification>
|
17
|
+
<AddressLine>55 GLENLAKE PKWY</AddressLine>
|
18
|
+
<Region>ATLANTA GA 30328-3474</Region>
|
19
|
+
<PoliticalDivision2>ATLANTA</PoliticalDivision2>
|
20
|
+
<PoliticalDivision1>GA</PoliticalDivision1>
|
21
|
+
<PostcodePrimaryLow>30328</PostcodePrimaryLow>
|
22
|
+
<PostcodeExtendedLow>3474</PostcodeExtendedLow>
|
23
|
+
<CountryCode>US</CountryCode>
|
24
|
+
</AddressKeyFormat>
|
25
|
+
</AddressValidationResponse>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<AddressValidationResponse>
|
2
|
+
<Response>
|
3
|
+
<TransactionReference />
|
4
|
+
<ResponseStatusCode>1</ResponseStatusCode>
|
5
|
+
<ResponseStatusDescription>Success</ResponseStatusDescription>
|
6
|
+
</Response>
|
7
|
+
<AmbiguousAddressIndicator />
|
8
|
+
<AddressClassification>
|
9
|
+
<Code>1</Code>
|
10
|
+
<Description>Commercial</Description>
|
11
|
+
</AddressClassification>
|
12
|
+
<AddressKeyFormat>
|
13
|
+
<AddressClassification>
|
14
|
+
<Code>1</Code>
|
15
|
+
<Description>Commercial</Description>
|
16
|
+
</AddressClassification>
|
17
|
+
<AddressLine>55 GLENLAKE PKWY</AddressLine>
|
18
|
+
<Region>ATLANTA GA 30328-3474</Region>
|
19
|
+
<PoliticalDivision2>ATLANTA</PoliticalDivision2>
|
20
|
+
<PoliticalDivision1>GA</PoliticalDivision1>
|
21
|
+
<PostcodePrimaryLow>30328</PostcodePrimaryLow>
|
22
|
+
<PostcodeExtendedLow>3474</PostcodeExtendedLow>
|
23
|
+
<CountryCode>US</CountryCode>
|
24
|
+
</AddressKeyFormat>
|
25
|
+
<AddressKeyFormat>
|
26
|
+
<AddressClassification>
|
27
|
+
<Code>2</Code>
|
28
|
+
<Description>Residential</Description>
|
29
|
+
</AddressClassification>
|
30
|
+
<AddressLine>555 GLENVALE</AddressLine>
|
31
|
+
<Region>ATLANTA GA 30328-3474</Region>
|
32
|
+
<PoliticalDivision2>ATLANTA</PoliticalDivision2>
|
33
|
+
<PoliticalDivision1>GA</PoliticalDivision1>
|
34
|
+
<PostcodePrimaryLow>30328</PostcodePrimaryLow>
|
35
|
+
<PostcodeExtendedLow>3474</PostcodeExtendedLow>
|
36
|
+
<CountryCode>US</CountryCode>
|
37
|
+
</AddressKeyFormat>
|
38
|
+
</AddressValidationResponse>
|
data/test/remote/fedex_test.rb
CHANGED
@@ -316,6 +316,8 @@ class RemoteFedExTest < Minitest::Test
|
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
319
|
+
### create_shipment
|
320
|
+
|
319
321
|
def test_cant_obtain_multiple_shipping_labels
|
320
322
|
assert_raises(ActiveShipping::Error,"Multiple packages are not supported yet.") do
|
321
323
|
@carrier.create_shipment(
|
@@ -318,15 +318,32 @@ class FedExTest < Minitest::Test
|
|
318
318
|
@carrier.expects(:commit).returns(mock_response)
|
319
319
|
|
320
320
|
assert_raises ActiveShipping::ResponseContentError do
|
321
|
-
|
321
|
+
@carrier.find_rates(
|
322
322
|
location_fixtures[:ottawa],
|
323
323
|
location_fixtures[:beverly_hills],
|
324
324
|
package_fixtures.values_at(:book, :wii),
|
325
|
-
:
|
325
|
+
test: true
|
326
326
|
)
|
327
327
|
end
|
328
328
|
end
|
329
329
|
|
330
|
+
def test_parsing_response_without_notifications
|
331
|
+
mock_response = xml_fixture('fedex/reply_without_notifications')
|
332
|
+
|
333
|
+
@carrier.expects(:commit).returns(mock_response)
|
334
|
+
|
335
|
+
response = @carrier.find_rates(
|
336
|
+
location_fixtures[:ottawa],
|
337
|
+
location_fixtures[:beverly_hills],
|
338
|
+
package_fixtures.values_at(:book, :wii),
|
339
|
+
test: true
|
340
|
+
)
|
341
|
+
|
342
|
+
assert_predicate response, :success?
|
343
|
+
end
|
344
|
+
|
345
|
+
### find_tracking_info
|
346
|
+
|
330
347
|
def test_response_transient_failure
|
331
348
|
mock_response = xml_fixture('fedex/tracking_response_failure_code_9045')
|
332
349
|
@carrier.expects(:commit).returns(mock_response)
|
@@ -339,7 +356,7 @@ class FedExTest < Minitest::Test
|
|
339
356
|
assert_equal msg, error.message
|
340
357
|
end
|
341
358
|
|
342
|
-
def
|
359
|
+
def test_response_with_failure_nested_in_track_details
|
343
360
|
mock_response = xml_fixture('fedex/tracking_response_failure_code_9080')
|
344
361
|
@carrier.expects(:commit).returns(mock_response)
|
345
362
|
|
@@ -351,23 +368,18 @@ class FedExTest < Minitest::Test
|
|
351
368
|
assert_equal msg, error.message
|
352
369
|
end
|
353
370
|
|
354
|
-
def
|
355
|
-
mock_response = xml_fixture('fedex/
|
356
|
-
|
371
|
+
def test_response_with_failure_nested_in_completed_track_details
|
372
|
+
mock_response = xml_fixture('fedex/tracking_response_unable_to_process')
|
357
373
|
@carrier.expects(:commit).returns(mock_response)
|
358
374
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
package_fixtures.values_at(:book, :wii),
|
363
|
-
:test => true
|
364
|
-
)
|
375
|
+
error = assert_raises(ActiveShipping::ResponseError) do
|
376
|
+
@carrier.find_tracking_info('123456789013')
|
377
|
+
end
|
365
378
|
|
366
|
-
|
379
|
+
msg = 'FAILURE - 6330: Sorry, we are unable to process your tracking request. Please retry later, or contact Customer Service at 1.800.Go.FedEx(R) 800.463.3339.'
|
380
|
+
assert_equal msg, error.message
|
367
381
|
end
|
368
382
|
|
369
|
-
### find_tracking_info
|
370
|
-
|
371
383
|
def test_tracking_info_for_delivered_with_signature
|
372
384
|
mock_response = xml_fixture('fedex/tracking_response_delivered_with_signature')
|
373
385
|
@carrier.expects(:commit).returns(mock_response)
|
@@ -507,7 +519,7 @@ class FedExTest < Minitest::Test
|
|
507
519
|
mock_response = xml_fixture('fedex/tracking_response_multiple_results')
|
508
520
|
@carrier.expects(:commit).returns(mock_response)
|
509
521
|
|
510
|
-
error = assert_raises(ActiveShipping::
|
522
|
+
error = assert_raises(ActiveShipping::ResponseError) do
|
511
523
|
@carrier.find_tracking_info('123456789012')
|
512
524
|
end
|
513
525
|
|
@@ -574,6 +586,8 @@ class FedExTest < Minitest::Test
|
|
574
586
|
assert_empty response.shipment_events
|
575
587
|
end
|
576
588
|
|
589
|
+
### create_shipment
|
590
|
+
|
577
591
|
def test_create_shipment
|
578
592
|
confirm_response = xml_fixture('fedex/create_shipment_response')
|
579
593
|
@carrier.stubs(:commit).returns(confirm_response)
|
@@ -628,4 +628,32 @@ class UPSTest < Minitest::Test
|
|
628
628
|
assert_equal 'OZS', request.search('/Package/PackageWeight/UnitOfMeasurement/Code').text
|
629
629
|
assert_equal '8.0', request.search('/Package/PackageWeight/Weight').text
|
630
630
|
end
|
631
|
+
|
632
|
+
def test_address_validation
|
633
|
+
location = Location.new(address1: "55 Glenlake Parkway", city: "Atlanta", state: "GA", zip: "30328", country: "US")
|
634
|
+
address_validation_response = xml_fixture('ups/address_validation_response')
|
635
|
+
@carrier.expects(:commit).returns(address_validation_response)
|
636
|
+
response = @carrier.validate_address(location)
|
637
|
+
assert_equal :commercial, response.classification
|
638
|
+
assert_equal true, response.address_match?
|
639
|
+
end
|
640
|
+
|
641
|
+
def test_address_validation_ambiguous
|
642
|
+
location = Location.new(address1: "55 Glen", city: "Atlanta", state: "GA", zip: "30328", country: "US")
|
643
|
+
address_validation_response = xml_fixture('ups/address_validation_response_ambiguous')
|
644
|
+
@carrier.expects(:commit).returns(address_validation_response)
|
645
|
+
response = @carrier.validate_address(location)
|
646
|
+
assert_equal false, response.address_match?
|
647
|
+
assert_equal :ambiguous, response.validity
|
648
|
+
end
|
649
|
+
|
650
|
+
def test_address_validation_no_candidates
|
651
|
+
location = Location.new(address1: "55 Glenblagahrhadd", city: "Atlanta", state: "GA", zip: "30321", country: "US")
|
652
|
+
address_validation_response = xml_fixture('ups/address_validation_response_no_candidates')
|
653
|
+
@carrier.expects(:commit).returns(address_validation_response)
|
654
|
+
response = @carrier.validate_address(location)
|
655
|
+
assert_equal false, response.address_match?
|
656
|
+
assert_equal :invalid, response.validity
|
657
|
+
end
|
658
|
+
|
631
659
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_shipping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: quantified
|
@@ -62,16 +62,16 @@ dependencies:
|
|
62
62
|
name: nokogiri
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - '='
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: 1.6.8
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - '='
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 1.6.8
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: minitest
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- gemfiles/activesupport50.gemfile
|
183
183
|
- gemfiles/activesupport_master.gemfile
|
184
184
|
- lib/active_shipping.rb
|
185
|
+
- lib/active_shipping/address_validation_response.rb
|
185
186
|
- lib/active_shipping/carrier.rb
|
186
187
|
- lib/active_shipping/carriers.rb
|
187
188
|
- lib/active_shipping/carriers/australia_post.rb
|
@@ -299,6 +300,7 @@ files:
|
|
299
300
|
- test/fixtures/xml/fedex/tracking_response_multiple_results.xml
|
300
301
|
- test/fixtures/xml/fedex/tracking_response_not_found.xml
|
301
302
|
- test/fixtures/xml/fedex/tracking_response_shipment_exception.xml
|
303
|
+
- test/fixtures/xml/fedex/tracking_response_unable_to_process.xml
|
302
304
|
- test/fixtures/xml/fedex/tracking_response_with_blank_state.xml
|
303
305
|
- test/fixtures/xml/fedex/unknown_fedex_document_reply.xml
|
304
306
|
- test/fixtures/xml/kunaki/invalid_state_response.xml
|
@@ -328,6 +330,10 @@ files:
|
|
328
330
|
- test/fixtures/xml/stamps/track_shipment_request.xml
|
329
331
|
- test/fixtures/xml/stamps/track_shipment_response.xml
|
330
332
|
- test/fixtures/xml/ups/access_request.xml
|
333
|
+
- test/fixtures/xml/ups/address_validation_request.xml
|
334
|
+
- test/fixtures/xml/ups/address_validation_response.xml
|
335
|
+
- test/fixtures/xml/ups/address_validation_response_ambiguous.xml
|
336
|
+
- test/fixtures/xml/ups/address_validation_response_no_candidates.xml
|
331
337
|
- test/fixtures/xml/ups/delivered_shipment_with_refund.xml
|
332
338
|
- test/fixtures/xml/ups/delivered_shipment_without_events_tracking_response.xml
|
333
339
|
- test/fixtures/xml/ups/delivery_dates_response.xml
|
@@ -525,6 +531,7 @@ test_files:
|
|
525
531
|
- test/fixtures/xml/fedex/tracking_response_multiple_results.xml
|
526
532
|
- test/fixtures/xml/fedex/tracking_response_not_found.xml
|
527
533
|
- test/fixtures/xml/fedex/tracking_response_shipment_exception.xml
|
534
|
+
- test/fixtures/xml/fedex/tracking_response_unable_to_process.xml
|
528
535
|
- test/fixtures/xml/fedex/tracking_response_with_blank_state.xml
|
529
536
|
- test/fixtures/xml/fedex/unknown_fedex_document_reply.xml
|
530
537
|
- test/fixtures/xml/kunaki/invalid_state_response.xml
|
@@ -554,6 +561,10 @@ test_files:
|
|
554
561
|
- test/fixtures/xml/stamps/track_shipment_request.xml
|
555
562
|
- test/fixtures/xml/stamps/track_shipment_response.xml
|
556
563
|
- test/fixtures/xml/ups/access_request.xml
|
564
|
+
- test/fixtures/xml/ups/address_validation_request.xml
|
565
|
+
- test/fixtures/xml/ups/address_validation_response.xml
|
566
|
+
- test/fixtures/xml/ups/address_validation_response_ambiguous.xml
|
567
|
+
- test/fixtures/xml/ups/address_validation_response_no_candidates.xml
|
557
568
|
- test/fixtures/xml/ups/delivered_shipment_with_refund.xml
|
558
569
|
- test/fixtures/xml/ups/delivered_shipment_without_events_tracking_response.xml
|
559
570
|
- test/fixtures/xml/ups/delivery_dates_response.xml
|