Created
January 15, 2019 12:47
-
-
Save danielAlbuquerque/0cc1b6a779bf0d0041cdb5e0ed2a99dd to your computer and use it in GitHub Desktop.
Exemplo de integracao com a INTELIPOST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include 'totvs.ch' | |
#include "TBICONN.CH" | |
// EXEMPLO DE CHAMADA DA FUNCAO | |
User Function Intel01tst() | |
Local oPedidoEnvio, cPed, oVolume | |
Local aItens := {} | |
PREPARE ENVIRONMENT EMPRESA "01" FILIAL "0103" USER "ADMIN" PASSWORD "589@corp" MODULO "FAT" | |
cPed := "000131" | |
oPedidoEnvio := Intelipost():new(cPed, '20180901')// numero pedido, data envio | |
// Montagem do volume que sera enviado | |
oVolume := JsonObject():new() | |
oVolume['tracking_code'] := "12345678BR" // codigo de rastreio | |
oVolume['products_quantity'] := 1 // quantidades de itens dentro do volume | |
oVolume['width'] := 10 // largura | |
oVolume['height'] := 10 // altura | |
oVolume['length'] := 10 // comprimento | |
// pode adicionar mais de 1 volume | |
oPedidoEnvio:addVolume( oVolume ):save() | |
// validacao do retorno da api | |
if !oPedidoEnvio:lTudoOk | |
alert(oPedidoEnvio:cMsgError) | |
Return .F. | |
EndIf | |
alert("Enviado com sucesso") | |
RESET ENVIRONMENT | |
Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment