bling-ruby 0.0.2 → 0.0.3
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/Gemfile.lock +33 -16
- data/LICENSE.txt +2 -2
- data/VERSION +1 -1
- data/bling.gemspec +1 -1
- data/lib/bling/base.rb +0 -12
- data/lib/bling/nota_fiscal.rb +11 -5
- data/lib/bling/nota_servico.rb +10 -1
- data/lib/bling/pedido.rb +12 -3
- data/lib/bling/produto.rb +14 -5
- 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: a8edbd5138a98bbe569695ef0cfc15d96491b1c7
|
4
|
+
data.tar.gz: a1282325ffb70fe1b5852e2a2d3a36099331cd37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19b3fc02750c2c6500ca40ef5d3c28771e3d925f0870228ed57250ca33280eaa937eeceadd4877cf2d76871d885c8284e9cb2514c6678902aa884176904313f
|
7
|
+
data.tar.gz: 4d51718f9e8e335adcf79fd50ed9d5e0ecfef61bb8c5e4dab2c6117ab4b2725cafdfea8729981ba1c954eda7d910c3bfd89222a193ad914dbee7ffa37305b438
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,30 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bling (0.0.
|
4
|
+
bling-ruby (0.0.3)
|
5
5
|
httparty (~> 0.13.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionpack (4.
|
11
|
-
actionview (= 4.
|
12
|
-
activesupport (= 4.
|
13
|
-
rack (~> 1.
|
10
|
+
actionpack (4.2.0)
|
11
|
+
actionview (= 4.2.0)
|
12
|
+
activesupport (= 4.2.0)
|
13
|
+
rack (~> 1.6.0)
|
14
14
|
rack-test (~> 0.6.2)
|
15
|
-
|
16
|
-
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
17
|
+
actionview (4.2.0)
|
18
|
+
activesupport (= 4.2.0)
|
17
19
|
builder (~> 3.1)
|
18
20
|
erubis (~> 2.7.0)
|
19
|
-
|
20
|
-
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
23
|
+
activesupport (4.2.0)
|
24
|
+
i18n (~> 0.7)
|
21
25
|
json (~> 1.7, >= 1.7.7)
|
22
26
|
minitest (~> 5.1)
|
23
|
-
thread_safe (~> 0.
|
27
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
24
28
|
tzinfo (~> 1.1)
|
25
29
|
builder (3.2.2)
|
26
30
|
diff-lcs (1.2.5)
|
@@ -28,16 +32,29 @@ GEM
|
|
28
32
|
httparty (0.13.3)
|
29
33
|
json (~> 1.8)
|
30
34
|
multi_xml (>= 0.5.2)
|
31
|
-
i18n (0.
|
35
|
+
i18n (0.7.0)
|
32
36
|
json (1.8.1)
|
37
|
+
loofah (2.0.1)
|
38
|
+
nokogiri (>= 1.5.9)
|
39
|
+
mini_portile (0.6.1)
|
33
40
|
minitest (5.5.0)
|
34
41
|
multi_xml (0.5.5)
|
35
|
-
|
42
|
+
nokogiri (1.6.5)
|
43
|
+
mini_portile (~> 0.6.0)
|
44
|
+
rack (1.6.0)
|
36
45
|
rack-test (0.6.2)
|
37
46
|
rack (>= 1.0)
|
38
|
-
|
39
|
-
|
40
|
-
|
47
|
+
rails-deprecated_sanitizer (1.0.3)
|
48
|
+
activesupport (>= 4.2.0.alpha)
|
49
|
+
rails-dom-testing (1.0.5)
|
50
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
51
|
+
nokogiri (~> 1.6.0)
|
52
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
53
|
+
rails-html-sanitizer (1.0.1)
|
54
|
+
loofah (~> 2.0)
|
55
|
+
railties (4.2.0)
|
56
|
+
actionpack (= 4.2.0)
|
57
|
+
activesupport (= 4.2.0)
|
41
58
|
rake (>= 0.8.7)
|
42
59
|
thor (>= 0.18.1, < 2.0)
|
43
60
|
rake (10.3.2)
|
@@ -66,6 +83,6 @@ PLATFORMS
|
|
66
83
|
ruby
|
67
84
|
|
68
85
|
DEPENDENCIES
|
69
|
-
bling!
|
86
|
+
bling-ruby!
|
70
87
|
rake (~> 10.3.2)
|
71
88
|
rspec-rails (~> 3.1.0)
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2014 Luciano Sousa
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/bling.gemspec
CHANGED
data/lib/bling/base.rb
CHANGED
@@ -10,18 +10,6 @@ module Bling
|
|
10
10
|
|
11
11
|
# URL padrão para requisições no servidor Bling
|
12
12
|
API_URL = "https://bling.com.br/Api/v2"
|
13
|
-
|
14
|
-
def show_data(param)
|
15
|
-
if param["erros"]
|
16
|
-
if param["erros"]["cod"] == 14
|
17
|
-
[]
|
18
|
-
end
|
19
|
-
else
|
20
|
-
param
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class MissingApiKeyError < StandardError; end
|
25
13
|
end
|
26
14
|
|
27
15
|
class Object
|
data/lib/bling/nota_fiscal.rb
CHANGED
@@ -4,6 +4,8 @@ require 'httparty'
|
|
4
4
|
# Nota Fiscal: Mantém notas fiscais
|
5
5
|
|
6
6
|
module Bling
|
7
|
+
class BlingError < StandardError ; end
|
8
|
+
|
7
9
|
class NotaFiscal
|
8
10
|
include HTTParty
|
9
11
|
|
@@ -26,7 +28,7 @@ module Bling
|
|
26
28
|
serie = attributes[:serie].to_s
|
27
29
|
|
28
30
|
full_data = self.send(:get, "/notafiscal/#{numero}/#{serie}/json", { query: { apikey: apikey } } )
|
29
|
-
full_data["retorno"]
|
31
|
+
get_response(full_data["retorno"])
|
30
32
|
end
|
31
33
|
|
32
34
|
# Listagem de notas fiscais
|
@@ -52,8 +54,7 @@ module Bling
|
|
52
54
|
filters = set_filters(attributes)
|
53
55
|
|
54
56
|
full_data = self.send(:get, "/notasfiscais#{page}/json", { query: { apikey: apikey, filters: filters } } )
|
55
|
-
|
56
|
-
show_data(full_data["retorno"])
|
57
|
+
get_response(full_data["retorno"])
|
57
58
|
end
|
58
59
|
|
59
60
|
# Salva uma nota fiscal
|
@@ -69,7 +70,7 @@ module Bling
|
|
69
70
|
xml = attributes[:xml]
|
70
71
|
|
71
72
|
full_data = self.send(:post, '/notafiscal/json', { query: { apikey: apikey, xml: xml } } )
|
72
|
-
full_data["retorno"]
|
73
|
+
get_response(full_data["retorno"])
|
73
74
|
end
|
74
75
|
|
75
76
|
# Salva e retorna os dados de uma nota fiscal
|
@@ -91,11 +92,16 @@ module Bling
|
|
91
92
|
send_email = attributes[:send_email]
|
92
93
|
|
93
94
|
full_data = self.send(:post, '/notafiscal/json', { query: { apikey: apikey, number: number, serie: serie, sendEmail: send_email } } )
|
94
|
-
full_data["retorno"]
|
95
|
+
get_response(full_data["retorno"])
|
95
96
|
end
|
96
97
|
|
97
98
|
private
|
98
99
|
|
100
|
+
def get_response data
|
101
|
+
raise(BlingError, data["erros"]["erro"]) if data["erros"]
|
102
|
+
data["notasservico"]
|
103
|
+
end
|
104
|
+
|
99
105
|
def set_filters attributes
|
100
106
|
data_emissao_from = attributes[:data_emissao_from]
|
101
107
|
data_emissao_to = attributes[:data_emissao_to]
|
data/lib/bling/nota_servico.rb
CHANGED
@@ -4,6 +4,8 @@ require 'httparty'
|
|
4
4
|
# Nota Serviço: Mantém notas de serviço
|
5
5
|
|
6
6
|
module Bling
|
7
|
+
class BlingError < StandardError ; end
|
8
|
+
|
7
9
|
class NotaServico
|
8
10
|
include HTTParty
|
9
11
|
|
@@ -24,7 +26,14 @@ module Bling
|
|
24
26
|
xml = attributes[:xml]
|
25
27
|
|
26
28
|
full_data = self.send(:post, '/notaservico/json', { query: { apikey: apikey, xml: xml } } )
|
27
|
-
full_data["retorno"]
|
29
|
+
get_response(full_data["retorno"])
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def get_response data
|
35
|
+
raise(BlingError, data["erros"]["erro"]) if data["erros"]
|
36
|
+
data["notasservico"]
|
28
37
|
end
|
29
38
|
end
|
30
39
|
end
|
data/lib/bling/pedido.rb
CHANGED
@@ -4,6 +4,8 @@ require 'httparty'
|
|
4
4
|
# Pedido: Mantém pedidos
|
5
5
|
|
6
6
|
module Bling
|
7
|
+
class BlingError < StandardError ; end
|
8
|
+
|
7
9
|
class Pedido
|
8
10
|
include HTTParty
|
9
11
|
|
@@ -24,7 +26,7 @@ module Bling
|
|
24
26
|
numero = attributes[:numero].to_s
|
25
27
|
|
26
28
|
full_data = self.send(:get, "/pedido/#{numero}/json", { query: { apikey: apikey } } )
|
27
|
-
full_data["retorno"]
|
29
|
+
get_response(full_data["retorno"])
|
28
30
|
end
|
29
31
|
|
30
32
|
# Lista pedidos do sistema
|
@@ -41,7 +43,7 @@ module Bling
|
|
41
43
|
page = "/page=#{page_number}" if page_number
|
42
44
|
|
43
45
|
full_data = self.send(:get, "/pedidos#{page}/json", { query: { apikey: apikey } } )
|
44
|
-
full_data["retorno"]
|
46
|
+
get_response(full_data["retorno"])
|
45
47
|
end
|
46
48
|
|
47
49
|
# Salva um pedido
|
@@ -60,7 +62,14 @@ module Bling
|
|
60
62
|
gerar_nfe = attributes[:gerar_nfe].to_s
|
61
63
|
|
62
64
|
full_data = self.send(:post, "/pedido/json", { query: { apikey: apikey, xml: xml, gerarnfe: gerar_nfe } } )
|
63
|
-
full_data["retorno"]
|
65
|
+
get_response(full_data["retorno"])
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def get_response data
|
71
|
+
raise(BlingError, data["erros"]["erro"]) if data["erros"]
|
72
|
+
data["pedidos"]
|
64
73
|
end
|
65
74
|
end
|
66
75
|
end
|
data/lib/bling/produto.rb
CHANGED
@@ -4,6 +4,8 @@ require 'httparty'
|
|
4
4
|
# Produto: Mantém produtos
|
5
5
|
|
6
6
|
module Bling
|
7
|
+
class BlingError < StandardError ; end
|
8
|
+
|
7
9
|
class Produto
|
8
10
|
include HTTParty
|
9
11
|
|
@@ -25,7 +27,7 @@ module Bling
|
|
25
27
|
xml = attributes[:xml]
|
26
28
|
|
27
29
|
full_data = self.send(:post, '/produto/json', { query: { apikey: apikey, xml: xml } } )
|
28
|
-
full_data["retorno"]
|
30
|
+
get_response(full_data["retorno"])
|
29
31
|
end
|
30
32
|
|
31
33
|
# Deleta um produto
|
@@ -41,7 +43,7 @@ module Bling
|
|
41
43
|
codigo = attributes[:codigo].to_s
|
42
44
|
|
43
45
|
full_data = self.send(:delete, "/produto/#{codigo}", { body: { apikey: apikey } } )
|
44
|
-
full_data["retorno"]
|
46
|
+
get_response(full_data["retorno"])
|
45
47
|
end
|
46
48
|
|
47
49
|
# Busca por um produto
|
@@ -57,7 +59,7 @@ module Bling
|
|
57
59
|
codigo = attributes[:codigo].to_s
|
58
60
|
|
59
61
|
full_data = self.send(:get, "/produto/#{codigo}/json", { query: { apikey: apikey } } )
|
60
|
-
full_data["retorno"]
|
62
|
+
get_response(full_data["retorno"])
|
61
63
|
end
|
62
64
|
|
63
65
|
# Listagem de produtos
|
@@ -76,7 +78,7 @@ module Bling
|
|
76
78
|
page = "/page=#{page_number}" if page_number
|
77
79
|
|
78
80
|
full_data = self.send(:get, "/produtos#{page}/json", { query: { apikey: apikey } } )
|
79
|
-
full_data["retorno"]
|
81
|
+
get_response(full_data["retorno"])
|
80
82
|
end
|
81
83
|
|
82
84
|
# Salva um produto
|
@@ -92,7 +94,14 @@ module Bling
|
|
92
94
|
xml = attributes[:xml]
|
93
95
|
|
94
96
|
full_data = self.send(:post, '/produto/json', { query: { apikey: apikey, xml: xml } } )
|
95
|
-
full_data["retorno"]
|
97
|
+
get_response(full_data["retorno"])
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def get_response data
|
103
|
+
raise(BlingError, data["erros"]["erro"]) if data["erros"]
|
104
|
+
data["produtos"]
|
96
105
|
end
|
97
106
|
end
|
98
107
|
end
|