bling-ruby 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 35eb4fc8d36b57254cc475b118ad6fb1def04d73
4
- data.tar.gz: 6379367b675a18de7c5a0333ec19f2ca384972e0
3
+ metadata.gz: 28ee36026efdd2a2d6a8b64bb229d1eccdb0f8c6
4
+ data.tar.gz: c2cce3b19f9065074e6218b0a951a9b750d806cd
5
5
  SHA512:
6
- metadata.gz: 26abf36ce543e12bb4cf59aa89947624eee709ee530b568ffa08303329ca2b32d6f37db7866554ad0234c2b42b928801c9c0e2ba94fc72374e5455b154aa1252
7
- data.tar.gz: 1a39b3780d78b06b235892ec93cb9e7045455a941dc1f8cebbd1987e05441c92cc35f6c581c00d16e8fc1dc4dce9417cc7401326866d224462eafa9ececb6a58
6
+ metadata.gz: c5a051bace9c5421eaa0b2cc81aea510fba0a1d158b445ab19510ed4afd9d75153bf6194c420315450eeddad794657527d212d171c2e893bbe577f71b01cc429
7
+ data.tar.gz: ac0f6862754219ac7ee0fac3479257c6fb248a129043bf5a8ab730a4ec15ceeaec5b79f8315668e05d153cb83b2d0304b4c33f14901c19788a09a0e3d740181a
data/README.md CHANGED
@@ -1,15 +1,12 @@
1
1
  bling-ruby
2
2
  ==========
3
3
 
4
- Configuração
5
- ============
4
+ Gem de integração com a plataforma de emissão de nota fiscal Bling - http://bling.com.br
6
5
 
7
- Crie um arquivo em: config/initializers/bling.rb com o seguinte conteúdo:
8
-
9
- Bling.setup do |config|
10
- config.apikey = 'sua-chave-aqui'
11
- end
6
+ Documentação
7
+ =============
12
8
 
9
+ Saiba mais em: http://www.rubydoc.info/github/organisys/bling-ruby/
13
10
 
14
11
  Contribuições
15
12
  =============
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/bling.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'bling-ruby'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.date = '2014-12-16'
5
5
  s.description = "The smartest integration with Bling system"
6
6
  s.summary = "The official Bling library"
data/lib/bling/base.rb CHANGED
@@ -11,14 +11,6 @@ module Bling
11
11
  # URL padrão para requisições no servidor Bling
12
12
  API_URL = "https://bling.com.br/Api/v2"
13
13
 
14
- # Variável que contém API Key
15
- mattr_accessor :apikey
16
-
17
- # Carrega arquivo de inicialização com configurações gerais
18
- def self.setup
19
- yield self
20
- end
21
-
22
14
  def show_data(param)
23
15
  if param["erros"]
24
16
  if param["erros"]["cod"] == 14
@@ -14,15 +14,18 @@ module Bling
14
14
  #
15
15
  # Parâmetros:
16
16
  #
17
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
18
+ #
17
19
  # numero - (opcional)
18
20
  #
19
21
  # serie - (opcional)
20
22
 
21
23
  def nota_fiscal(attributes = {})
24
+ apikey = attributes[:apikey]
22
25
  numero = attributes[:numero].to_s
23
26
  serie = attributes[:serie].to_s
24
27
 
25
- full_data = self.send(:get, "/notafiscal/#{numero}/#{serie}/json", { query: { apikey: Bling.apikey } } )
28
+ full_data = self.send(:get, "/notafiscal/#{numero}/#{serie}/json", { query: { apikey: apikey } } )
26
29
  full_data["retorno"]["notasfiscais"]
27
30
  end
28
31
 
@@ -30,6 +33,8 @@ module Bling
30
33
  #
31
34
  # Parâmetros:
32
35
  #
36
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
37
+ #
33
38
  # page - parâmetro para paginação (opcional)
34
39
  #
35
40
  # data_emissao - filtro para data de emissão da nota fiscal (opcional)
@@ -41,12 +46,12 @@ module Bling
41
46
  # situacao - veja em [http://bling.com.br/manuais.bling.php?p=manuais.api2#getNotasFiscais] as possíveis situações (opcional)
42
47
 
43
48
  def notas_fiscais(attributes = {})
49
+ apikey = attributes[:apikey]
44
50
  page_number = attributes[:page]
45
- page = "/page=#{page_number}" if page_number
46
-
47
- filters = set_filters(attributes)
51
+ page = "/page=#{page_number}" if page_number
52
+ filters = set_filters(attributes)
48
53
 
