Skip to content

Instantly share code, notes, and snippets.

@Lunberg88
Last active August 20, 2020 14:17
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/755a34d89af918b8ce7d7a81f4df3bcd to your computer and use it in GitHub Desktop.
Save Lunberg88/755a34d89af918b8ce7d7a81f4df3bcd 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)
};
data.accommodationBooking.roomConfigurations.forEach((room, i) => {
let checkoutItem = {
id: i + 1,
...room,
configurationId: i + 1
};
//Checkout
Checkout.insertOrUpdate({
data: checkoutItem
});
//TotalPrices
TotalPrice.insertOrUpdate({
data: {
id: i + 1,
...room.totalPrice
}
});
//SpecialWishes
SpecialWish.insertOrUpdate({
data: {
checkoutId: i + 1,
...room.specialRequests
}
});
// CustomerGuests
room.paxes.forEach((pax) => {
CustomerGuest.insertOrUpdate({
data: {
id: i + 1,
...pax,
...pax.customer,
type: pax.ageGroupTypeID
}
});
});
});
//Vouchers
Voucher.insertOrUpdate({
data: data.vouchers
});
return {
customer: customer
};
},
persistBy: 'insertOrUpdate'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment