Class: Printful::OrdersResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/printful/resources/orders.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Printful::Resource

Instance Method Details

#cancel(id:) ⇒ Object



31
32
33
34
# File 'lib/printful/resources/orders.rb', line 31

def cancel(id:)
  response = delete_request("orders/#{id}")
  return true if response.success?
end

#confirm(id:) ⇒ Object



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

def confirm(id:)
  response = post_request("orders/#{id}/confirm", body: {})
  Order.new(response.body["result"])
end

#create(**params) ⇒ Object



15
16
17
18
19
# File 'lib/printful/resources/orders.rb', line 15

def create(**params)
  # attributes = {sync_product: product, sync_variants: variants}
  response = post_request("orders", body: params)
  Order.new(response.body["result"])
end

#estimate(**params) ⇒ Object



10
11
12
13
# File 'lib/printful/resources/orders.rb', line 10

def estimate(**params)
  response = post_request("orders/estimate-costs", body: params)
  Cost.new(response.body["result"])
end

#listObject



4
5
6
7
8
# File 'lib/printful/resources/orders.rb', line 4

def list
  response = get_request("orders")
  body = response.body["result"]
  Collection.from_response(body: body, type: Order)
end

#retrieve(id:) ⇒ Object



21
22
23
24
# File 'lib/printful/resources/orders.rb', line 21

def retrieve(id:)
  response = get_request("orders/#{id}")
  Order.new(response.body["result"])
end

#update(id:, **params) ⇒ Object



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

def update(id:, **params)
  response = put_request("orders/#{id}", body: params)
  return true if response.success?
end