Customer Data
Use DOM Package helpers for profile, order, booking, enquiry, receipt, and company data
Customer Data
After a customer signs in, the DOM Package can call Client API endpoints on their behalf. These helpers add the authentication headers and handle token refresh automatically.
Updating the Customer Profile
await auth.updateProfile({
firstName: 'John',
lastName: 'Smith',
phone: '+1234567890',
});This calls the Update Profile endpoint under the hood.
Profile photos can be passed as a hosted URL, a browser File or Blob, or a data:image/... or blob:... URI.
const file = fileInput.files?.[0];
if (file) {
await auth.updateProfile({
profilePhoto: file,
});
}You can also upload only the profile photo:
await auth.uploadProfilePhoto(file);When a file or blob is provided, the SDK requests a secure upload URL, uploads the image to Tiquo storage, then saves the resulting image URL on the authenticated customer's profile.
Fetching Customer Data
The SDK provides convenience methods for the Client API list endpoints:
// Get order history
const orders = await auth.getOrders();
// Get booking history
const bookings = await auth.getBookings();
// Get upcoming bookings only
const upcoming = await auth.getUpcomingBookings();
// Get enquiry history
const enquiries = await auth.getEnquiries();
// Get companies the customer belongs to
const companies = await auth.getCompanies();Receipts
Use getReceipt() to retrieve a printable receipt payload for an order owned by the authenticated customer.
const receipt = await auth.getReceipt('order_123');Receipts are available for orders that have been paid, refunded, or completed. Draft and pending orders do not have customer receipts yet.
Booking Tickets
Bookings include a ticketing object when ticket settings are available for the booking's sublocation.
const { bookings } = await auth.getUpcomingBookings();
const booking = bookings[0];
if (booking?.ticketing.qrCodeTicketsEnabled) {
const ticketPdf = await auth.downloadBookingTicket(booking.id);
}When wallet tickets are enabled, the booking also includes wallet links:
const walletUrl = booking.ticketing.walletTicketUrl;
const appleWalletUrl = booking.ticketing.appleWalletTicketUrl;
const googleWalletUrl = booking.ticketing.googleWalletTicketUrl;Company Memberships
Use getCompanies() to show the authenticated customer's company memberships.
const { companies } = await auth.getCompanies();
for (const company of companies) {
console.log(company.name, company.membership.relationship);
}Each company includes the customer's membership details, including whether the customer is a company admin.
Company admins can call getCompanyColleagues() to retrieve basic contact-card information for colleagues in the same company.
const company = companies.find((item) => item.membership.isCompanyAdmin);
if (company) {
const { colleagues } = await auth.getCompanyColleagues(company.id);
console.log(colleagues);
}If the authenticated customer is not a company admin for that company, the request returns a permissions error.