bling_api 0.1.0 → 0.1.2

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: '048de75fb5cc935a0ed4c2b4708ff9c9f9603bfdd8f96442035e351eaf2b8ead'
4
- data.tar.gz: 75904baa8b3aea1339d73d663adef8518d60a3ecb9dafa07740a855b79113c6b
3
+ metadata.gz: a04a4dbf899a435d7d09f1c723c9b8f99c46bcf25c683a1c43278f26adc8979c
4
+ data.tar.gz: 7e61054450432223a0b236fb748d6c3cacd5e2f037139457ee41ba7ac351b565
5
5
  SHA512:
6
- metadata.gz: 6231c38d87ac59d1809c6fb346a6a4fe992c73480f8cbd8179c76934327b38e02524e1e77a083b66309e2e4141fb3a55ce551bcb17e8473541feefc3c1d6615b
7
- data.tar.gz: 3cc354154211ee42fd8abc69316ed7837be5f8762a8368b7c0c07b4ca55a82158b1c203e3f74aa0df4fdda9f5f57af20c8f61ff46f5512eeb621de918dd24233
6
+ metadata.gz: 844634140d72199434e0d45e361c4caf04002919e3f93de902f57184958b64be082826d5a6431001947cb67bbad2f2b885eed1ebbb3a37fc026bca012a14759b
7
+ data.tar.gz: 7e2dd2c44f166405543d8bbb719dc4584bb25a96daf5e2091df78930f0a5a44548134339e8b7d98ebfa300676891dea196a1840576282965efff453c21ab249d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bling_api (0.1.0)
4
+ bling_api (0.1.2)
5
5
  ac
6
6
  base64
7
7
 
@@ -32,6 +32,7 @@ GEM
32
32
  ethon (>= 0.9.0)
33
33
 
34
34
  PLATFORMS
35
+ arm64-darwin-22
35
36
  x86_64-linux
36
37
 
37
38
  DEPENDENCIES
@@ -1,17 +1,16 @@
1
1
  module BlingApi
2
2
  class Customer
3
- ACCESS_TOKEN = "0039bb7d2d3e3c6777983361204dc168ecbf1ef8"
4
3
 
5
4
  def self.find_by_tax_id tax_id
6
- response_json = Client.new(ACCESS_TOKEN).find_contact_by_document_number(tax_id)
5
+ response_json = Client.new(BlingApi.access_token).find_contact_by_document_number(tax_id)
7
6
  if response_json
8
- contact = Client.new(ACCESS_TOKEN).get_contact(response_json["id"])
7
+ contact = Client.new(BlingApi.access_token).get_contact(response_json["id"])
9
8
  new(**build_hash(contact))
10
9
  end
11
10
  end
12
11
 
13
12
  def self.find_by_id id
14
- contact = Client.new(ACCESS_TOKEN).get_contact(id)
13
+ contact = Client.new(BlingApi.access_token).get_contact(id)
15
14
  new(**build_hash(contact))
16
15
  end
17
16
 
@@ -67,12 +66,12 @@ module BlingApi
67
66
  instance_variable_set("@#{key}", value)
68
67
  end
69
68
  end
70
- Client.new(ACCESS_TOKEN).update_contact(id, JSON.dump(build_json))
69
+ Client.new(BlingApi.access_token).update_contact(id, JSON.dump(build_json))
71
70
  self.class.find_by_id(self.id)
72
71
  end
73
72
 
74
73
  def create
75
- response = Client.new(ACCESS_TOKEN).create_contact(JSON.dump(build_json))
74
+ response = Client.new(BlingApi.access_token).create_contact(JSON.dump(build_json))
76
75
  self.class.find_by_id(response["id"])
77
76
  end
78
77
 
@@ -1,9 +1,8 @@
1
1
  module BlingApi
2
2
  class Order
3
- ACCESS_TOKEN = "0039bb7d2d3e3c6777983361204dc168ecbf1ef8"
4
3
 
5
4
  def self.find_by_id id
6
- response = Client.new(ACCESS_TOKEN).get_order(id)
5
+ response = Client.new(BlingApi.access_token).get_order(id)
7
6
  new(**build_hash(response))
8
7
  end
9
8
 
@@ -45,7 +44,10 @@ module BlingApi
45
44
  },
46
45
  "transporte": transporte,
47
46
  "parcelas": parcelas,
48
- "valorDesconto": valor_desconto,
47
+ "desconto": {
48
+ "valor": valor_desconto,
49
+ "unidade": "REAL"
50
+ },
49
51
  "totalProdutos": total_produtos,
50
52
  "total": total,
51
53
  "observacoes": observacoes,
@@ -57,7 +59,7 @@ module BlingApi
57
59
  end
58
60
 
59
61
  def create
60
- response = Client.new(ACCESS_TOKEN).create_order(JSON.dump(build_json))
62
+ response = Client.new(BlingApi.access_token).create_order(JSON.dump(build_json))
61
63
  self.class.find_by_id(response["id"])
62
64
  end
63
65
 
@@ -78,8 +80,7 @@ module BlingApi
78
80
  numero_pedido_compra: json_response["numeroPedidoCompra"],
79
81
  observacoes: json_response["observacoes"],
80
82
  observacoes_internas: json_response["observacoesInternas"],
81
- valor_desconto: json_response["valorDesconto"],
82
- unidade_desconto: json_response["unidadeDesconto"],
83
+ desconto: json_response["desconto"],
83
84
  id_categoria: json_response["categoria"]["id"],
84
85
  transporte: json_response["transporte"],
85
86
  id_vendedor: json_response["vendedor"]["id"]
@@ -1,9 +1,8 @@
1
1
  module BlingApi
2
2
  class Product
3
- ACCESS_TOKEN = "0039bb7d2d3e3c6777983361204dc168ecbf1ef8"
4
3
 
5
4
  def self.find_by_sku sku
6
- response_json = Client.new(ACCESS_TOKEN).find_product_by_sku(sku)
5
+ response_json = Client.new(BlingApi.access_token).find_product_by_sku(sku)
7
6
  if response_json
8
7
  new(**build_hash(response_json))
9
8
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlingApi
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/bling_api.rb CHANGED
@@ -1,30 +1,30 @@
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_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
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bling_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - caio
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2023-11-10 00:00:00.000000000 Z
@@ -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.6
81
- signing_key:
80
+ rubygems_version: 3.4.20
81
+ signing_key:
82
82
  specification_version: 4
83
83
  summary: ''
84
84
  test_files: []