Sha256: 48b3bfa4e13b1016dfcb351796a7b63066a6b0907a92762ae82c5a6966bfbe48

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

# The Pickup object allows you to schedule a pickup from your carrier from your customer's residence or place of business.
class EasyPost::Pickup < EasyPost::Resource
  # Buy a Pickup.
  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 a Pickup.
  def cancel(params = {})
    response = EasyPost.make_request(:post, "#{url}/cancel", @api_key, params)
    refresh_from(response, @api_key)

    self
  end

  # Retrieve a list of all Pickup objects.
  def self.all
    raise NotImplementedError.new('Pickup.all not implemented.')
  end

  # Get the lowest rate of a Pickup (can exclude by having `'!'` as the first element of your optional filter lists).
  def lowest_rate(carriers = [], services = [])
    EasyPost::Util.get_lowest_object_rate(self, carriers, services, 'pickup_rates')
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
easypost-4.7.0 lib/easypost/pickup.rb
easypost-4.6.0 lib/easypost/pickup.rb
easypost-4.5.0 lib/easypost/pickup.rb
easypost-4.4.0 lib/easypost/pickup.rb
easypost-4.3.0 lib/easypost/pickup.rb
easypost-4.2.1 lib/easypost/pickup.rb
easypost-4.2.0 lib/easypost/pickup.rb