show me final format of request and response body this rute takes and returns…
- User
show me final format of request and response body this rute takes and returns exports.connect = async (req, res) => { const request = req.body.data; const client = new ET_Client(request.clientId, request.clientSecret, request.origin.split('.')[1], {origin: request.origin, authOrigin: request.authOrigin, soapOrigin: request.soapOrigin, authOptions : { authVersion: 2, accountId: request.mid , scope: ''}}); sendMcQuery();
function sendMcQuery() { const deRow = client.dataExtensionRow({ Name: DE_NAME, props: props });
logger.info(JSON.stringify(props)) deRow.get((err, response) => { if (err) { logger.info(JSON.stringify(err)) if (err.message === 'The Request Property(s) customDomain do not match with the fields of DataExtensionObject retrieve') { props = ['apiKey', 'baseUrl', 'smsSenderName', 'viberSenderName', 'smsWebhook', 'omniWebhook', 'kakaoSenderName']; sendMcQuery(); } else if (JSON.stringify(err.message) === 'Data extention does not exist') { res.status(200).send('empty'); } else { res.status(200).send(err.message); } } else { let buildResult = []; props = ['apiKey', 'baseUrl', 'customDomain', 'smsSenderName', 'viberSenderName', 'smsWebhook', 'omniWebhook', 'kakaoSenderName']; for (const result of response.body.Results) { for (const property of result.Properties.Property) { buildResult.push(property) } } logger.info(JSON.stringify(buildResult)) buildResult.forEach((item) => { if (item['Name'] === 'apiKey') { const aes = new AesEncryption() aes.setSecretKey(process.env.Secret); let apiWithNonce = item['Value']; apiWithNonce = apiWithNonce.slice(24, apiWithNonce.length) const decrypted = aes.decrypt(apiWithNonce); console.log(decrypted) item['Value'] = decrypted; } }); res.status(200).send(buildResult); } });} }
- Assistant
Request Body:
{ "data": { "clientId": "your_client_id", "clientSecret": "your_client_secret", "origin": "https://example.com", "authOrigin": "https://auth.example.com", "soapOrigin": "https://soap.example.com", "mid": "your_mid" } }
Response Body:
If successful:
[{ "Name": "property_name", "Value": "property_value", "IsPrimaryKey": false, "IsRequired": false, "MaxLength": 50, "Ordinal": 0, "ObjectID": "", "Client": "", "PartnerKey": "", "ModifiedDate": "", "CreatedDate": "" }, { "Name": "another_property", "Value": "another_value", "IsPrimaryKey": false, "IsRequired": false, "MaxLength": 50, "Ordinal": 0, "ObjectID": "", "Client": "", "PartnerKey": "", "ModifiedDate": "", "CreatedDate": "" } ]
If there is an error:
{"message": "error message"}