Neste documento são demonstradas as formas de utilização dos endpoints de mensagem padronizada do padrão REST/JSON.

Endpoint /transactions

Submeter mensagens de inclusão/alteração em lote

POST /totvseai/standardmessage/v1/transactions?batchType={batchType}&batchUUID={batchUUID}

Onde:

  • batchType indica o tipo de lote sendo enviado. Os valores possíveis são:
    • simpleBatch: Este é o tipo default, quando o parâmetro não for informado, e indica que as transações podem ser processadas individualmente. Eventuais erros não comprometem as demais;
    • businessTransaction: indica que as transações dentro do lote devem ser processadas de forma atômica: ou processa tudo ou não aceita nenhuma. O lote pode conter mensagens de uma mesma transação e versão.
  • batchUUID: UUID gerado pela origem que será a referencia do lote. Esta informação é obrigatória quando for lote, mesmo o batchType sendo implícito.

Requisições em lote serão apenas assíncronas. Do contrário, pode acontecer timeout, prejudicando a integração. Por este motivo, se houver uma mensagem como modo de envio (deliveryType) igual a "sync", todo o lote deve ser rejeitado.

Lote de mensagens - simpleBatch
POST /totvseai/standardmessage/v1/transactions?batchUUID=f0b3695c-1efc-49f2-84a7-1eeb59c5a962	// batchType = simpleBatch é implícito

{
    "Items" : [
		{
            "Header" : {
                "UUID" : "",
                "Type" : "BusinessMessage",
                "SubType" : "event",
                "Transaction" : "customerVendor",
                "Version" : "2.001",
                "SourceApplication": "",
                "ProductName" : "",
                "ProductVersion" : "",
                "GeneratedOn" : "",
                "DeliveryType" : "async",
            },
            "Content" : {
                "Atributo1" : "",
                "Atributo2" : "",
                ...
                "AtributoN" : ""
            }
        },{
            "Header" : {
                "UUID" : "",
                ...
                "Transaction" : "customerVendor",
                "Version" : "2.001",
                ...
                "DeliveryType" : "async" 
            },
            "Content" : {
                "Atributo1" : "",
                "Atributo2" : "",
                ...
                "AtributoN" : ""
            }
        }
    ]
}
Lote de mensagens - businessTransaction
POST /totvseai/standardmessage/v1/transactions?batchType=businessTransaction&batchUUID=f0b3695c-1efc-49f2-84a7-1eeb59c5a962

{
    "Items" : [
		{
            "Header" : {
                "UUID" : "",
                "Type" : "BusinessMessage",
                "SubType" : "event",
                "Transaction" : "customerVendor",
                "Version" : "2.001",
                "SourceApplication": "",
                "ProductName" : "",
                "ProductVersion" : "",
                "GeneratedOn" : "",
                "DeliveryType" : "async",
            },
            "Content" : {
                "Atributo1" : "",
                "Atributo2" : "",
                ...
                "AtributoN" : ""
            }
        },{
            "Header" : {
                "UUID" : "",
                ...
                "Transaction" : "item",
                "Version" : "3.001",
                ...
                "DeliveryType" : "sync" // Rejeitar toda a requisição e informar que só aceita assíncrono
            },
            "Content" : {
                "Atributo1" : "",
                "Atributo2" : "",
                ...
                "AtributoN" : ""
            }
        }
    ]
}

Submeter uma única mensagem de inclusão/alteração

POST /totvseai/standardmessage/v1/transactions

Os parâmetros batchType e batchUUID não são relevantes para esta situação. Logo, se forem informados, devem ser ignorados.

POST /totvseai/standardmessage/v1/transactions/

{
    "Header" : {
        "UUID" : "",
        "Type" : "BusinessMessage",
        "SubType" : "event",
        "Transaction" : "customerVendor",
        "Version" : "2.001",
        "SourceApplication": "",
        "ProductName" : "",
        "ProductVersion" : "",
        "CompanyId" : "",
        "BranchId" : "",
        "GeneratedOn" : "",
        "DeliveryType" : "sync",
    },
    "Content" : {
        "Atributo1" : "",
        "Atributo2" : "",
        ...
        "AtributoN" : ""
    }
}

Submeter uma mensagem de eliminação

DELETE /totvseai/standardmessage/v1/transactions/
DELETE /totvseai/standardmessage/v1/transactions/
{
	"Header" : {
    	"UUID" : "",
        "Type" : "BusinessMessage",
        "SubType" : "event",
        "Transaction" : "customerVendor",
        "Version" : "2.001",
        "SourceApplication": "",
        "ProductName" : "",
        "ProductVersion" : "",
        "CompanyId" : "",
        "BranchId" : "",
        "GeneratedOn" : "",
        "DeliveryType" : "sync",
    },
    "Content" : {
        "Atributo1" : "",
        "Atributo2" : "",
        ...
        "AtributoN" : ""
    }
}

