refactor(pdfgeneration): Switch to new document-server api
Some checks failed
ci/woodpecker/push/build Pipeline failed
Some checks failed
ci/woodpecker/push/build Pipeline failed
This commit is contained in:
@@ -78,6 +78,53 @@ class DocumentServer {
|
||||
const blob = await response.blob();
|
||||
return blob;
|
||||
}
|
||||
|
||||
async generateCertificates(runners: any[], locale: string) {
|
||||
const generateRunners = new Array<any>();
|
||||
|
||||
for (let i = 0; i < runners.length; i++) {
|
||||
const certificate = {
|
||||
id: runners[i].id,
|
||||
first_name: runners[i].firstname,
|
||||
middle_name: runners[i].middlename,
|
||||
last_name: runners[i].lastname,
|
||||
group: {
|
||||
id: runners[i].group.id,
|
||||
name: runners[i].group.name,
|
||||
},
|
||||
distance: runners[i].distance,
|
||||
distance_donations: runners[i].distanceDonations.map((distanceDonation: any) =>{
|
||||
return {
|
||||
id: distanceDonation.id,
|
||||
amount: distanceDonation.amount,
|
||||
amount_per_distance: distanceDonation.amountPerDistance,
|
||||
donor: {
|
||||
id: distanceDonation.donor.id,
|
||||
first_name: distanceDonation.donor.firstname,
|
||||
middle_name: distanceDonation.donor.middlename,
|
||||
last_name: distanceDonation.donor.lastname,
|
||||
}
|
||||
}
|
||||
}),
|
||||
}
|
||||
generateRunners.push(certificate)
|
||||
|
||||
}
|
||||
|
||||
const response = await fetch(`${this.baseUrl}/v1/pdfs/certificates?key=${this.apiKey}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
locale,
|
||||
runners: generateRunners,
|
||||
}),
|
||||
});
|
||||
|
||||
const blob = await response.blob();
|
||||
return blob;
|
||||
}
|
||||
}
|
||||
|
||||
export default DocumentServer;
|
||||
Reference in New Issue
Block a user