Class: EasyPost::Order

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

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, #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

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/easypost/order.rb', line 24

def self.all(filters={}, api_key=nil)
  raise NotImplementedError.new('Order.all not implemented.')
end

Instance Method Details

#buy(params = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/easypost/order.rb', line 10

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

  response = EasyPost.make_request(:post, url + '/buy', @api_key, params)
  self.refresh_from(response, @api_key, true)

  return self
end

#get_rates(params = {}) ⇒ Object



3
4
5
6
7
8
# File 'lib/easypost/order.rb', line 3

def get_rates(params={})
  response = EasyPost.make_request(:get, url + '/rates', @api_key, params)
  self.refresh_from(response, @api_key, true)

  return self
end