in src/libs/zuora.ts [292:322]
async function jobIdToFileId(
stage: string,
zuoraBearerToken: string,
jobId: string,
date: string,
): Promise<ZuoraDataFileIds> {
// Data retrieval from Zuora work like this:
// 1. We submit a job to Zuora with submitQueryToZuora
// 2. We get an answer that carries an id that we call the jobId.
// 3. We probe the server with checkJobStatus *until* we get a ZuoraBatchJobStatusReceipt with status: true
// 4. That ZuoraBatchJobStatusReceipt will also have a fileId
// 5. The fileId can be used to retrive the file using readDataFileFromZuora
// This function essentially perform 3, notably querying the server *until* we get a positive ZuoraBatchJobStatusReceipt
// It takes the jobId and returns the fileId
while (true) {
console.log(`date: ${date}; jobId: ${jobId}; awaiting for fileId`);
const receipt = await checkJobStatus(
stage,
zuoraBearerToken,
jobId,
date,
);
console.log(`date: ${date}; receipt: ${JSON.stringify(receipt)}`);
if (receipt.status) {
return Promise.resolve(receipt); // The receipt is obtained as a ZuoraBatchJobStatusReceipt and returned as as ZuoraDataFileIds
}
await sleep(10 * 1000); // sleeping for 10 seconds
}
}