Class: TaxCloud::Address
Overview
An Address
defines an address in the United States.
Instance Attribute Summary collapse
-
#address1 ⇒ Object
First line of address.
-
#address2 ⇒ Object
Second line of adress.
-
#city ⇒ Object
City.
-
#state ⇒ Object
State.
-
#zip4 ⇒ Object
4-digit Zip Code.
-
#zip5 ⇒ Object
5-digit Zip Code.
Instance Method Summary collapse
-
#to_hash ⇒ Object
Convert the object to a usable hash for SOAP requests.
-
#verify ⇒ Object
Verify this address.
-
#zip ⇒ Object
Complete zip code.
Methods inherited from Record
Constructor Details
This class inherits a constructor from TaxCloud::Record
Instance Attribute Details
#address1 ⇒ Object
First line of address.
5 6 7 |
# File 'lib/tax_cloud/address.rb', line 5 def address1 @address1 end |
#address2 ⇒ Object
Second line of adress.
7 8 9 |
# File 'lib/tax_cloud/address.rb', line 7 def address2 @address2 end |
#city ⇒ Object
City.
9 10 11 |
# File 'lib/tax_cloud/address.rb', line 9 def city @city end |
#state ⇒ Object
State.
11 12 13 |
# File 'lib/tax_cloud/address.rb', line 11 def state @state end |
#zip4 ⇒ Object
4-digit Zip Code.
15 16 17 |
# File 'lib/tax_cloud/address.rb', line 15 def zip4 @zip4 end |
#zip5 ⇒ Object
5-digit Zip Code.
13 14 15 |
# File 'lib/tax_cloud/address.rb', line 13 def zip5 @zip5 end |
Instance Method Details
#to_hash ⇒ Object
Convert the object to a usable hash for SOAP requests
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tax_cloud/address.rb', line 37 def to_hash { 'Address1' => address1, 'Address2' => address2, 'City' => city, 'State' => state, 'Zip5' => zip5, 'Zip4' => zip4 } end |
#verify ⇒ Object
Verify this address.
Returns a verified TaxCloud::Address.
20 21 22 23 24 25 26 27 |
# File 'lib/tax_cloud/address.rb', line 20 def verify params = to_hash.downcase_keys params = params.merge( 'uspsUserID' => TaxCloud.configuration.usps_username ) if TaxCloud.configuration.usps_username response = TaxCloud.client.request(:verify_address, params) TaxCloud::Responses::VerifyAddress.parse(response) end |
#zip ⇒ Object
Complete zip code. Returns a 9-digit Zip Code, when available.
31 32 33 34 |
# File 'lib/tax_cloud/address.rb', line 31 def zip return nil unless zip5 && zip5.length > 0 [zip5, zip4].select { |z| z && z.length > 0 }.join('-') end |