Module: Usps::Api::Endpoints::Verify

Included in:
Usps::Api::Endpoints
Defined in:
lib/usps/api/endpoints/verify.rb

Instance Method Summary collapse

Instance Method Details

#verify(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • address_validate_request (required, Hash)

    API = AddressValidateRequest

    • :revision (required, String) — Integer value used to return of all available response fields. Set this value to 1 to return all currently documented response fields. Example: Revision>1</Revision>

    • :address (required, Hash) — Up to 5 address verifications can be included per transaction.

      • :firm_name (String) — Firm Name Example:<FirmName>XYZ Corp.</FirmName>

      • :address1 (String) — Delivery Address in the destination address. May contain secondary unit designator, such as APT or SUITE, for Accountable mail.)

      • :address2 (required, String) — Delivery Address in the destination address. Required for all mail and packages, however 11-digit Destination Delivery Point ZIP+4 Code can be provided as an alternative in the Detail 1 Record.

      • :city (String) — City name of the destination address.

      • :state (String) — Two-character state code of the destination address.

      • :urbanization (String) — Urbanization. For Puerto Rico addresses only.

      • :zip5 (String) — Destination 5-digit ZIP Code. Numeric values (0-9) only. If International, all zeroes.

      • :zip4 (String) — Destination ZIP+4 Numeric values (0-9) only. If International, all zeroes. Default to spaces if not available.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/usps/api/endpoints/verify.rb', line 21

def verify(options = {})
	throw ArgumentError.new('Required arguments :address_validate_request missing') if options[:address_validate_request].nil?
	throw ArgumentError.new('Required arguments :address_validate_request, :revision missing') if options[:address_validate_request][:revision].nil?
	throw ArgumentError.new('Required arguments :address_validate_request, :address missing') if options[:address_validate_request][:address].nil?
	throw ArgumentError.new('Required arguments :address_validate_request, :address, :address2 missing') if options[:address_validate_request][:address][:address2].nil?

	request = build_request(:verify, options)
	get('https://secure.shippingapis.com/ShippingAPI.dll', {
		API: 'Verify',
		XML: request,
	})
end