Submeter um lote de mensagens de eliminação

DELETE /totvseai/standardmessage/v1/transactions?batchType={batchType}?batchUUID={batchUUID}

A eliminação em lote utiliza o mesmo endpoint, variando apenas o corpo, onde as mensagens a eliminar estarão dentro de um array JSON. Somente mensagens assíncronas serão aceitas.

O endpoint aceita os parâmetros batchType e batchUUID, e o comportamento será o mesmo descrito para quando um lote de mensagens é submetido. Se o parâmetro batchType for omitido, deve-se assumir o valor "simpleBatch".

DELETE /totvseai/standardmessage/v1/transactions?batchUUID=f0b3695c-1efc-49f2-84a7-1eeb59c5a962

{
    "Items" : [
        {
            "Header" : {
                "UUID" : "",
                "Type" : "BusinessMessage",
                "SubType" : "event",
                "Transaction" : "customerVendor",
                "Version" : "2.001",
                "SourceApplication": "",
                "ProductName" : "",
                "ProductVersion" : "",
                "GeneratedOn" : "",
                "DeliveryType" : "async",
            },
            "Content" : {
                "Atributo1" : "",
                "Atributo2" : "",
                ...
                "AtributoN" : ""
            }
        },
        {
            "Header" : {
                "UUID" : "",
                "Type" : "BusinessMessage",
                "SubType" : "event",
                "Transaction" : "customerVendor",
                "Version" : "2.001",
                "SourceApplication": "",
                "ProductName" : "",
                "ProductVersion" : "",
                "GeneratedOn" : "",
                "DeliveryType" : "async",
            },
            "Content" : {
                "Atributo1" : "",
                "Atributo2" : "",
                ...
                "AtributoN" : ""
            }
        }
    ]
}

Entender mensagem de Erro 

Entende-se como ERRO quando transmissão e entendimento da mensagem foram realizados com sucesso, porém alguma regra de negócio no ERP receptor não foi cumprida. 

O status HTTP retornado é 200, e a mensagem de resposta encontra-se no seguinte formato:

{
    "Header" : {
        "UUID" : "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6",
        "Type" : "Response",
        "SubType" : "event",
        "Transaction" : "CostCenter",
        "Version" : "2.000",
        "SourceApplication" : "LGX12",
        "ProductName" : "LOGIX",
        "ProductVersion" : "12.1.15",
        "GeneratedOn" : "2017-11-14T11:47:15-03:00",
        "DeliveryType": "async"
    },
    "Content" : {
        "ReceivedMessage" : {
            "UUID" : "d6bbfa63-ca27-e2ac-0b14-101970f59a5b",
            "SentBy" : "P1299",
            "Event" : "upsert"        
        },
        "ProcessingInformation" : {
            "ProcessedOn" : "2017-11-14T11:47:15-03:00",
            "Status" : "ERROR",
            "Details" : [
                {
                    "Code" : "FE001",
                    "Message" : "Mensagem padrão no formato incorreto.",
                    "DetailedMessage" : "",
					"HelpUrl": "http://tdn.totvs.com" 
                },
                {
                    "Code" : "AE004",
                    "Message" : "Empresa não configurada para integração.",
                    "DetailedMessage" : "",
					"HelpUrl": "http://tdn.totvs.com" 
                }
            ]
        },
        "ReturnContent" : {            
            "ListOfInternalID" : [
                {
                    "Name" : "CostCenter",
                    "Origin" : "99|ABC001",
                    "Destination" : "10|1000"
                },
                {
                    "Name" : "Company",
                    "Origin" : "99",
                    "Destination" : "10"
                }
            ]
        }
    }
}


Entender mensagem de Falha

Entende-se como FALHA quando transmissão e entendimento da mensagem não puderam ser realizados. 

Isso pode ocorrer devido aos seguintes motivos:

  • Configuração do EAI está incorreta ou incompleta
  • Estrutura da mensagem recebida está incorreta ou incompleta

O status HTTP retornado é 500, e a mensagem de resposta encontra-se no seguinte formato:

{
    "Code" : "FE001",
    "Message" : "Mensagem padrão no formato incorreto.",
    "DetailedMessage" : "",
	"HelpUrl": "http://tdn.totvs.com" 
}



  • Sem rótulos