lib/easypost/address.rb in easypost-1.1.3 vs lib/easypost/address.rb in easypost-2.0.0
- old
+ new
@@ -1,14 +1,21 @@
module EasyPost
- class Address
- @@type = "address"
+ class Address < Resource
- def self.test
- puts EasyPost.api_url("verify")
- end
+ def verify(params={})
+ response, api_key = EasyPost.request(:get, url + '/verify', @api_key, params)
- def self.verify(address={})
- @verified_address = EasyPost.get(EasyPost.api_url(:type => @@type, :action => "verify"), :address => address)
+ if response.has_key?(:address)
+ if response.has_key?(:message)
+ response[:address][:message] = response[:message]
+ end
+ verified_address = EasyPost::Util::convert_to_easypost_object(response[:address], api_key)
+ return verified_address
+ else
+ raise Error.new("Unable to verify address.")
+ end
+
+ return self
end
end
end