Class: Voucherify::Service::Orders

Inherits:
Object
  • Object
show all
Defined in:
lib/voucherify/service/orders.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Orders

Returns a new instance of Orders.



8
9
10
# File 'lib/voucherify/service/orders.rb', line 8

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/voucherify/service/orders.rb', line 6

def client
  @client
end

Instance Method Details

#create(order) ⇒ Object



12
13
14
# File 'lib/voucherify/service/orders.rb', line 12

def create(order)
  @client.post('/orders', order.to_json)
end

#get(order_id) ⇒ Object



16
17
18
# File 'lib/voucherify/service/orders.rb', line 16

def get(order_id)
  @client.get("/orders/#{ERB::Util.url_encode(order_id)}")
end

#list(query = {}) ⇒ Object



24
25
26
# File 'lib/voucherify/service/orders.rb', line 24

def list(query = {})
  @client.get("/orders", query)
end

#update(order_id, order) ⇒ Object



20
21
22
# File 'lib/voucherify/service/orders.rb', line 20

def update(order_id, order)
  @client.put("/orders/#{ERB::Util.url_encode(order_id)}", order.to_json)
end