tiny_erp_api 0.1.6 → 0.1.7
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/lib/tiny_erp_api/client.rb +10 -10
- data/lib/tiny_erp_api/seller.rb +3 -3
- data/lib/tiny_erp_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fc6aa7487ddfbb1254cf3f3d139f6b3146707c3b14c716952473db621b6ac3d
|
4
|
+
data.tar.gz: bde6e3f169d7df65321d4ab166db5c3627c43621c442749385cb0b4608adbd79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88bdc3da6fed1c75103c3e048b66cc1449b953694b8941aaf4a0005ad5e833c9c3dcb22a720bafd141aa0798aa8581736ec26fe4b0ca7d30ceac69df0466c657
|
7
|
+
data.tar.gz: b8fff99625e2cc64c1aac89de6538be9e0276c504fcfb4d4954ce827067f2b9ba94f1eddf605e602eda2f94078996c2e7377dcab8512dc5ecc6ac539c291d80c
|
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/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