Class: BlingApi::Order
- Inherits:
-
Object
- Object
- BlingApi::Order
- Defined in:
- lib/bling_api/order.rb
Constant Summary collapse
- ACCESS_TOKEN =
"0039bb7d2d3e3c6777983361204dc168ecbf1ef8"
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#id_categoria ⇒ Object
readonly
Returns the value of attribute id_categoria.
-
#id_contato ⇒ Object
readonly
Returns the value of attribute id_contato.
-
#id_loja ⇒ Object
readonly
Returns the value of attribute id_loja.
-
#id_vendedor ⇒ Object
readonly
Returns the value of attribute id_vendedor.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#numero ⇒ Object
readonly
Returns the value of attribute numero.
-
#numero_loja ⇒ Object
readonly
Returns the value of attribute numero_loja.
-
#numero_pedido_compra ⇒ Object
readonly
Returns the value of attribute numero_pedido_compra.
-
#observacoes ⇒ Object
readonly
Returns the value of attribute observacoes.
-
#observacoes_internas ⇒ Object
readonly
Returns the value of attribute observacoes_internas.
-
#parcelas ⇒ Object
readonly
Returns the value of attribute parcelas.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#total_produtos ⇒ Object
readonly
Returns the value of attribute total_produtos.
-
#transporte ⇒ Object
readonly
Returns the value of attribute transporte.
-
#unidade_desconto ⇒ Object
readonly
Returns the value of attribute unidade_desconto.
-
#valor_desconto ⇒ Object
readonly
Returns the value of attribute valor_desconto.
Class Method Summary collapse
Instance Method Summary collapse
- #build_json ⇒ Object
- #create ⇒ Object
-
#initialize(id: nil, numero: nil, id_contato:, items:, parcelas: nil, numero_loja:, data:, total_produtos:, total:, id_loja:, numero_pedido_compra: nil, observacoes:, observacoes_internas:, valor_desconto:, unidade_desconto:, id_categoria:, transporte: nil, id_vendedor:) ⇒ Order
constructor
A new instance of Order.
Constructor Details
#initialize(id: nil, numero: nil, id_contato:, items:, parcelas: nil, numero_loja:, data:, total_produtos:, total:, id_loja:, numero_pedido_compra: nil, observacoes:, observacoes_internas:, valor_desconto:, unidade_desconto:, id_categoria:, transporte: nil, id_vendedor:) ⇒ Order
Returns a new instance of Order.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bling_api/order.rb', line 11 def initialize(id:nil, numero:nil, id_contato:, items:, parcelas:nil, numero_loja:, data:, total_produtos:, total:, id_loja:, numero_pedido_compra:nil, observacoes:, observacoes_internas:, valor_desconto:, unidade_desconto:, id_categoria:, transporte:nil, id_vendedor:) @id = id @numero = numero @id_contato = id_contato @items = items @parcelas = parcelas @numero_loja = numero_loja @data = data @total_produtos = total_produtos @total = total @id_loja = id_loja @numero_pedido_compra = numero_pedido_compra @observacoes = observacoes @observacoes_internas = observacoes_internas @valor_desconto = valor_desconto @unidade_desconto = unidade_desconto @id_categoria = id_categoria @transporte = transporte @id_vendedor = id_vendedor end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def id @id end |
#id_categoria ⇒ Object (readonly)
Returns the value of attribute id_categoria.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def id_categoria @id_categoria end |
#id_contato ⇒ Object (readonly)
Returns the value of attribute id_contato.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def id_contato @id_contato end |
#id_loja ⇒ Object (readonly)
Returns the value of attribute id_loja.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def id_loja @id_loja end |
#id_vendedor ⇒ Object (readonly)
Returns the value of attribute id_vendedor.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def id_vendedor @id_vendedor end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def items @items end |
#numero ⇒ Object (readonly)
Returns the value of attribute numero.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def numero @numero end |
#numero_loja ⇒ Object (readonly)
Returns the value of attribute numero_loja.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def numero_loja @numero_loja end |
#numero_pedido_compra ⇒ Object (readonly)
Returns the value of attribute numero_pedido_compra.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def numero_pedido_compra @numero_pedido_compra end |
#observacoes ⇒ Object (readonly)
Returns the value of attribute observacoes.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def observacoes @observacoes end |
#observacoes_internas ⇒ Object (readonly)
Returns the value of attribute observacoes_internas.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def observacoes_internas @observacoes_internas end |
#parcelas ⇒ Object (readonly)
Returns the value of attribute parcelas.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def parcelas @parcelas end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def total @total end |
#total_produtos ⇒ Object (readonly)
Returns the value of attribute total_produtos.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def total_produtos @total_produtos end |
#transporte ⇒ Object (readonly)
Returns the value of attribute transporte.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def transporte @transporte end |
#unidade_desconto ⇒ Object (readonly)
Returns the value of attribute unidade_desconto.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def unidade_desconto @unidade_desconto end |
#valor_desconto ⇒ Object (readonly)
Returns the value of attribute valor_desconto.
10 11 12 |
# File 'lib/bling_api/order.rb', line 10 def valor_desconto @valor_desconto end |
Class Method Details
.find_by_id(id) ⇒ Object
5 6 7 8 |
# File 'lib/bling_api/order.rb', line 5 def self.find_by_id id response = Client.new(ACCESS_TOKEN).get_order(id) new(**build_hash(response)) end |
Instance Method Details
#build_json ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bling_api/order.rb', line 32 def build_json { "numeroLoja": numero_loja, "data": data, "loja": { "id": id_loja }, "contato": { "id": id_contato }, "itens": items, "vendedor": { "id": id_vendedor }, "transporte": transporte, "parcelas": parcelas, "valorDesconto": valor_desconto, "totalProdutos": total_produtos, "total": total, "observacoes": observacoes, "observacoesInternas": observacoes_internas, "categoria": { "id": id_categoria } } end |
#create ⇒ Object
59 60 61 62 |
# File 'lib/bling_api/order.rb', line 59 def create response = Client.new(ACCESS_TOKEN).create_order(JSON.dump(build_json)) self.class.find_by_id(response["id"]) end |