Skip to content

Instantly share code, notes, and snippets.

@Lunberg88
Created August 20, 2020 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lunberg88/95608061445348b6313c4eedd39b26f8 to your computer and use it in GitHub Desktop.
Save Lunberg88/95608061445348b6313c4eedd39b26f8 to your computer and use it in GitHub Desktop.
this.post(`${config.bookingApi}/ManageBooking/GetBooking`, booked, {
dataTransformer: ({data}) => {
console.log('transformer.data.response', data);
let customer = {
id: 1,
...data.bookerProfile,
...data.bookerProfile.address,
email: data.bookerProfile.email.address,
mobilePhone: data.bookerProfile.phone.countryCode.concat(' ', data.bookerProfile.phone.number)
};
let checkout = [];
let totalPrices = [];
data.accommodationBooking.roomConfigurations.forEach((room, i) => {
let checkoutItem = {
...room,
configurationId: i + 1,
guests: room.paxes.map((pax) => {
return {
id: i + 1,
...pax,
...pax.customer,
type: pax.ageGroupTypeID,
}
}),
specialWishes: room.specialRequests
};
totalPrices.push(room.totalPrice);
checkout.push(checkoutItem);
});
return {
customer: customer,
checkout: checkout,
totalPrices: totalPrices,
voucher: {id: 1, quantity: 100}
};
},
persistBy: 'insertOrUpdate'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment