It's possible that the address validation service can return multiple suggestions. When this happens it results in the following error:
can't convert Symbol into Integer
/app/vendor/bundle/ruby/1.9.1/gems/fedex-3.0.0/lib/fedex/address.rb:9:in `[]'
/app/vendor/bundle/ruby/1.9.1/gems/fedex-3.0.0/lib/fedex/address.rb:9:in `initialize'
/app/vendor/bundle/ruby/1.9.1/gems/fedex-3.0.0/lib/fedex/request/address.rb:21:in `new'
/app/vendor/bundle/ruby/1.9.1/gems/fedex-3.0.0/lib/fedex/request/address.rb:21:in `process_request'
/app/vendor/bundle/ruby/1.9.1/gems/fedex-3.0.0/lib/fedex/shipment.rb:43:in `validate_address'
{
:address_validation_reply => {
:highest_severity => "SUCCESS",
:notifications => {
:severity => "SUCCESS",
:source => "wsi"
},
:version => {
:service_id => "aval",
:major => "2",
:intermediate => "0",
:minor => "0"
},
:reply_timestamp => "2013-07-17T22:32:44.372Z",
:address_results => {
:proposed_address_details => [
{
:score => "0",
:changes => ["MODIFIED_TO_ACHIEVE_MATCH", "APARTMENT_NUMBER_REQUIRED"],
:residential_status => "BUSINESS",
:delivery_point_validation => "CONFIRMED",
:address => {
:street_lines => "REDACTED",
:city => "REDACTED",
:state_or_province_code => "REDACTED",
:postal_code => "REDACTED",
:country_code => "REDACTED"
},
:removed_non_address_data => nil
},
{
:score => "0",
:changes => ["MODIFIED_TO_ACHIEVE_MATCH", "APARTMENT_NUMBER_REQUIRED"],
:residential_status => "UNDETERMINED",
:delivery_point_validation => "UNCONFIRMED",
:address => {
:street_lines => "REDACTED",
:city => "REDACTED",
:state_or_province_code => "REDACTED",
:postal_code => "REDACTED",
:country_code => "REDACTED"
},
:removed_non_address_data => nil
}
]
}
}
}
So you can see that it is an array of hashes instead of the singular hash it expects.
I had some trouble running the tests so I didn't feel comfortable trying a real solution yet so here's the quick hack I'm using temporarily (tested in our app's tests for now): stitchfix@785cd33 Obviously this isn't a real solution but it does keep it from breaking.
A real solution likely involves allowing it to handle multiple results rather than just taking the first one and would of course need tests, which I don't have the time today to solve for why they aren't running for me.
In particular this was a case of leaving off an "East" or "West" on the street name so I'm sure that's a common cause.