tiny_erp_api 0.1.6 → 0.1.7

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: adf612cd76206a2d6b1388fd3c4afce5e73ca62c90d75a49eb7ba39931f336e4
4
- data.tar.gz: 9a769eb5476c0940e32df04df0cb4d9666cc2bd44fcabf051c356a89d4d44bcc
3
+ metadata.gz: 8fc6aa7487ddfbb1254cf3f3d139f6b3146707c3b14c716952473db621b6ac3d
4
+ data.tar.gz: bde6e3f169d7df65321d4ab166db5c3627c43621c442749385cb0b4608adbd79
5
5
  SHA512:
6
- metadata.gz: c00baa67d0fa9f567d574d89f1b44b4665c608ce9ff73eadcc1660cb48081b4a91dbe13a8139a39e969e03369954646f6a853b0de6a0d8be5a02688579915ef8
7
- data.tar.gz: eaaa61df9c3864fe67288ae0a8e82699038300ed40e730b8d39a25027d209a6867525496fb68c2b4a7dd7f32055c53491f2c84ef85de1e84d84382765201d532
6
+ metadata.gz: 88bdc3da6fed1c75103c3e048b66cc1449b953694b8941aaf4a0005ad5e833c9c3dcb22a720bafd141aa0798aa8581736ec26fe4b0ca7d30ceac69df0466c657
7
+ data.tar.gz: b8fff99625e2cc64c1aac89de6538be9e0276c504fcfb4d4954ce827067f2b9ba94f1eddf605e602eda2f94078996c2e7377dcab8512dc5ecc6ac539c291d80c
@@ -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["retorno"]["contatos"][0]
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["retorno"]["contato"]
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["retorno"]["registros"][0]["registro"]
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["retorno"]["registros"][0]["registro"]
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["retorno"]
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["retorno"]["vendedores"][0]["vendedor"]
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["retorno"]["produtos"][0]
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["retorno"]["produto"]
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["retorno"]["pedido"]
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["retorno"]["registros"][0]["registro"]
73
+ response.json.dig("retorno", "registros", "registro")
74
74
  end
75
75
 
76
76
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TinyErpApi
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_erp_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamilton Tumenas Borges