Class: PBShipping::Address

Inherits:
ShippingApiResource show all
Defined in:
lib/pbshipping/address.rb

Instance Method Summary collapse

Methods inherited from ApiObject

#[], #[]=, #add_accessors, #as_json, convert_to_api_object, #create_accessor, #each, #initialize, #inspect, #key?, #keys, #metaclass, #respond_to?, #to_hash, #to_json, #to_s, #update, #values

Constructor Details

This class inherits a constructor from PBShipping::ApiObject

Instance Method Details

#verify(auth_obj, minimalAddressValidation = nil, overwrite = true) ⇒ Object

ADDRESS VALIDATION API: POST /addresses/verify API signature: post/addresses/verify

Verify and cleanse any postal address within the United States. This will ensure that packages are rated accurately and the shipments arrive at their final destination on time.

By default, the returned result would overwrite the current state of the object. To avoid overwriting, set the input argument overwrite to False and a copy of the result would be generated and returned instead



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pbshipping/address.rb', line 36

def verify(auth_obj, minimalAddressValidation=nil, overwrite=true)
  if minimalAddressValidation == nil
    hdrs = {"minimalAddressValidation" => false}
  else
    hdrs = {"minimalAddressValidation" => minimalAddressValidation}
  end
  api_sig = "post/address/verify"
  api_version = PBShipping::get_api_version(api_sig)
  api_path = "/addresses/verify"
  json_resp = PBShipping::api_request(
    auth_obj, :post, api_version, api_path, hdrs, {}, self)
  if overwrite == true 
    self.update(json_resp)
    self
  else  
    Address.new(json_resp)
  end  
end