Class: Button::Orders

Inherits:
Resource show all
Defined in:
lib/button/resources/orders.rb

Overview

Constant Summary

Constants inherited from Resource

Resource::USER_AGENT

Instance Attribute Summary

Attributes inherited from Resource

#config

Instance Method Summary collapse

Methods inherited from Resource

#api_delete, #api_get, #api_post, #initialize, #timeout

Constructor Details

This class inherits a constructor from Button::Resource

Instance Method Details

#create(order) ⇒ Button::Response

Creates an order

Parameters:

  • order (Hash)

    the order to create

Returns:



26
27
28
# File 'lib/button/resources/orders.rb', line 26

def create(order)
  api_post(path, order)
end

#delete(order_id) ⇒ Button::Response

Deletes an order

Parameters:

  • order_id (String)

    the order id

Returns:



45
46
47
# File 'lib/button/resources/orders.rb', line 45

def delete(order_id)
  api_delete(path(order_id))
end

#get(order_id) ⇒ Button::Response

Gets an order

Parameters:

  • order_id (String)

    the order id

Returns:



17
18
19
# File 'lib/button/resources/orders.rb', line 17

def get(order_id)
  api_get(path(order_id))
end

#path(order_id = nil) ⇒ Object



7
8
9
10
# File 'lib/button/resources/orders.rb', line 7

def path(order_id = nil)
  return "/v1/order/#{order_id}" if order_id
  '/v1/order'
end

#update(order_id, order) ⇒ Button::Response

Updates an order

Parameters:

  • order_id (String)

    the order id

  • order (Hash)

    the order to create

Returns:



36
37
38
# File 'lib/button/resources/orders.rb', line 36

def update(order_id, order)
  api_post(path(order_id), order)
end