bling_api 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84cb91501398dd70d7a13523dd6cdc48de2e4bba98350e2f204c453ddf03f425
4
- data.tar.gz: adb1897298db3a8cf3c9a525b538d2d5a09ca1865e761076768e1023bfc5a8dc
3
+ metadata.gz: 10f3e0abf05620ac8d795ea49272d18ec388494248fa3a85178fd6e9ec496488
4
+ data.tar.gz: c0efbb931037f47f88acde597995d0925956bbe42f909c0b3bb803f004d3850b
5
5
  SHA512:
6
- metadata.gz: 364475e50fd00865b764ed723637a0de45ff3b11faec11df0298f18c4cc636971f3a257217ea698740174ab4dd220932ecd2b94c0659b8094161317071f41588
7
- data.tar.gz: 6c919a15a43d7e99ef147fdf1e6d9f8c6ad10655272b46441835bdd52be63d29c3e32dfee7d03d1a284e287fc5c3de8372ea4c75020fcc1895b5f5410f613254
6
+ metadata.gz: 15dcd2c8b672d379691b40f3b15c1441b659936ffaca1957f69da3b8188194e45b00cbca12f13de2eb26ff533f742b41bf1df0d3d6bea4ebbbb4f0ee5891016d
7
+ data.tar.gz: c8ebec0245600208a0c0da2b25d7aca0a8c462c716b203236af5a6dadd45ae3eddb2ad5fb1feaacb58e0b11dd7da9b9ac208f0922eb6a4f91df827570e439098
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bling_api (0.1.3)
4
+ bling_api (0.1.5)
5
5
  ac
6
6
  base64
7
7
 
@@ -11,7 +11,7 @@ GEM
11
11
  ac (0.1.1)
12
12
  typhoeus
13
13
  attr_extras (7.1.0)
14
- base64 (0.1.1)
14
+ base64 (0.2.0)
15
15
  concurrent-ruby (1.2.2)
16
16
  diff-lcs (1.5.0)
17
17
  ethon (0.16.0)
@@ -2,15 +2,15 @@ module BlingApi
2
2
  class Customer
3
3
 
4
4
  def self.find_by_tax_id tax_id
5
- response_json = Client.new(BlingApi.access_token).find_contact_by_document_number(tax_id)
5
+ response_json = Client.new(BlingApi.configuration.access_token).find_contact_by_document_number(tax_id)
6
6
  if response_json
7
- contact = Client.new(BlingApi.access_token).get_contact(response_json["id"])
7
+ contact = Client.new(BlingApi.configuration.access_token).get_contact(response_json["id"])
8
8
  new(**build_hash(contact))
9
9
  end
10
10
  end
11
11
 
12
12
  def self.find_by_id id
13
- contact = Client.new(BlingApi.access_token).get_contact(id)
13
+ contact = Client.new(BlingApi.configuration.access_token).get_contact(id)
14
14
  new(**build_hash(contact))
15
15
  end
16
16
 
@@ -66,12 +66,12 @@ module BlingApi
66
66
  instance_variable_set("@#{key}", value)
67
67
  end
68
68
  end
69
- Client.new(BlingApi.access_token).update_contact(id, JSON.dump(build_json))
69
+ Client.new(BlingApi.configuration.access_token).update_contact(id, JSON.dump(build_json))
70
70
  self.class.find_by_id(self.id)
71
71
  end
72
72
 
73
73
  def create
74
- response = Client.new(BlingApi.access_token).create_contact(JSON.dump(build_json))
74
+ response = Client.new(BlingApi.configuration.access_token).create_contact(JSON.dump(build_json))
75
75
  self.class.find_by_id(response["id"])
76
76
  end
77
77
 
@@ -2,11 +2,11 @@ module BlingApi
2
2
  class Order
3
3
 
4
4
  def self.find_by_id id
5
- response = Client.new(BlingApi.access_token).get_order(id)
5
+ response = Client.new(BlingApi.configuration.access_token).get_order(id)
6
6
  new(**build_hash(response))
7
7
  end
8
8
 
9
- attr_reader :id, :numero, :id_contato, :items, :parcelas, :numero_loja, :data, :total_produtos, :total, :id_loja, :numero_pedido_compra, :observacoes, :observacoes_internas, :valor_desconto, :unidade_desconto, :id_categoria, :transporte, :id_vendedor
9
+ attr_reader :id, :numero, :id_contato, :items, :parcelas, :numero_loja, :data, :total_produtos, :total, :id_loja, :numero_pedido_compra, :observacoes, :observacoes_internas, :valor_desconto, :id_categoria, :transporte, :id_vendedor
10
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:, id_categoria:, transporte:nil, id_vendedor:)
11
11
  @id = id
12
12
  @numero = numero
@@ -22,7 +22,6 @@ module BlingApi
22
22
  @observacoes = observacoes
23
23
  @observacoes_internas = observacoes_internas
24
24
  @valor_desconto = valor_desconto
25
- @unidade_desconto = unidade_desconto
26
25
  @id_categoria = id_categoria
27
26
  @transporte = transporte
28
27
  @id_vendedor = id_vendedor
@@ -59,7 +58,7 @@ module BlingApi
59
58
  end
60
59
 
61
60
  def create
62
- response = Client.new(BlingApi.access_token).create_order(JSON.dump(build_json))
61
+ response = Client.new(BlingApi.configuration.access_token).create_order(JSON.dump(build_json))
63
62
  self.class.find_by_id(response["id"])
64
63
  end
65
64
 
@@ -2,7 +2,7 @@ module BlingApi
2
2
  class Product
3
3
 
4
4
  def self.find_by_sku sku
5
- response_json = Client.new(BlingApi.access_token).find_product_by_sku(sku)
5
+ response_json = Client.new(BlingApi.configuration.access_token).find_product_by_sku(sku)
6
6
  if response_json
7
7
  new(**build_hash(response_json))
8
8
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlingApi
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/bling_api.rb CHANGED
@@ -16,12 +16,11 @@ module BlingApi
16
16
  attr_accessor :access_token
17
17
 
18
18
  def initialize
19
- @api_key = nil
20
19
  end
21
20
  end
22
21
 
23
22
  class << self
24
- attr_accessor :access_token
23
+ attr_accessor :configuration
25
24
  end
26
25
 
27
26
  def self.configure
@@ -0,0 +1,10 @@
1
+ module BlingApi
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("templates", __dir__)
5
+ def copy_initializer
6
+ template "initializer.rb", "config/initializers/bling_api.rb"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ BlingApi.configure do |config|
2
+ #config.access_token = ""
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bling_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - caio
@@ -56,6 +56,8 @@ files:
56
56
  - lib/bling_api/order.rb
57
57
  - lib/bling_api/product.rb
58
58
  - lib/bling_api/version.rb
59
+ - lib/generators/bling_api/install/install_generator.rb
60
+ - lib/generators/bling_api/install/templates/initializer.rb
59
61
  homepage: https://github.com/CaioGarcia1
60
62
  licenses:
61
63
  - MIT