bling_api 0.1.11 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bling_api/client.rb +11 -1
- data/lib/bling_api/customer.rb +1 -1
- data/lib/bling_api/seller.rb +41 -0
- data/lib/bling_api/version.rb +1 -1
- data/lib/bling_api.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b555184d85bd2868cae8cf4e87a26a11cecd56985e36036c85c42238e1e9f7e
|
4
|
+
data.tar.gz: 192812d80aed357f1011193abc56e6593fbeaf63222a6e59f0bd6d7c56b1329b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2c9bcee577fb4417ba47b9c64d60d5ed25da255627f58dd3ab96d7cae8331d857ed5ade00e521b9f903abd3e305a161d66d05584ed754bcc447665e59d92c8c
|
7
|
+
data.tar.gz: 703fc27931310b047beb60bd19375a5a6c24dcf1cf53d646826a80400bc0e78b2f06f13959bd71720bbb025a550b52a31a0ae4d2058329cc51a1bc4ebce27e01
|
data/Gemfile.lock
CHANGED
data/lib/bling_api/client.rb
CHANGED
@@ -23,6 +23,16 @@ module BlingApi
|
|
23
23
|
response.json["data"]
|
24
24
|
end
|
25
25
|
|
26
|
+
def get_seller(seller_id)
|
27
|
+
response = get("/vendedores/#{seller_id}") { _1.json["data"] }
|
28
|
+
response.json["data"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_sellers(page, limit, situation)
|
32
|
+
response = get("/vendedores?pagina=#{page}&limite=#{limit}&situacaoContato=#{situation}") { _1.json["data"] }
|
33
|
+
response.json["data"]
|
34
|
+
end
|
35
|
+
|
26
36
|
def find_contact_by_document_number(document_number)
|
27
37
|
response = get("/contatos?numeroDocumento=#{document_number.gsub(/\D/, "")}") {_1.json["data"]}
|
28
38
|
response.json["data"].first
|
@@ -54,4 +64,4 @@ module BlingApi
|
|
54
64
|
end
|
55
65
|
|
56
66
|
end
|
57
|
-
end
|
67
|
+
end
|
data/lib/bling_api/customer.rb
CHANGED
@@ -15,7 +15,7 @@ module BlingApi
|
|
15
15
|
end
|
16
16
|
|
17
17
|
attr_reader :nome, :pessoa_juridica, :telefone, :numero_documento, :id, :email, :endereco, :endereco_cobranca, :cod_contribuinte, :situacao
|
18
|
-
def initialize(nome:, pessoa_juridica:, numero_documento:, id:nil, telefone:nil, email:nil, endereco:nil, endereco_cobranca:nil, cod_contribuinte:nil, situacao:)
|
18
|
+
def initialize(nome:, pessoa_juridica:, numero_documento:, id:nil, telefone:nil, email:nil, endereco:nil, endereco_cobranca:nil, cod_contribuinte:nil, situacao:nil)
|
19
19
|
@id = id
|
20
20
|
@nome = nome
|
21
21
|
@pessoa_juridica = pessoa_juridica
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module BlingApi
|
2
|
+
class Seller
|
3
|
+
|
4
|
+
def self.get_sellers page: 1, limit: 100, situation: "A"
|
5
|
+
sellers = Client.new(BlingApi.configuration.access_token).get_sellers(page, limit, situation)
|
6
|
+
build_hash_sellers(sellers)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find_by_id id
|
10
|
+
seller = Client.new(BlingApi.configuration.access_token).get_seller(id)
|
11
|
+
new(**build_hash(seller))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.build_hash_sellers sellers
|
15
|
+
sellers.map do |seller|
|
16
|
+
{
|
17
|
+
id: seller.dig("id"),
|
18
|
+
nome: seller.dig("contato", "nome"),
|
19
|
+
situacao: seller.dig("contato", "situacao")
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_reader :id, :nome, :situacao
|
25
|
+
def initialize(id:, nome:, situacao:)
|
26
|
+
@id = id
|
27
|
+
@nome = nome
|
28
|
+
@situacao = situacao
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def self.build_hash json_response
|
34
|
+
{
|
35
|
+
id: json_response.dig("id"),
|
36
|
+
nome: json_response.dig("contato", "nome"),
|
37
|
+
situacao: json_response.dig("contato", "situacao")
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/bling_api/version.rb
CHANGED
data/lib/bling_api.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- caio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ac
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/bling_api/customer.rb
|
56
56
|
- lib/bling_api/order.rb
|
57
57
|
- lib/bling_api/product.rb
|
58
|
+
- lib/bling_api/seller.rb
|
58
59
|
- lib/bling_api/version.rb
|
59
60
|
- lib/generators/bling_api/install/install_generator.rb
|
60
61
|
- lib/generators/bling_api/install/templates/initializer.rb
|
@@ -79,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
80
|
- !ruby/object:Gem::Version
|
80
81
|
version: '0'
|
81
82
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.5.3
|
83
84
|
signing_key:
|
84
85
|
specification_version: 4
|
85
86
|
summary: ''
|