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 +4 -4
- data/README.md +4 -7
- data/VERSION +1 -1
- data/bling.gemspec +1 -1
- data/lib/bling/base.rb +0 -8
- data/lib/bling/nota_fiscal.rb +19 -8
- data/lib/bling/nota_servico.rb +5 -2
- data/lib/bling/pedido.rb +14 -5
- data/lib/bling/produto.rb +23 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28ee36026efdd2a2d6a8b64bb229d1eccdb0f8c6
|
4
|
+
data.tar.gz: c2cce3b19f9065074e6218b0a951a9b750d806cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
5
|
-
============
|
4
|
+
Gem de integração com a plataforma de emissão de nota fiscal Bling - http://bling.com.br
|
6
5
|
|
7
|
-
|
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
|
+
0.0.2
|
data/bling.gemspec
CHANGED
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
|
data/lib/bling/nota_fiscal.rb
CHANGED
@@ -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:
|
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
|
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:
|
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
|
-
|
68
|
+
apikey = attributes[:apikey]
|
69
|
+
xml = attributes[:xml]
|
62
70
|
|
63
|
-
full_data = self.send(:post, '/notafiscal/json', { query: { apikey:
|
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:
|
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
|
|
data/lib/bling/nota_servico.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 salvar_nota_servico(attributes = {})
|
21
|
-
|
23
|
+
apikey = attributes[:apikey]
|
24
|
+
xml = attributes[:xml]
|
22
25
|
|
23
|
-
full_data = self.send(:post, '/notaservico/json', { query: { apikey:
|
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:
|
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
|
41
|
+
page = "/page=#{page_number}" if page_number
|
36
42
|
|
37
|
-
full_data = self.send(:get, "/pedidos#{page}/json", { query: { 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
|
-
|
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:
|
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
|
-
|
24
|
+
apikey = attributes[:apikey]
|
25
|
+
xml = attributes[:xml]
|
23
26
|
|
24
|
-
full_data = self.send(:post, '/produto/json', { query: { apikey:
|
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:
|
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:
|
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
|
76
|
+
page = "/page=#{page_number}" if page_number
|
65
77
|
|
66
|
-
full_data = self.send(:get, "/produtos#{page}/json", { query: { 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
|
-
|
91
|
+
apikey = attributes[:apikey]
|
92
|
+
xml = attributes[:xml]
|
78
93
|
|
79
|
-
full_data = self.send(:post, '/produto/json', { query: { apikey:
|
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
|