bling_api 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a04a4dbf899a435d7d09f1c723c9b8f99c46bcf25c683a1c43278f26adc8979c
4
- data.tar.gz: 7e61054450432223a0b236fb748d6c3cacd5e2f037139457ee41ba7ac351b565
3
+ metadata.gz: 84cb91501398dd70d7a13523dd6cdc48de2e4bba98350e2f204c453ddf03f425
4
+ data.tar.gz: adb1897298db3a8cf3c9a525b538d2d5a09ca1865e761076768e1023bfc5a8dc
5
5
  SHA512:
6
- metadata.gz: 844634140d72199434e0d45e361c4caf04002919e3f93de902f57184958b64be082826d5a6431001947cb67bbad2f2b885eed1ebbb3a37fc026bca012a14759b
7
- data.tar.gz: 7e2dd2c44f166405543d8bbb719dc4584bb25a96daf5e2091df78930f0a5a44548134339e8b7d98ebfa300676891dea196a1840576282965efff453c21ab249d
6
+ metadata.gz: 364475e50fd00865b764ed723637a0de45ff3b11faec11df0298f18c4cc636971f3a257217ea698740174ab4dd220932ecd2b94c0659b8094161317071f41588
7
+ data.tar.gz: 6c919a15a43d7e99ef147fdf1e6d9f8c6ad10655272b46441835bdd52be63d29c3e32dfee7d03d1a284e287fc5c3de8372ea4c75020fcc1895b5f5410f613254
data/Gemfile.lock CHANGED
@@ -1,44 +1,44 @@
1
- PATH
2
- remote: .
3
- specs:
4
- bling_api (0.1.2)
5
- ac
6
- base64
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- ac (0.1.1)
12
- typhoeus
13
- attr_extras (7.1.0)
14
- base64 (0.1.1)
15
- concurrent-ruby (1.2.2)
16
- diff-lcs (1.5.0)
17
- ethon (0.16.0)
18
- ffi (>= 1.15.0)
19
- ffi (1.16.3)
20
- optimist (3.1.0)
21
- patience_diff (1.2.0)
22
- optimist (~> 3.0)
23
- rake (13.1.0)
24
- super_diff (0.10.0)
25
- attr_extras (>= 6.2.4)
26
- diff-lcs
27
- patience_diff
28
- tldr (0.9.5)
29
- concurrent-ruby (~> 1.2)
30
- super_diff (~> 0.10)
31
- typhoeus (1.4.0)
32
- ethon (>= 0.9.0)
33
-
34
- PLATFORMS
35
- arm64-darwin-22
36
- x86_64-linux
37
-
38
- DEPENDENCIES
39
- bling_api!
40
- rake (~> 13.0)
41
- tldr
42
-
43
- BUNDLED WITH
44
- 2.4.12
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bling_api (0.1.3)
5
+ ac
6
+ base64
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ac (0.1.1)
12
+ typhoeus
13
+ attr_extras (7.1.0)
14
+ base64 (0.1.1)
15
+ concurrent-ruby (1.2.2)
16
+ diff-lcs (1.5.0)
17
+ ethon (0.16.0)
18
+ ffi (>= 1.15.0)
19
+ ffi (1.16.3)
20
+ optimist (3.1.0)
21
+ patience_diff (1.2.0)
22
+ optimist (~> 3.0)
23
+ rake (13.1.0)
24
+ super_diff (0.10.0)
25
+ attr_extras (>= 6.2.4)
26
+ diff-lcs
27
+ patience_diff
28
+ tldr (0.9.5)
29
+ concurrent-ruby (~> 1.2)
30
+ super_diff (~> 0.10)
31
+ typhoeus (1.4.0)
32
+ ethon (>= 0.9.0)
33
+
34
+ PLATFORMS
35
+ arm64-darwin-22
36
+ x86_64-linux
37
+
38
+ DEPENDENCIES
39
+ bling_api!
40
+ rake (~> 13.0)
41
+ tldr
42
+
43
+ BUNDLED WITH
44
+ 2.4.12
@@ -1,95 +1,95 @@
1
- module BlingApi
2
- class Customer
3
-
4
- def self.find_by_tax_id tax_id
5
- response_json = Client.new(BlingApi.access_token).find_contact_by_document_number(tax_id)
6
- if response_json
7
- contact = Client.new(BlingApi.access_token).get_contact(response_json["id"])
8
- new(**build_hash(contact))
9
- end
10
- end
11
-
12
- def self.find_by_id id
13
- contact = Client.new(BlingApi.access_token).get_contact(id)
14
- new(**build_hash(contact))
15
- end
16
-
17
- attr_reader :nome, :pessoa_juridica, :telefone, :numero_documento, :id, :email, :endereco, :endereco_cobranca
18
- def initialize(nome:, pessoa_juridica:, numero_documento:, id:nil, telefone:nil, email:nil, endereco:nil, endereco_cobranca:nil)
19
- @id = id
20
- @nome = nome
21
- @pessoa_juridica = pessoa_juridica
22
- @telefone = telefone
23
- @numero_documento = numero_documento
24
- @email = email
25
- @endereco = endereco
26
- @endereco_cobranca = endereco_cobranca
27
- end
28
-
29
- def build_json
30
- {
31
- "nome": nome,
32
- "telefone": telefone,
33
- "tipo": pessoa_juridica ? "J" : "F",
34
- "numeroDocumento": numero_documento,
35
- "email": email,
36
- "endereco": {
37
- "geral": {
38
- "endereco": endereco["endereco"],
39
- "cep": endereco["cep"],
40
- "bairro": endereco["bairro"],
41
- "municipio": endereco["municipio"],
42
- "uf": endereco["uf"],
43
- "numero": endereco["numero"],
44
- "complemento": endereco["complemento"]
45
- },
46
- "cobranca": {
47
- "endereco": endereco_cobranca["endereco"],
48
- "cep": endereco_cobranca["cep"],
49
- "bairro": endereco_cobranca["bairro"],
50
- "municipio": endereco_cobranca["municipio"],
51
- "uf": endereco_cobranca["uf"],
52
- "numero": endereco_cobranca["numero"],
53
- "complemento": endereco_cobranca["complemento"]
54
- }
55
- }
56
- }
57
- end
58
-
59
- def update attributes
60
- attributes.each do |key, value|
61
- if key == :endereco || key == :endereco_cobranca
62
- value.each do |k, v|
63
- self.send(key)[k] = v
64
- end
65
- else
66
- instance_variable_set("@#{key}", value)
67
- end
68
- end
69
- Client.new(BlingApi.access_token).update_contact(id, JSON.dump(build_json))
70
- self.class.find_by_id(self.id)
71
- end
72
-
73
- def create
74
- response = Client.new(BlingApi.access_token).create_contact(JSON.dump(build_json))
75
- self.class.find_by_id(response["id"])
76
- end
77
-
78
- private
79
-
80
- def self.build_hash json_response
81
- {
82
- id: json_response["id"],
83
- nome: json_response["nome"],
84
- telefone: json_response["telefone"],
85
- pessoa_juridica: json_response["tipo"] == "J",
86
- numero_documento: json_response["numeroDocumento"],
87
- email: json_response["email"],
88
- endereco: json_response["endereco"]["geral"],
89
- endereco_cobranca: json_response["endereco"]["cobranca"]
90
- }
91
- end
92
-
93
- end
94
- end
95
-
1
+ module BlingApi
2
+ class Customer
3
+
4
+ def self.find_by_tax_id tax_id
5
+ response_json = Client.new(BlingApi.access_token).find_contact_by_document_number(tax_id)
6
+ if response_json
7
+ contact = Client.new(BlingApi.access_token).get_contact(response_json["id"])
8
+ new(**build_hash(contact))
9
+ end
10
+ end
11
+
12
+ def self.find_by_id id
13
+ contact = Client.new(BlingApi.access_token).get_contact(id)
14
+ new(**build_hash(contact))
15
+ end
16
+
17
+ attr_reader :nome, :pessoa_juridica, :telefone, :numero_documento, :id, :email, :endereco, :endereco_cobranca
18
+ def initialize(nome:, pessoa_juridica:, numero_documento:, id:nil, telefone:nil, email:nil, endereco:nil, endereco_cobranca:nil)
19
+ @id = id
20
+ @nome = nome
21
+ @pessoa_juridica = pessoa_juridica
22
+ @telefone = telefone
23
+ @numero_documento = numero_documento
24
+ @email = email
25
+ @endereco = endereco&.with_indifferent_access
26
+ @endereco_cobranca = endereco_cobranca&.with_indifferent_access
27
+ end
28
+
29
+ def build_json
30
+ {
31
+ "nome": nome,
32
+ "telefone": telefone,
33
+ "tipo": pessoa_juridica ? "J" : "F",
34
+ "numeroDocumento": numero_documento,
35
+ "email": email,
36
+ "endereco": {
37
+ "geral": {
38
+ "endereco": endereco["endereco"],
39
+ "cep": endereco["cep"],
40
+ "bairro": endereco["bairro"],
41
+ "municipio": endereco["municipio"],
42
+ "uf": endereco["uf"],
43
+ "numero": endereco["numero"],
44
+ "complemento": endereco["complemento"]
45
+ },
46
+ "cobranca": {
47
+ "endereco": endereco_cobranca["endereco"],
48
+ "cep": endereco_cobranca["cep"],
49
+ "bairro": endereco_cobranca["bairro"],
50
+ "municipio": endereco_cobranca["municipio"],
51
+ "uf": endereco_cobranca["uf"],
52
+ "numero": endereco_cobranca["numero"],
53
+ "complemento": endereco_cobranca["complemento"]
54
+ }
55
+ }
56
+ }
57
+ end
58
+
59
+ def update attributes
60
+ attributes.each do |key, value|
61
+ if key == :endereco || key == :endereco_cobranca
62
+ value.each do |k, v|
63
+ self.send(key)[k] = v
64
+ end
65
+ else
66
+ instance_variable_set("@#{key}", value)
67
+ end
68
+ end
69
+ Client.new(BlingApi.access_token).update_contact(id, JSON.dump(build_json))
70
+ self.class.find_by_id(self.id)
71
+ end
72
+
73
+ def create
74
+ response = Client.new(BlingApi.access_token).create_contact(JSON.dump(build_json))
75
+ self.class.find_by_id(response["id"])
76
+ end
77
+
78
+ private
79
+
80
+ def self.build_hash json_response
81
+ {
82
+ id: json_response["id"],
83
+ nome: json_response["nome"],
84
+ telefone: json_response["telefone"],
85
+ pessoa_juridica: json_response["tipo"] == "J",
86
+ numero_documento: json_response["numeroDocumento"],
87
+ email: json_response["email"],
88
+ endereco: json_response["endereco"]["geral"],
89
+ endereco_cobranca: json_response["endereco"]["cobranca"]
90
+ }
91
+ end
92
+
93
+ end
94
+ end
95
+
@@ -1,91 +1,91 @@
1
- module BlingApi
2
- class Order
3
-
4
- def self.find_by_id id
5
- response = Client.new(BlingApi.access_token).get_order(id)
6
- new(**build_hash(response))
7
- end
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
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:)
11
- @id = id
12
- @numero = numero
13
- @id_contato = id_contato
14
- @items = items
15
- @parcelas = parcelas
16
- @numero_loja = numero_loja
17
- @data = data
18
- @total_produtos = total_produtos
19
- @total = total
20
- @id_loja = id_loja
21
- @numero_pedido_compra = numero_pedido_compra
22
- @observacoes = observacoes
23
- @observacoes_internas = observacoes_internas
24
- @valor_desconto = valor_desconto
25
- @unidade_desconto = unidade_desconto
26
- @id_categoria = id_categoria
27
- @transporte = transporte
28
- @id_vendedor = id_vendedor
29
- end
30
-
31
- def build_json
32
- {
33
- "numeroLoja": numero_loja,
34
- "data": data,
35
- "loja": {
36
- "id": id_loja
37
- },
38
- "contato": {
39
- "id": id_contato
40
- },
41
- "itens": items,
42
- "vendedor": {
43
- "id": id_vendedor
44
- },
45
- "transporte": transporte,
46
- "parcelas": parcelas,
47
- "desconto": {
48
- "valor": valor_desconto,
49
- "unidade": "REAL"
50
- },
51
- "totalProdutos": total_produtos,
52
- "total": total,
53
- "observacoes": observacoes,
54
- "observacoesInternas": observacoes_internas,
55
- "categoria": {
56
- "id": id_categoria
57
- }
58
- }
59
- end
60
-
61
- def create
62
- response = Client.new(BlingApi.access_token).create_order(JSON.dump(build_json))
63
- self.class.find_by_id(response["id"])
64
- end
65
-
66
- private
67
-
68
- def self.build_hash json_response
69
- {
70
- id: json_response["id"],
71
- id_contato: json_response["contato"]["id"],
72
- items: json_response["itens"],
73
- parcelas: json_response["parcelas"],
74
- numero_loja: json_response["numeroLoja"],
75
- numero: json_response["numero"],
76
- data: json_response["data"],
77
- total_produtos: json_response["totalProdutos"],
78
- total: json_response["total"],
79
- id_loja: json_response["loja"]["id"],
80
- numero_pedido_compra: json_response["numeroPedidoCompra"],
81
- observacoes: json_response["observacoes"],
82
- observacoes_internas: json_response["observacoesInternas"],
83
- desconto: json_response["desconto"],
84
- id_categoria: json_response["categoria"]["id"],
85
- transporte: json_response["transporte"],
86
- id_vendedor: json_response["vendedor"]["id"]
87
- }
88
- end
89
-
90
- end
1
+ module BlingApi
2
+ class Order
3
+
4
+ def self.find_by_id id
5
+ response = Client.new(BlingApi.access_token).get_order(id)
6
+ new(**build_hash(response))
7
+ end
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
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
+ @id = id
12
+ @numero = numero
13
+ @id_contato = id_contato
14
+ @items = items
15
+ @parcelas = parcelas
16
+ @numero_loja = numero_loja
17
+ @data = data
18
+ @total_produtos = total_produtos
19
+ @total = total
20
+ @id_loja = id_loja
21
+ @numero_pedido_compra = numero_pedido_compra
22
+ @observacoes = observacoes
23
+ @observacoes_internas = observacoes_internas
24
+ @valor_desconto = valor_desconto
25
+ @unidade_desconto = unidade_desconto
26
+ @id_categoria = id_categoria
27
+ @transporte = transporte
28
+ @id_vendedor = id_vendedor
29
+ end
30
+
31
+ def build_json
32
+ {
33
+ "numeroLoja": numero_loja,
34
+ "data": data,
35
+ "loja": {
36
+ "id": id_loja
37
+ },
38
+ "contato": {
39
+ "id": id_contato
40
+ },
41
+ "itens": items,
42
+ "vendedor": {
43
+ "id": id_vendedor
44
+ },
45
+ "transporte": transporte,
46
+ "parcelas": parcelas,
47
+ "desconto": {
48
+ "valor": valor_desconto,
49
+ "unidade": "REAL"
50
+ },
51
+ "totalProdutos": total_produtos,
52
+ "total": total,
53
+ "observacoes": observacoes,
54
+ "observacoesInternas": observacoes_internas,
55
+ "categoria": {
56
+ "id": id_categoria
57
+ }
58
+ }
59
+ end
60
+
61
+ def create
62
+ response = Client.new(BlingApi.access_token).create_order(JSON.dump(build_json))
63
+ self.class.find_by_id(response["id"])
64
+ end
65
+
66
+ private
67
+
68
+ def self.build_hash json_response
69
+ {
70
+ id: json_response["id"],
71
+ id_contato: json_response["contato"]["id"],
72
+ items: json_response["itens"],
73
+ parcelas: json_response["parcelas"],
74
+ numero_loja: json_response["numeroLoja"],
75
+ numero: json_response["numero"],
76
+ data: json_response["data"],
77
+ total_produtos: json_response["totalProdutos"],
78
+ total: json_response["total"],
79
+ id_loja: json_response["loja"]["id"],
80
+ numero_pedido_compra: json_response["numeroPedidoCompra"],
81
+ observacoes: json_response["observacoes"],
82
+ observacoes_internas: json_response["observacoesInternas"],
83
+ valor_desconto: json_response["desconto"]["valor"],
84
+ id_categoria: json_response["categoria"]["id"],
85
+ transporte: json_response["transporte"],
86
+ id_vendedor: json_response["vendedor"]["id"]
87
+ }
88
+ end
89
+
90
+ end
91
91
  end
