Neste documento são demonstradas as formas de utilização dos endpoints de mensagem padronizada do padrão REST/JSON.
POST /totvseai/standardmessage/v1/transactions?batchType={batchType}&batchUUID={batchUUID}
Onde:
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.
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" : "" } } ] }
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" : "" } } ] }
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" : "" } }
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" : "" } }
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" : "" } } ] }
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" } ] } } }
Entende-se como FALHA quando transmissão e entendimento da mensagem não puderam ser realizados.
Isso pode ocorrer devido aos seguintes motivos:
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" }