49
- full_data = self.send(:get, "/notasfiscais#{page}/json", { query: { apikey: Bling.apikey, filters: filters } } )
54
+ full_data = self.send(:get, "/notasfiscais#{page}/json", { query: { apikey: apikey, filters: filters } } )
50
55
 
51
56
  show_data(full_data["retorno"])
52
57
  end
@@ -55,12 +60,15 @@ module Bling
55
60
  #
56
61
  # Parâmetros:
57
62
  #
63
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
64
+ #
58
65
  # xml - Path para XML
59
66
 
60
67
  def salvar_nota_fiscal(attributes = {})
61
- xml = attributes[:xml]
68
+ apikey = attributes[:apikey]
69
+ xml = attributes[:xml]
62
70
 
63
- full_data = self.send(:post, '/notafiscal/json', { query: { apikey: Bling.apikey, xml: xml } } )
71
+ full_data = self.send(:post, '/notafiscal/json', { query: { apikey: apikey, xml: xml } } )
64
72
  full_data["retorno"]["notasfiscais"]
65
73
  end
66
74
 
@@ -68,6 +76,8 @@ module Bling
68
76
  #
69
77
  # Parâmetros:
70
78
  #
79
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
80
+ #
71
81
  # number - número da nota fiscal
72
82
  #
73
83
  # serie - número de série da nota fiscal
@@ -75,11 +85,12 @@ module Bling
75
85
  # send_mail - true/false (opcional)
76
86
 
77
87
  def salvar_consultar_nota_fiscal(attributes = {})
88
+ apikey = attributes[:apikey]
78
89
  number = attributes[:number].to_s
79
90
  serie = attributes[:serie].to_s
80
91
  send_email = attributes[:send_email]
81
92
 
82
- full_data = self.send(:post, '/notafiscal/json', { query: { apikey: Bling.apikey, number: number, serie: serie, sendEmail: send_email } } )
93
+ full_data = self.send(:post, '/notafiscal/json', { query: { apikey: apikey, number: number, serie: serie, sendEmail: send_email } } )
83
94
  full_data["retorno"]["notasfiscais"]
84
95
  end
85
96
 
@@ -15,12 +15,15 @@ module Bling
15
15
  #
16
16
  # Parâmetros:
17
17
  #
18
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
19
+ #
18
20
  # xml - Path para XML
19
21
 
20
22
  def salvar_nota_servico(attributes = {})
21
- xml = attributes[:xml]
23
+ apikey = attributes[:apikey]
24
+ xml = attributes[:xml]
22
25
 
23
- full_data = self.send(:post, '/notaservico/json', { query: { apikey: Bling.apikey, xml: xml } } )
26
+ full_data = self.send(:post, '/notaservico/json', { query: { apikey: apikey, xml: xml } } )
24
27
  full_data["retorno"]["notasservico"]
25
28
  end
26
29
  end
data/lib/bling/pedido.rb CHANGED
@@ -15,12 +15,15 @@ module Bling
15
15
  #
16
16
  # Parâmetros:
17
17
  #
18
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
19
+ #
18
20
  # xml - Path para XML
19
21
 
20
22
  def pedido(attributes = {})
23
+ apikey = attributes[:apikey]
21
24
  numero = attributes[:numero].to_s
22
25
 
23
- full_data = self.send(:get, "/pedido/#{numero}/json", { query: { apikey: Bling.apikey } } )
26
+ full_data = self.send(:get, "/pedido/#{numero}/json", { query: { apikey: apikey } } )
24
27
  full_data["retorno"]["pedidos"]
25
28
  end
26
29
 
@@ -28,13 +31,16 @@ module Bling
28
31
  #
29
32
  # Parâmetros:
30
33
  #
34
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
35
+ #
31
36
  # page - parâmetro para paginação (opcional)
32
37
 
33
38
  def pedidos(attributes = {})
39
+ apikey = attributes[:apikey]
34
40
  page_number = attributes[:page]
35
- page = "/page=#{page_number}" if page_number
41
+ page = "/page=#{page_number}" if page_number
36
42
 
37
- full_data = self.send(:get, "/pedidos#{page}/json", { query: { apikey: Bling.apikey } } )
43
+ full_data = self.send(:get, "/pedidos#{page}/json", { query: { apikey: apikey } } )
38
44
  full_data["retorno"]["pedidos"]
39
45
  end
40
46
 
@@ -42,15 +48,18 @@ module Bling
42
48
  #
43
49
  # Parâmetros:
44
50
  #
51
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
52
+ #
45
53
  # xml - Path para XML
