Class: Nuvemshop::Orders

Inherits:
Request show all
Includes:
Extensions::Credentiable
Defined in:
lib/nuvemshop/orders.rb

Constant Summary collapse

PATH =
'orders'.freeze

Constants inherited from Request

Request::BASE_URL

Instance Attribute Summary

Attributes inherited from Request

#access_token, #options, #response, #user_id

Class Method Summary collapse

Methods included from Extensions::Credentiable

#initialize

Methods inherited from Request

#delete, #get, #initialize, #post, #put, respond_with

Class Method Details

.all(opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/nuvemshop/orders.rb', line 7

def self.all(opts = {})
  response = new(
    access_token: opts[:access_token],
    user_id: opts[:user_id]
  ).get(
    action: PATH,
    query: {
      since_id: opts[:since_id],
      status: opts[:status],
      channels: opts[:channels],
      payment_status: opts[:payment_status],
      shipping_status: opts[:shipping_status],
      created_at_min: opts[:created_at_min],
      created_at_max: opts[:created_at_max],
      updated_at_min: opts[:updated_at_min],
      updated_at_max: opts[:updated_at_max],
      total_min: opts[:total_min],
      total_max: opts[:total_max],
      customer_ids: opts[:customer_ids],
      page: opts[:page],
      per_page: opts[:per_page],
      fields: opts[:fields],
      q: opts[:q],
      app_id: opts[:app_id]
    }
  )

  respond_with(response, Nuvemshop::Order)
end

.show(opts = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/nuvemshop/orders.rb', line 37

def self.show(opts = {})
  response = new(
    access_token: opts[:access_token],
    user_id: opts[:user_id]
  ).get(
    action: "#{PATH}/#{opts[:order_id]}",
    query: {
      fields: opts[:fields]
    }
  )

  respond_with(response, Nuvemshop::Order)
end