rate method returns empty array for invalid address - no errors.

42 views
Skip to first unread message

Alan

unread,
Oct 3, 2009, 5:36:26 PM10/3/09
to Shippinglogic
If you pass in an invalid address, such as a zip and state not
matching, an empty array is returned, no errors are raised.. Having
worked with FedEx web services before, I know the service can return
errors for less obvious issues, so the lack of error message coming
through is problematic.

Ben Johnson

unread,
Oct 3, 2009, 7:30:30 PM10/3/09
to shippi...@googlegroups.com
Ho Alan,

That task is delegated to FedEx. FedEx should return errors, I have
seen these. Shippinglogic itself doesn't do this because FedEx already
does.

Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

Alan

unread,
Oct 4, 2009, 4:02:20 PM10/4/09
to Shippinglogic
Hi Ben, I'll dig further, but using the latest, an empty array is
returned, and errors/exceptions are not raised and there doesn't seem
to be a way to access the error using the API. I tried calling .errors
and .valid? before and after making the rate request and they weren't
populated. I have gotten Shippinglogic::FedEx::Error's raised for
missing input, but nothing for the scenario above.

I have seen the errors returned by FedEx for the scenario I've given
(using a different FedEx lib) so I'm assuming this is a different
error type that ShippingLogic is not inspecting. I'll try to post back
after I have a chance to dig into it a bit more.

Alan

unread,
Oct 6, 2009, 4:41:02 PM10/6/09
to Shippinglogic
Ok, I dug a little deeper and found some interesting findings. Btw, I
appreciate you taking up this library, I'm sure it will end up being
the defacto rails shipping gem once the kinks get worked out.

1. If a service type is specified, the code breaks.
2. If a service type is specified with reworked code, some address
validation errors are thrown(which is I why I was initially confused
as to why it wasn't happening). This doesn't happen if specific
service type is not provided.
3. Because of FedEx's limitations(#2), I'm going to locally tack on
address validation to shippinglogic. If I find that Address Validation
is either too much or otherwise not usable, I might make two calls to
FedEx, the first "fake" request to generate errors, and assuming there
are none, the second request being the standard request(ewww!)


1. Service Type Breaks code.
Unfortunately, the current code breaks if you specify a service type
(:service_type=>"FEDEX_GROUND"). The parse code assumes
rate_reply_details to be an array. If a service type is specified, it
actually returns a hash. Quick and dirty fix is below, where
get_rate_info calls your current parsing code.

if (response[:rate_reply_details].is_a?(Array))
response[:rate_reply_details].collect do |details|
get_rate_info(details)
end
else
return [].push(get_rate_info(response[:rate_reply_details]))
end
end


2. Specifying a service type gets FedEx to return simple address
validation errors, Example:
{:highest_severity=>"ERROR", :notifications=>
{:code=>"836", :source=>"crs", :message=>"Destination Postal-State
Mismatch.", :localized_message=>"Destination Postal-State
Mismatch.", :severity=>"ERROR"}, :"xmlns:xsi"=>"http://www.w3.org/2001/
XMLSchema-instance", :version=>
{:minor=>"0", :service_id=>"crs", :intermediate=>"0", :major=>"6"}, :"xmlns:v6"=>"http://
fedex.com/ws/rate/v6"}

3. If you have any interest in adding address validation to shipping
logic, I can get shoot you over some code, if anything it will
probably help you save some keystrokes.
Reply all
Reply to author
Forward
0 new messages