Class: EasyPost::Services::Address
- Defined in:
- lib/easypost/services/address.rb
Constant Summary collapse
Instance Method Summary collapse
-
#all(filters = {}) ⇒ Object
Retrieve all Addresses.
-
#create(params = {}) ⇒ Object
Create an address.
-
#create_and_verify(params = {}) ⇒ Object
Create and verify an Address in one call.
-
#get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of addresses.
-
#retrieve(id) ⇒ Object
Retrieve an Address.
-
#verify(id) ⇒ Object
Verify an Address.
Methods inherited from Service
Constructor Details
This class inherits a constructor from EasyPost::Services::Service
Instance Method Details
#all(filters = {}) ⇒ Object
Retrieve all Addresses.
42 43 44 |
# File 'lib/easypost/services/address.rb', line 42 def all(filters = {}) @client.make_request(:get, 'addresses', MODEL_CLASS, filters) end |
#create(params = {}) ⇒ Object
Create an address.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/easypost/services/address.rb', line 7 def create(params = {}) address = params.reject { |k, _| [:verify, :verify_strict].include?(k) } wrapped_params = { address: address } if params[:verify] wrapped_params[:verify] = params[:verify] end if params[:verify_strict] wrapped_params[:verify_strict] = params[:verify_strict] end @client.make_request(:post, 'addresses', MODEL_CLASS, params) end |
#create_and_verify(params = {}) ⇒ Object
Create and verify an Address in one call.
24 25 26 27 28 29 |
# File 'lib/easypost/services/address.rb', line 24 def create_and_verify(params = {}) wrapped_params = {} wrapped_params[:address] = params @client.make_request(:post, 'addresses/create_and_verify', MODEL_CLASS, wrapped_params).address end |
#get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of addresses.
47 48 49 |
# File 'lib/easypost/services/address.rb', line 47 def get_next_page(collection, page_size = nil) get_next_page_helper(collection, collection.addresses, 'addresses', MODEL_CLASS, page_size) end |
#retrieve(id) ⇒ Object
Retrieve an Address.
37 38 39 |
# File 'lib/easypost/services/address.rb', line 37 def retrieve(id) @client.make_request(:get, "addresses/#{id}", MODEL_CLASS) end |
#verify(id) ⇒ Object
Verify an Address.
32 33 34 |
# File 'lib/easypost/services/address.rb', line 32 def verify(id) @client.make_request(:get, "addresses/#{id}/verify", MODEL_CLASS).address end |