46
54
  #
47
55
  # gera_nfe - true/false (opcional)
48
56
 
49
57
  def salvar_pedido(attributes = {})
50
- xml = attributes[:xml]
58
+ apikey = attributes[:apikey]
59
+ xml = attributes[:xml]
51
60
  gerar_nfe = attributes[:gerar_nfe].to_s
52
61
 
53
- full_data = self.send(:post, "/pedido/json", { query: { apikey: Bling.apikey, xml: xml, gerarnfe: gerar_nfe } } )
62
+ full_data = self.send(:post, "/pedido/json", { query: { apikey: apikey, xml: xml, gerarnfe: gerar_nfe } } )
54
63
  full_data["retorno"]["pedidos"]
55
64
  end
56
65
  end
data/lib/bling/produto.rb CHANGED
@@ -16,12 +16,15 @@ module Bling
16
16
  #
17
17
  # Parâmetros:
18
18
  #
19
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
20
+ #
19
21
  # xml - Path para XML
20
22
 
21
23
  def atualiza_produto(attributes = {})
22
- xml = attributes[:xml]
24
+ apikey = attributes[:apikey]
25
+ xml = attributes[:xml]
23
26
 
24
- full_data = self.send(:post, '/produto/json', { query: { apikey: Bling.apikey, xml: xml } } )
27
+ full_data = self.send(:post, '/produto/json', { query: { apikey: apikey, xml: xml } } )
25
28
  full_data["retorno"]["produtos"]
26
29
  end
27
30
 
@@ -29,12 +32,15 @@ module Bling
29
32
  #
30
33
  # Parâmetros:
31
34
  #
35
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
36
+ #
32
37
  # codigo - código do produto
33
38
 
34
39
  def deletar_produto(attributes = {})
40
+ apikey = attributes[:apikey]
35
41
  codigo = attributes[:codigo].to_s
36
42
 
37
- full_data = self.send(:delete, "/produto/#{codigo}", { body: { apikey: Bling.apikey } } )
43
+ full_data = self.send(:delete, "/produto/#{codigo}", { body: { apikey: apikey } } )
38
44
  full_data["retorno"]["produtos"]["produto"]
39
45
  end
40
46
 
@@ -42,12 +48,15 @@ module Bling
42
48
  #
43
49
  # Parâmetros:
44
50
  #
51
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
52
+ #
45
53
  # codigo - código do produto
46
54
 
47
55
  def produto(attributes = {})
56
+ apikey = attributes[:apikey]
48
57
  codigo = attributes[:codigo].to_s
49
58
 
50
- full_data = self.send(:get, "/produto/#{codigo}/json", { query: { apikey: Bling.apikey } } )
59
+ full_data = self.send(:get, "/produto/#{codigo}/json", { query: { apikey: apikey } } )
51
60
  full_data["retorno"]["produtos"]
52
61
  end
53
62
 
@@ -55,15 +64,18 @@ module Bling
55
64
  #
56
65
  # Parâmetros
57
66
  #
67
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
68
+ #
58
69
  # estoque - parâmetro para incluir estoque atual no retorno (opcional)
59
70
  #
60
71
  # page - parâmetro para paginação (opcional)
61
72
 
62
73
  def produtos(attributes = {})
74
+ apikey = attributes[:apikey]
63
75
  page_number = attributes[:page]
64
- page = "/page=#{page_number}" if page_number
76
+ page = "/page=#{page_number}" if page_number
65
77
 
66
- full_data = self.send(:get, "/produtos#{page}/json", { query: { apikey: Bling.apikey } } )
78
+ full_data = self.send(:get, "/produtos#{page}/json", { query: { apikey: apikey } } )
67
79
  full_data["retorno"]["produtos"]
68
80
  end
69
81
 
@@ -71,12 +83,15 @@ module Bling
71
83
  #
72
84
  # Parâmetros:
73
85
  #
86
+ # apikey - API Key obrigatória para requisiçãoes na plataforma Bling
87
+ #
74
88
  # xml - Path para XML
75
89
 
76
90
  def salvar_produto(attributes = {})
77
- xml = attributes[:xml]
91
+ apikey = attributes[:apikey]
92
+ xml = attributes[:xml]
78
93
 
79
- full_data = self.send(:post, '/produto/json', { query: { apikey: Bling.apikey, xml: xml } } )
94
+ full_data = self.send(:post, '/produto/json', { query: { apikey: apikey, xml: xml } } )
80
95
  full_data["retorno"]["produtos"]
81
96
  end
82
97
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bling-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Sousa