Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

USPS address validation #150

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants
Contributor

smartacus commented Feb 19, 2014

Here's a fairly basic implementation of USPS address validation. I have most of the code for FedEx validation as well, but I need to clean it up a bit before submitting a pull request.

Contributor

csaunders commented Mar 13, 2014

Looks like some merged PRs make this unmergable. Would you mind rebasing off master?

iurifq commented Mar 13, 2014

👍 for the rebase

Contributor

csaunders commented Apr 14, 2014

@smartacus would you be able to do a rebase?

Contributor

smartacus commented Apr 17, 2014

Okay, I just rebased off of master. I apologize for taking such a long time to get it done.

@garethson garethson commented on the diff Jul 17, 2014

lib/active_shipping/shipping/carriers/usps.rb
@@ -239,14 +251,22 @@ def world_rates(origin, destination, packages, options={})
parse_rate_response origin, destination, packages, commit(:world_rates,request,false), options
end
- # Once the address verification API is implemented, remove this and have valid_credentials? build the request using that instead.
- def canned_address_verification_works?
- return false unless @options[:login]
- request = "%3CCarrierPickupAvailabilityRequest%20USERID=%22#{URI.encode(@options[:login])}%22%3E%20%0A%3CFirmName%3EABC%20Corp.%3C/FirmName%3E%20%0A%3CSuiteOrApt%3ESuite%20777%3C/SuiteOrApt%3E%20%0A%3CAddress2%3E1390%20Market%20Street%3C/Address2%3E%20%0A%3CUrbanization%3E%3C/Urbanization%3E%20%0A%3CCity%3EHouston%3C/City%3E%20%0A%3CState%3ETX%3C/State%3E%20%0A%3CZIP5%3E77058%3C/ZIP5%3E%20%0A%3CZIP4%3E1234%3C/ZIP4%3E%20%0A%3C/CarrierPickupAvailabilityRequest%3E%0A"
- # expected_hash = {"CarrierPickupAvailabilityResponse"=>{"City"=>"HOUSTON", "Address2"=>"1390 Market Street", "FirmName"=>"ABC Corp.", "State"=>"TX", "Date"=>"3/1/2004", "DayOfWeek"=>"Monday", "Urbanization"=>nil, "ZIP4"=>"1234", "ZIP5"=>"77058", "CarrierRoute"=>"C", "SuiteOrApt"=>"Suite 777"}}
- xml = REXML::Document.new(commit(:test, request, true))
- xml.get_text('/CarrierPickupAvailabilityResponse/City').to_s == 'HOUSTON' &&
- xml.get_text('/CarrierPickupAvailabilityResponse/Address2').to_s == '1390 Market Street'
+ def build_address_validation_request(address, options={})
+ address_lines = address.to_hash.values_at(:address1, :address2, :address3).compact
@garethson

garethson Jul 17, 2014

Contributor

Believe address3 would never make it into the request if 1 and 2 are filled out.

Owner

wvanbergen commented Jan 30, 2015

Sorry, but this needs rebasing again. The USPS carrier implementation was rewritten to use Nokogiri instead of REXML / XmlNode

@kmcphillips kmcphillips closed this Nov 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment