class EasyPost::Services::Pickup
Constants
- MODEL_CLASS
The
Pickup
object allows you to schedule a pickup from your carrier from your customer’s residence or place of business.
Public Instance Methods
all(params = {})
click to toggle source
Retrieve all Pickup
objects
# File lib/easypost/services/pickup.rb, line 22 def all(params = {}) filters = { key: 'pickups' } get_all_helper('pickups', MODEL_CLASS, params, filters) end
buy(id, params = {})
click to toggle source
Buy a Pickup
# File lib/easypost/services/pickup.rb, line 29 def buy(id, params = {}) if params.instance_of?(EasyPost::Models::PickupRate) params = { carrier: params[:carrier], service: params[:service] } end response = @client.make_request(:post, "pickups/#{id}/buy", params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
cancel(id, params = {})
click to toggle source
Cancel a Pickup
# File lib/easypost/services/pickup.rb, line 40 def cancel(id, params = {}) response = @client.make_request(:post, "pickups/#{id}/cancel", params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
create(params = {})
click to toggle source
Create a Pickup
object
# File lib/easypost/services/pickup.rb, line 7 def create(params = {}) wrapped_params = { pickup: params } response = @client.make_request(:post, 'pickups', wrapped_params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
get_next_page(collection, page_size = nil)
click to toggle source
Get next page of Pickups
# File lib/easypost/services/pickup.rb, line 47 def get_next_page(collection, page_size = nil) raise EasyPost::Errors::EndOfPaginationError.new unless more_pages?(collection) params = { before_id: collection.pickups.last.id } params[:page_size] = page_size unless page_size.nil? all(params) end
retrieve(id)
click to toggle source
Retrieve a Pickup
object
# File lib/easypost/services/pickup.rb, line 15 def retrieve(id) response = @client.make_request(:get, "pickups/#{id}") EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end