Class: BlingApi::Order
- Inherits:
-
Object
- Object
- BlingApi::Order
- Defined in:
- lib/bling_api/order.rb
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.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bling_api/order.rb', line 10 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.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def id @id end |
#id_categoria ⇒ Object (readonly)
Returns the value of attribute id_categoria.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def id_categoria @id_categoria end |
#id_contato ⇒ Object (readonly)
Returns the value of attribute id_contato.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def id_contato @id_contato end |
#id_loja ⇒ Object (readonly)
Returns the value of attribute id_loja.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def id_loja @id_loja end |
#id_vendedor ⇒ Object (readonly)
Returns the value of attribute id_vendedor.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def id_vendedor @id_vendedor end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def items @items end |
#numero ⇒ Object (readonly)
Returns the value of attribute numero.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def numero @numero end |
#numero_loja ⇒ Object (readonly)
Returns the value of attribute numero_loja.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def numero_loja @numero_loja end |
#numero_pedido_compra ⇒ Object (readonly)
Returns the value of attribute numero_pedido_compra.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def numero_pedido_compra @numero_pedido_compra end |
#observacoes ⇒ Object (readonly)
Returns the value of attribute observacoes.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def observacoes @observacoes end |
#observacoes_internas ⇒ Object (readonly)
Returns the value of attribute observacoes_internas.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def observacoes_internas @observacoes_internas end |
#parcelas ⇒ Object (readonly)
Returns the value of attribute parcelas.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def parcelas @parcelas end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def total @total end |
#total_produtos ⇒ Object (readonly)
Returns the value of attribute total_produtos.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def total_produtos @total_produtos end |
#transporte ⇒ Object (readonly)
Returns the value of attribute transporte.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def transporte @transporte end |
#unidade_desconto ⇒ Object (readonly)
Returns the value of attribute unidade_desconto.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def unidade_desconto @unidade_desconto end |
#valor_desconto ⇒ Object (readonly)
Returns the value of attribute valor_desconto.
9 10 11 |
# File 'lib/bling_api/order.rb', line 9 def valor_desconto @valor_desconto end |
Class Method Details
.find_by_id(id) ⇒ Object
4 5 6 7 |
# File 'lib/bling_api/order.rb', line 4 def self.find_by_id id response = Client.new(BlingApi.access_token).get_order(id) new(**build_hash(response)) end |
Instance Method Details
#build_json ⇒ Object
31 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 |
# File 'lib/bling_api/order.rb', line 31 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
58 59 60 61 |
# File 'lib/bling_api/order.rb', line 58 def create response = Client.new(BlingApi.access_token).create_order(JSON.dump(build_json)) self.class.find_by_id(response["id"]) end |