Class: Varejonline::API::Orders

Inherits:
Client
  • Object
show all
Defined in:
lib/varejonline/api/orders.rb

Instance Attribute Summary

Attributes inherited from Client

#access_token

Instance Method Summary collapse

Methods inherited from Client

#category_levels, #client_classes, #companies, #credit_limits, #default_entries, #entities, #initialize, #installments, #orders, #payment_conditions, #product_categories, #products, #provisions, #receipts, #sales_history, #sellers, #third_parties, #user_data

Methods included from ClassMethods

#require_all

Constructor Details

This class inherits a constructor from Varejonline::Client

Instance Method Details

#cancel(id) ⇒ Object



28
29
30
# File 'lib/varejonline/api/orders.rb', line 28

def cancel(id)
  return parse_response(self.class.put("/#{id}/cancelar", body: build_body, headers: header))
end

#find(id) ⇒ Object



16
17
18
# File 'lib/varejonline/api/orders.rb', line 16

def find(id)
  return parse_response(self.class.get("/#{id}", body: build_body, headers: header))
end

#list(searcher = nil) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
# File 'lib/varejonline/api/orders.rb', line 9

def list(searcher = nil)
  raise ArgumentError unless searcher.nil? || searcher.is_a?(Varejonline::Searcher::Operational::OrderSearcher)

  return parse_response(self.class.get('/', body: build_body(searcher.as_parameter), headers: header)) if searcher
  return parse_response(self.class.get('/', body: build_body, headers: header)) unless searcher
end

#save(data) ⇒ Object Also known as: create

Raises:

  • (ArgumentError)


20
21
22
23
24
25
# File 'lib/varejonline/api/orders.rb', line 20

def save(data)
  return parse_response(self.class.post('/', body: build_body(data), headers: header))              if data.is_a?(Hash)
  return parse_response(self.class.post('/', body: build_body(data.as_parameter), headers: header)) if data.is_a?(Varejonline::Entity::Commercial::Order)

  raise ArgumentError
end