tripstorekrabi-shared 1.21.0 → 1.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils.js +30 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.21.0",
3
+ "version": "1.21.2",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/utils.js CHANGED
@@ -6,7 +6,7 @@ import utc from 'dayjs/plugin/utc.js';
6
6
  import timezone from 'dayjs/plugin/timezone.js';
7
7
  import { findEndPoint, findStartingPoint } from './price.js';
8
8
  import { CUSTOMER_NOTE } from './booking.js';
9
- import { parsePhoneNumber, AsYouType } from 'libphonenumber-js';
9
+ import { parsePhoneNumberWithError, AsYouType } from 'libphonenumber-js';
10
10
 
11
11
  dayjs.extend(customParseFormat);
12
12
  dayjs.extend(advancedFormat);
@@ -30,13 +30,15 @@ export const CUSTOM_MEETING_POINT = {
30
30
  description: 'Custom meeting point',
31
31
  };
32
32
 
33
- export const TRIPSTORE_AGENCYID_IN_PHAYUN = '2Z5NPZTmd62tm22q0RNB';
34
- export const VIATOR_AGENCYID_IN_PHAYUN = 'eVxVUldoJhEiNUZyfcyt';
35
- export const GYG_AGENCYID_IN_PHAYUN = 'lPZIMbXgzaFwA366uzia';
36
- export const KLK_AGENCYID_IN_PHAYUN = 'JSYggp9yw8RBdIkhuPvo';
37
- export const MUS_AGENCYID_IN_PHAYUN = '6VBWnnTPn2wlfhGIxG5L';
38
- export const EXP_AGENCYID_IN_PHAYUN = 'ECf1LkUkd67Avjb8CoAB';
39
- export const TIQ_AGENCYID_IN_PHAYUN = 'HPiO2Z6OdD8A3O5Zbi96';
33
+ export const TRIPSTORE_AGENCY_ID = '2Z5NPZTmd62tm22q0RNB';
34
+ export const VIATOR_AGENCY_ID = 'eVxVUldoJhEiNUZyfcyt';
35
+ export const GYG_AGENCY_ID = 'lPZIMbXgzaFwA366uzia';
36
+ export const KLK_AGENCY_ID = 'JSYggp9yw8RBdIkhuPvo';
37
+ export const MUS_AGENCY_ID = '6VBWnnTPn2wlfhGIxG5L';
38
+ export const EXP_AGENCY_ID = 'ECf1LkUkd67Avjb8CoAB';
39
+ export const TIQ_AGENCY_ID = 'HPiO2Z6OdD8A3O5Zbi96';
40
+ export const CIV_AGENCY_ID = 'ZBoPc4cFtxyUJIxkFKnzG';
41
+ export const CUR_AGENCY_ID = 'BSV3FQAM_pZx7QnC67dBC';
40
42
 
41
43
  export const DIETARIES = [
42
44
  'None',
@@ -354,7 +356,7 @@ export function formatPeople(people) {
354
356
  }
355
357
 
356
358
  export function countPeople(people) {
357
- return people.adults ?? 0 + people.children ?? 0 + people.infants ?? 0;
359
+ return (people.adults ?? 0) + (people.children ?? 0) + (people.infants ?? 0);
358
360
  }
359
361
 
360
362
  export function isNumeric(n) {
@@ -692,44 +694,40 @@ export function createVoucherRequest(booking, product) {
692
694
  return request;
693
695
  }
694
696
 
695
- export function isGYGBooking(referenceNumber) {
696
- return referenceNumber.startsWith('GYG');
697
+ export function isGYGBooking(otaPartnerRef) {
698
+ return otaPartnerRef.id === GYG_AGENCY_ID;
697
699
  }
698
700
 
699
- export function isViatorBooking(referenceNumber) {
700
- return referenceNumber.startsWith('BR-');
701
+ export function isViatorBooking(otaPartnerRef) {
702
+ return otaPartnerRef.id === VIATOR_AGENCY_ID;
701
703
  }
702
704
 
703
- export function isExpediaBooking(referenceNumber) {
704
- return referenceNumber.startsWith('EXP-');
705
+ export function isExpediaBooking(otaPartnerRef) {
706
+ return otaPartnerRef.id === EXP_AGENCY_ID;
705
707
  }
706
708
 
707
- export function isKlookBooking(referenceNumber) {
708
- return referenceNumber.startsWith('KLK-');
709
+ export function isKlookBooking(otaPartnerRef) {
710
+ return otaPartnerRef.id === KLK_AGENCY_ID;
709
711
  }
710
712
 
711
- export function isMusementBooking(referenceNumber) {
712
- return referenceNumber.startsWith('MUS');
713
+ export function isMusementBooking(otaPartnerRef) {
714
+ return otaPartnerRef.id === MUS_AGENCY_ID;
713
715
  }
714
716
 
715
- export function isAirbnbBooking(referenceNumber) {
716
- return referenceNumber.startsWith('Airbnb-');
717
+ export function isTiqetsBooking(otaPartnerRef) {
718
+ return otaPartnerRef.id === TIQ_AGENCY_ID;
717
719
  }
718
720
 
719
- export function isTiqetsBooking(referenceNumber) {
720
- return referenceNumber.startsWith('TIQ-');
721
+ export function isCivitatisBooking(otaPartnerRef) {
722
+ return otaPartnerRef.id === CIV_AGENCY_ID;
721
723
  }
722
724
 
723
- export function isCivitatisBooking(referenceNumber) {
724
- return referenceNumber.startsWith('CIV-');
725
+ export function isCuriosidad(otaPartnerRef) {
726
+ return otaPartnerRef.id === CUR_AGENCY_ID
725
727
  }
726
728
 
727
- export function isCuriosidad(referenceNumber) {
728
- return referenceNumber.startsWith('CUR-');
729
- }
730
-
731
- export function isTSKBooking(referenceNumber) {
732
- return referenceNumber.startsWith('TSK');
729
+ export function isTSKBooking(otaPartnerRef) {
730
+ return otaPartnerRef.id === TRIPSTORE_AGENCY_ID;
733
731
  }
734
732
 
735
733
  export function getBookingType(referenceNumber) {
@@ -747,8 +745,6 @@ export function getBookingType(referenceNumber) {
747
745
  return 'klk';
748
746
  } else if (isMusementBooking(referenceNumber)) {
749
747
  return 'mus';
750
- } else if (isAirbnbBooking(referenceNumber)) {
751
- return 'air';
752
748
  } else if (isTiqetsBooking(referenceNumber)) {
753
749
  return 'tiq';
754
750
  } else if (isCuriosidad(referenceNumber)) {
@@ -783,7 +779,7 @@ export function isJSON(text) {
783
779
  export function formatPhoneNumber(phoneNumber) {
784
780
  if (phoneNumber) {
785
781
  try {
786
- let libPhoneNumber = parsePhoneNumber(phoneNumber, 'TH');
782
+ let libPhoneNumber = parsePhoneNumberWithError(phoneNumber, 'TH');
787
783
  let asYouType = new AsYouType();
788
784
  asYouType.input(phoneNumber);
789
785