Class: EasyPost::Pickup

Inherits:
Resource show all
Defined in:
lib/easypost/pickup.rb

Overview

The Pickup object allows you to schedule a pickup from your carrier from your customer’s residence or place of business.

Instance Attribute Summary

Attributes inherited from EasyPostObject

#api_key, #name, #parent, #unsaved_values

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

class_name, create, #delete, each, #refresh, retrieve, #save, url, #url

Methods inherited from EasyPostObject

#[], #[]=, #as_json, construct_from, #deconstruct_keys, #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

.all(_filters = {}, _api_key = nil) ⇒ Object

Retrieve a list of all Pickup objects.

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/easypost/pickup.rb', line 29

def self.all(_filters = {}, _api_key = nil)
  raise NotImplementedError.new('Pickup.all not implemented.')
end

Instance Method Details

#buy(params = {}) ⇒ Object

Buy a Pickup.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/easypost/pickup.rb', line 6

def buy(params = {})
  if params.instance_of?(EasyPost::PickupRate)
    temp = params.clone
    params = {}
    params[:carrier] = temp.carrier
    params[:service] = temp.service
  end

  response = EasyPost.make_request(:post, "#{url}/buy", @api_key, params)
  refresh_from(response, @api_key)

  self
end

#cancel(params = {}) ⇒ Object

Cancel a Pickup.



21
22
23
24
25
26
# File 'lib/easypost/pickup.rb', line 21

def cancel(params = {})
  response = EasyPost.make_request(:post, "#{url}/cancel", @api_key, params)
  refresh_from(response, @api_key)

  self
end

#lowest_rate(carriers = [], services = []) ⇒ Object

Get the lowest rate of a Pickup (can exclude by having ‘’!‘` as the first element of your optional filter lists).



34
35
36
# File 'lib/easypost/pickup.rb', line 34

def lowest_rate(carriers = [], services = [])
  EasyPost::Util.get_lowest_object_rate(self, carriers, services, 'pickup_rates')
end