bling_api 0.1.12 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a9b0f526f08f2c5b00645fe1a2e3cdb0e76391af1c2e932a3d0114d2f167e48
4
- data.tar.gz: f2a89160bf223a8b706019331f2d4fc173afa38b0d9093ebc0c4b44e7e1598c4
3
+ metadata.gz: 9b555184d85bd2868cae8cf4e87a26a11cecd56985e36036c85c42238e1e9f7e
4
+ data.tar.gz: 192812d80aed357f1011193abc56e6593fbeaf63222a6e59f0bd6d7c56b1329b
5
5
  SHA512:
6
- metadata.gz: e7b5e8cccc865d8a8dbc208259d94670bcfe52ea085282750780b81ca0a9bfe8799146d52c793d447cf035689a36692869e1f2dfa9adcc6fbc3c20ad0113db55
7
- data.tar.gz: 9a7b51430e21382ff55966ff1fa3bb060d433f32a995a130b24a0748ba6eade0ed46f0d9a968bf9fdc09517df4bb4b7eb8240282e2d40428c9146acca3071cd3
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
@@ -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.12"
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.12
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: ''