@@ -1,29 +1,29 @@
1
- module BlingApi
2
- class Product
3
-
4
- def self.find_by_sku sku
5
- response_json = Client.new(BlingApi.access_token).find_product_by_sku(sku)
6
- if response_json
7
- new(**build_hash(response_json))
8
- end
9
- end
10
-
11
- attr_reader :id, :nome, :sku
12
- def initialize(id:, nome:, sku:)
13
- @id = id
14
- @nome = nome
15
- @sku = sku
16
- end
17
-
18
- private
19
-
20
- def self.build_hash json_response
21
- {
22
- id: json_response["id"],
23
- nome: json_response["nome"],
24
- sku: json_response["codigo"]
25
- }
26
- end
27
-
28
- end
1
+ module BlingApi
2
+ class Product
3
+
4
+ def self.find_by_sku sku
5
+ response_json = Client.new(BlingApi.access_token).find_product_by_sku(sku)
6
+ if response_json
7
+ new(**build_hash(response_json))
8
+ end
9
+ end
10
+
11
+ attr_reader :id, :nome, :sku
12
+ def initialize(id:, nome:, sku:)
13
+ @id = id
14
+ @nome = nome
15
+ @sku = sku
16
+ end
17
+
18
+ private
19
+
20
+ def self.build_hash json_response
21
+ {
22
+ id: json_response["id"],
23
+ nome: json_response["nome"],
24
+ sku: json_response["codigo"]
25
+ }
26
+ end
27
+
28
+ end
29
29
  end
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module BlingApi
4
- VERSION = "0.1.2"
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module BlingApi
4
+ VERSION = "0.1.3"
5
+ end
data/lib/bling_api.rb CHANGED
@@ -1,30 +1,31 @@
1
- # frozen_string_literal: true
2
-
3
- require "ac"
4
- require "base64"
5
- require_relative "bling_api/version"
6
- require_relative "bling_api/client"
7
- require_relative "bling_api/customer"
8
- require_relative "bling_api/order"
9
- require_relative "bling_api/product"
10
-
11
- module BlingApi
12
- class Error < StandardError; end
13
-
14
- class Configuration
15
- attr_accessor :access_token
16
-
17
- def initialize
18
- @api_key = nil
19
- end
20
- end
21
-
22
- class << self
23
- attr_accessor :access_token
24
- end
25
-
26
- def self.configure
27
- self.confiration ||= Configuration.new
28
- yield confiration
29
- end
30
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "ac"
4
+ require "base64"
5
+ require "active_support/core_ext/hash/indifferent_access"
6
+ require_relative "bling_api/version"
7
+ require_relative "bling_api/client"
8
+ require_relative "bling_api/customer"
9
+ require_relative "bling_api/order"
10
+ require_relative "bling_api/product"
11
+
12
+ module BlingApi
13
+ class Error < StandardError; end
14
+
15
+ class Configuration
16
+ attr_accessor :access_token
17
+
18
+ def initialize
19
+ @api_key = nil
20
+ end
21
+ end
22
+
23
+ class << self
24
+ attr_accessor :access_token
25
+ end
26
+
27
+ def self.configure
28
+ self.configuration ||= Configuration.new
29
+ yield configuration
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bling_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - caio
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-10 00:00:00.000000000 Z
11
+ date: 2023-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ac
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description:
41
+ description:
42
42
  email:
43
43
  - caioif4@gmail.com
44
44
  executables: []
@@ -62,7 +62,7 @@ licenses:
62
62
  metadata:
63
63
  homepage_uri: https://github.com/CaioGarcia1
64
64
  source_code_uri: https://github.com/CaioGarcia1
65
- post_install_message:
65
+ post_install_message:
66
66
  rdoc_options: []
67
67
  require_paths:
68
68
  - lib
@@ -77,8 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.4.20
81
- signing_key:
80
+ rubygems_version: 3.4.6
81
+ signing_key:
82
82
  specification_version: 4
83
83
  summary: ''
84
84
  test_files: []