-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCEP2.PRW
48 lines (30 loc) · 1.34 KB
/
CEP2.PRW
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#Include 'Protheus.ch'
#Include 'FWMVCDEF.ch'
#Include 'RestFul.CH'
/***********************
+-------------------------------------------------------------------------+
|Funcao | ConsLink | Autor | João Victor Rodrigues |
+------------+------------------------------------------------------------+
|Data | 07.01.2022 |
+------------+------------------------------------------------------------+
|Descricao | Retorna a consulta dos dados do link criado |
**************************/
User Function RetCont()
Local cConteud := ""
cConteud := U_lercep("50791100", 2)
Return
User function lercep(cCep, nPos)
aInfo := ConsLink(cCep)
return aInfo[1,nPos]
static Function ConsLink(cCep)
Local oRest := FWRest():New("https://viacep.com.br")
Local oJson := JSonObject():New()
Local aTeste := {}
oRest:setPath("/ws/"+cCep+"/json/")
oRest:GET()
cErro := oJSon:fromJson(decodeUtf8(oRest:GetResult()))
If !empty(cErro)
Return
Endif
aAdd(aTeste, {oJson:GetJSonObject('cep'), oJson:GetJSonObject('logradouro'),oJson:GetJSonObject('complemento'),oJson:GetJSonObject('bairro'),oJson:GetJSonObject('localidade'),oJson:GetJSonObject('uf'),oJson:GetJSonObject('ibge'),oJson:GetJSonObject('gia'),oJson:GetJSonObject('ddd'),oJson:GetJSonObject('siafi')})
Return aTeste