Integration Template formats and transfers Teamogy's raw internal data object into the format required by the counterparty. It is always advisable to use Integration Template, it is not advisable to transfer the raw internal format. Should there be a change in the internal format, Teamogy guarantees the datafix of all Template integrations so that the final output format remains fully functional. However, if Teamogy raw internal format is used directly for integration, each time a change (Teamogy version) is made, it would be necessary to fix the integration at the counterparty.
Example - Teamogy internal data object format:
"input":{
"id": 123,
"name": "Teamogy",
"address": {
"zip": "15500",
"city": "Prague 5",
"state": "",
"street": "Bavorská 14",
"country": "CZ"
}
}
Example - formatting Teamogy internal format into the required counterparty JSON data object
{
"companyId": "${currentObject:input.id}",
"companyName": "${currentObject:input.name}",
"addressZip": "${currentObject:input.address.zip}",
"addressCity": "${currentObject:input.address.city}",
"addressStreet": "${currentObject:input.address.street}",
"addressCountry": "${currentObject:input.address.country}"
}
Example - formatting Teamogy internal format into the required counterparty XML data object
<?xml version="1.0" encoding="UTF-8"?>
<company id="${currentObject:input.id}">
<name>${currentObject:input.name}</name>
<address>
<street>${currentObject:input.address.street}</street>
<city>${currentObject:input.address.city}</city>
<zip>${currentObject:input.address.zip}</zip>
<country>${currentObject:input.address.country}</country>
<state>${currentObject:input.address.state}</state>
</address>
</company>
Translation of keywords using a translation dictionary
Usually, Teamogy key terms need to be translated into the key terms of the counterparty API.
Example:
The sales invoice types in Teamogy are as follows:
- INVOICE.SALES
- INVOICE.SALES.PROFORMA
- INVOICE.SALES.PREPAYMENT
- INVOICE.SALES.CORRECTION
The types of the same invoices in the counterparty system are as follows:
- issuedInvoice
- issuedProformaInvoice
- issuedAdvanceInvoice
- issuedCorrectiveTax
To translate these keywords, we will use the translation dictionary stored in the DICTIONARY-CUSTOM registry, which will have the following form:
{
"str": {
"type": {
"INVOICE.SALES": "issuedInvoice",
"INVOICE.SALES.PROFORMA": "issuedProformaInvoice",
"INVOICE.SALES.PREPAYMENT": "issuedAdvanceInvoice",
"INVOICE.SALES.CORRECTION": "issuedCorrectiveTax",
}
},
"regex": {
"baseType": [
{
"if": ".*\\bSALES\\b.*",
"then": "SALES"
},
{
"if": ".*\\bPURCHASE\\b.*",
"then": "PURCHASE"
}
]
}
}
The keyword translations in the Integration Template will then be used as follows:
...
"typeTranslated": "${strTranslate:${currentObject:input.type},type,DICTIONARY-CUSTOM}",
"baseTranstaled": "${regexTranslate:${currentObject:input.type},baseType,DICTIONARY-CUSTOM}"
...
The resulting format of the request using the translation dictionary if the input type is "INVOICE.SALES" will be as follows:
...
"typeTranslated": "issuedInvoice",
"baseTranstaled": "SALES"
...
Entities containing an array of items / item grid
An example of an itemized document is an invoice. Each invoice has several tables on it and each table contains a number of rows (invoice items). In order to build such itemized documents using the Integration Template, you need to use the forEach / forEachJson function, which is used as follows.
Example
Teamogy raw internal data object snippet:
...
"items": [
{
"rowNumber": 1,
"name": "First item",
"billingAmount": 150,
"vatPercentage": 20,
"currency": "EUR"
},
{
"rowNumber": 2,
"name": "Second item",
"billingAmount": 150,
"vatPercentage": 20,
"currency": "EUR"
}
],
...
Teamogy Integration Template snippet - will use INTEGRATION.TEMPLATE.SUB-INVOICE.ITEM
...
"invoiceItems": "#[forEachJson:input.items,INTEGRATION.TEMPLATE.SUB-INVOICE.ITEM]#",
...
Teamogy Integration Template INTEGRATION.TEMPLATE.SUB-INVOICE.ITEM snippet:
{
"itemRow": "${currentObject:rowNumber}",
"itemName": "${currentObject:name}",
"itemAmount": "${currentObject:billingAmount}",
"itemVat": "${currentObject:vatPercentage}",
"itemCurrency": "${currentObject:currency}"
}
Example output:
...
"invoiceItems": [
{
"itemRow": 1,
"itemName": "First item",
"itemAmount": 150,
"itemVat": 20,
"itemCurrency": "EUR"
},
{
"itemRow": 2,
"itemName": "Second item",
"itemAmount": 150,
"itemVat": 20,
"itemCurrency": "EUR"
}
],
...