Class: EasyPost::Address
- Inherits:
-
Resource
- Object
- EasyPostObject
- Resource
- EasyPost::Address
- Defined in:
- lib/easypost/address.rb
Instance Attribute Summary
Attributes inherited from EasyPostObject
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Resource
all, class_name, create, #delete, #refresh, retrieve, #save, url, #url
Methods inherited from EasyPostObject
#[], #[]=, #as_json, construct_from, #each, #id, #id=, #initialize, #inspect, #keys, #refresh_from, #to_hash, #to_json, #to_s, #values
Constructor Details
This class inherits a constructor from EasyPost::EasyPostObject
Class Method Details
.create_and_verify(params = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/easypost/address.rb', line 4 def self.create_and_verify(params={}) wrapped_params = {} wrapped_params[self.class_name().to_sym] = params response, api_key = EasyPost.request(:post, url + '/create_and_verify', @api_key, wrapped_params) 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 end |
Instance Method Details
#verify(params = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/easypost/address.rb', line 20 def verify(params={}) response, api_key = EasyPost.request(:get, url + '/verify', @api_key, params) 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 |