tiny_erp_api 0.1.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiny_erp_api/client.rb +10 -10
- data/lib/tiny_erp_api/order.rb +1 -1
- data/lib/tiny_erp_api/seller.rb +3 -3
- data/lib/tiny_erp_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e30fb0ea25eb461c8f30fbcfadf024060ab30133c4e6ffcfcc5efe4f2ed4475
|
4
|
+
data.tar.gz: ea1fe6ea157cc34ef811ddd62f73b391e31fe9dc80d3cd98a6ee19a3e9a3052a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0ef8b128ade2d05457ba54abbd8620be21476ecde589b55e4475763596f87c027bbd00f48e4000946c0c12d6ed34ef71bbe3ae673f6317a83db5b9711b676ed
|
7
|
+
data.tar.gz: 5441effde03400cbb2d2bd5382ba882b6f934afcaca333791006db4e384f37732c2eb5ac12df79376d2263707b0901ed2c513ed3a0f6732055c9f1da9c913533
|
data/lib/tiny_erp_api/client.rb
CHANGED
@@ -13,64 +13,64 @@ module TinyErpApi
|
|
13
13
|
def get_contact_by_document(document_number)
|
14
14
|
params = "#{@query_params}&cnpj_cpf=#{document_number}"
|
15
15
|
response = get("/contatos.pesquisa.php?#{params}")
|
16
|
-
response.json
|
16
|
+
response.json.dig("retorno","contatos",0,"contato")
|
17
17
|
end
|
18
18
|
|
19
19
|
def get_contact_by_id(contact_id)
|
20
20
|
params = "#{@query_params}&id=#{contact_id}"
|
21
21
|
response = get("/contato.obter.php?#{params}")
|
22
|
-
response.json
|
22
|
+
response.json.dig("retorno","contato")
|
23
23
|
end
|
24
24
|
|
25
25
|
def create_contact(contact)
|
26
26
|
params = "#{@query_params}&contato=#{URI.encode_www_form_component(contact.to_json)}"
|
27
27
|
response = post("/contato.incluir.php?#{params}")
|
28
|
-
response.json
|
28
|
+
response.json.dig("retorno","registros",0,"registro")
|
29
29
|
end
|
30
30
|
|
31
31
|
def update_contact(contact_id)
|
32
32
|
params = "#{@query_params}&contato=#{contact_id}"
|
33
33
|
response = post("/contato.alterar.php?#{params}")
|
34
|
-
response.json
|
34
|
+
response.json.dig("retorno","registros",0,"registro")
|
35
35
|
end
|
36
36
|
|
37
37
|
# Sellers
|
38
38
|
def get_sellers(page = 1)
|
39
39
|
params = "#{@query_params}&pagina=#{page}pesquisa="
|
40
40
|
response = post("/vendedores.pesquisa.php?#{params}")
|
41
|
-
response.json
|
41
|
+
response.json.dig("retorno")
|
42
42
|
end
|
43
43
|
|
44
44
|
def get_seller_by_name(seller_name)
|
45
45
|
params = "#{@query_params}&pesquisa=#{URI.encode_www_form_component(seller_name)}"
|
46
46
|
response = post("/vendedores.pesquisa.php?#{params}")
|
47
|
-
response.json
|
47
|
+
response.json.dig("retorno","vendedores",0,"vendedor")
|
48
48
|
end
|
49
49
|
|
50
50
|
# Products
|
51
51
|
def get_product_by_sku(sku)
|
52
52
|
params = "#{@query_params}&pesquisa=#{URI.encode_www_form_component(sku)}"
|
53
53
|
response = post("/produtos.pesquisa.php?#{params}")
|
54
|
-
response.json
|
54
|
+
response.json.dig("retorno","produtos",0, "produto")
|
55
55
|
end
|
56
56
|
|
57
57
|
def get_product_by_id(product_id)
|
58
58
|
params = "#{@query_params}&id=#{product_id}"
|
59
59
|
response = post("/produto.obter.php?#{params}")
|
60
|
-
response.json
|
60
|
+
response.json.dig("retorno", "produto")
|
61
61
|
end
|
62
62
|
|
63
63
|
# Orders
|
64
64
|
def get_order_by_id(order_id)
|
65
65
|
params = "#{@query_params}&id=#{order_id}"
|
66
66
|
response = post("/pedido.obter.php?#{params}")
|
67
|
-
response.json
|
67
|
+
response.json.dig("retorno", "pedido")
|
68
68
|
end
|
69
69
|
|
70
70
|
def create_order(order)
|
71
71
|
params = "#{@query_params}&pedido=#{URI.encode_www_form_component(JSON.dump(order))}"
|
72
72
|
response = post("/pedido.incluir.php?#{params}")
|
73
|
-
response.json
|
73
|
+
response.json.dig("retorno", "registros", "registro")
|
74
74
|
end
|
75
75
|
|
76
76
|
|
data/lib/tiny_erp_api/order.rb
CHANGED
@@ -32,7 +32,7 @@ module TinyErpApi
|
|
32
32
|
|
33
33
|
def create
|
34
34
|
response = Client.new(TinyErpApi.configuration.access_token).create_order(build_json)
|
35
|
-
self.class.find_by_id(response
|
35
|
+
self.class.find_by_id(response.dig("id"))
|
36
36
|
end
|
37
37
|
|
38
38
|
def build_json
|
data/lib/tiny_erp_api/seller.rb
CHANGED
@@ -23,8 +23,8 @@ module TinyErpApi
|
|
23
23
|
def self.get_all
|
24
24
|
response_json = Client.new(TinyErpApi.configuration.access_token).get_sellers
|
25
25
|
sellers = response_json["vendedores"]
|
26
|
-
if response_json["numero_paginas"] > 1
|
27
|
-
(2..response_json["numero_paginas"]).each do |page|
|
26
|
+
if response_json["numero_paginas"].to_i > 1
|
27
|
+
(2..response_json["numero_paginas"].to_i).each do |page|
|
28
28
|
response_json = Client.new(TinyErpApi.configuration.access_token).get_sellers(page)
|
29
29
|
sellers >> response_json["vendedores"]
|
30
30
|
end
|
@@ -79,4 +79,4 @@ module TinyErpApi
|
|
79
79
|
}
|
80
80
|
end
|
81
81
|
end
|
82
|
-
end
|
82
|
+
end
|
data/lib/tiny_erp_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_erp_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamilton Tumenas Borges
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ac
|