bling_api 0.1.11 → 0.2.0

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: 27d162f29e177e25c375a3568e8f019c3090bc1e8e4365f2ba397e692d5d9af8
4
- data.tar.gz: 8fa35e70e66a37e5f2f7fa0fd297c050ac631fc9ec2400d9ba3b1d1711d6db2e
3
+ metadata.gz: 9b555184d85bd2868cae8cf4e87a26a11cecd56985e36036c85c42238e1e9f7e
4
+ data.tar.gz: 192812d80aed357f1011193abc56e6593fbeaf63222a6e59f0bd6d7c56b1329b
5
5
  SHA512:
6
- metadata.gz: 0f9380ad598d6b0c6f9d105d13b3bd081f69e50a8dcc9819bcad9dcfb20940f081a0dd329ba96d76af8b23bef29c386c8a74e2e9e60e67d27c6d3c67d9a42099
7
- data.tar.gz: 4030fb571a210cdce2a5aa82af18d24ee286ec729e9680defd93a2a4f10daf9b3475269450111507487f95d2ef128a8846aaf92cdf410a5d561b977414e9b103
6
+ metadata.gz: d2c9bcee577fb4417ba47b9c64d60d5ed25da255627f58dd3ab96d7cae8331d857ed5ade00e521b9f903abd3e305a161d66d05584ed754bcc447665e59d92c8c
7
+ data.tar.gz: 703fc27931310b047beb60bd19375a5a6c24dcf1cf53d646826a80400bc0e78b2f06f13959bd71720bbb025a550b52a31a0ae4d2058329cc51a1bc4ebce27e01
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bling_api (0.1.10)
4
+ bling_api (0.2.0)
5
5
  ac
6
6
  base64
7
7
 
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlingApi
4
- VERSION = "0.1.11"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/bling_api.rb CHANGED
@@ -8,6 +8,7 @@ require_relative "bling_api/client"
8
8
  require_relative "bling_api/customer"
9
9
  require_relative "bling_api/order"
10
10
  require_relative "bling_api/product"
11
+ require_relative "bling_api/seller"
11
12
 
12
13
  module BlingApi
13
14
  class Error < StandardError; 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.11
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-14 00:00:00.000000000 Z
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.4.6
83
+ rubygems_version: 3.5.3
83
84
  signing_key:
84
85
  specification_version: 4
85
86
  summary: ''