Sha256: aa5fa854f99f74b6f112432114f8fc41dab49c79bc979ad4b687b5fd9bb8506c

Contents?: true

Size: 860 Bytes

Versions: 4

Compression:

Stored size: 860 Bytes

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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
easypost-4.1.2 lib/easypost/pickup.rb
easypost-4.1.1 lib/easypost/pickup.rb
easypost-4.1.0 lib/easypost/pickup.rb
easypost-4.0.0 lib/easypost/pickup.rb