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 +4 -4
- data/Gemfile.lock +2 -1
- data/lib/bling_api/customer.rb +5 -6
- data/lib/bling_api/order.rb +7 -6
- data/lib/bling_api/product.rb +1 -2
- data/lib/bling_api/version.rb +1 -1
- data/lib/bling_api.rb +30 -30
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a04a4dbf899a435d7d09f1c723c9b8f99c46bcf25c683a1c43278f26adc8979c
|
4
|
+
data.tar.gz: 7e61054450432223a0b236fb748d6c3cacd5e2f037139457ee41ba7ac351b565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 844634140d72199434e0d45e361c4caf04002919e3f93de902f57184958b64be082826d5a6431001947cb67bbad2f2b885eed1ebbb3a37fc026bca012a14759b
|
7
|
+
data.tar.gz: 7e2dd2c44f166405543d8bbb719dc4584bb25a96daf5e2091df78930f0a5a44548134339e8b7d98ebfa300676891dea196a1840576282965efff453c21ab249d
|
data/Gemfile.lock
CHANGED
data/lib/bling_api/customer.rb
CHANGED
@@ -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(
|
5
|
+
response_json = Client.new(BlingApi.access_token).find_contact_by_document_number(tax_id)
|
7
6
|
if response_json
|
8
|
-
contact = Client.new(
|
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(
|
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(
|
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(
|
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
|
|
data/lib/bling_api/order.rb
CHANGED
@@ -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(
|
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
|
-
"
|
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(
|
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
|
-
|
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"]
|
data/lib/bling_api/product.rb
CHANGED
@@ -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(
|
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
|
data/lib/bling_api/version.rb
CHANGED
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.
|
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.
|
81
|
-
signing_key:
|
80
|
+
rubygems_version: 3.4.20
|
81
|
+
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: ''
|
84
84
|
test_files: []
|