in src/libs/salesforce.ts [100:145]
async function runPhoneBookQuery(
bearerInformation: SalesforceBearerInformation,
): Promise<PhoneBookQueryAnswerData> {
console.log('Running phone book query');
const query =
"SELECT Name, Buyer__r.IdentityID__c, Buyer__r.Phone FROM SF_Subscription__c WHERE Product__c = 'Newspaper - National Delivery'";
const url = `${
bearerInformation.instance_url
}/services/data/v46.0/query/?q=${encodeURIComponent(query)}`;
console.log(url);
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${bearerInformation.access_token}`,
},
});
/*
response.data is a
{
"totalSize": 131,
"done": true,
"records": Item[]
}
where:
Item =
{
"attributes": {
"type": "SF_Subscription__c",
"url": "/services/data/v46.0/sobjects/SF_Subscription__c/a2F9E000007TOk3UAG"
},
"Name": "A-S00648323",
"Buyer__r": {
"attributes": {
"type": "Contact",
"url": "/services/data/v46.0/sobjects/Contact/0039E00001nw7LKQAY"
},
"IdentityID__c": "200138950",
"Phone": null
}
}
*/
return (await response.json()) as PhoneBookQueryAnswerData;
}