@qite/tide-client 1.1.50 → 1.1.51
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.
- package/build/index.js.map +1 -1
- package/build/types/accommodation-occupancy.d.ts +9 -9
- package/build/types/accommodation-with-available-places.d.ts +15 -15
- package/build/types/accommodation.d.ts +7 -7
- package/build/types/additional-services.d.ts +5 -5
- package/build/types/alternative-flight-data.d.ts +10 -10
- package/build/types/alternative-flight-leg.d.ts +18 -18
- package/build/types/alternative-flight.d.ts +12 -12
- package/build/types/availability-request.d.ts +11 -11
- package/build/types/availability.d.ts +5 -5
- package/build/types/available-products-request.d.ts +28 -28
- package/build/types/availablility-request.d.ts +11 -11
- package/build/types/duration.d.ts +4 -4
- package/build/types/entry-line-meta-data.d.ts +5 -5
- package/build/types/enums/online-payment-type.d.ts +3 -3
- package/build/types/enums/print-action-group.enum.d.ts +10 -10
- package/build/types/flight-leg.d.ts +18 -18
- package/build/types/flight.d.ts +23 -23
- package/build/types/hotel.d.ts +34 -34
- package/build/types/offer/affiliates.d.ts +5 -5
- package/build/types/offer/booking-v2/request/tour-codes-request.d.ts +3 -3
- package/build/types/offer/package-search-response.d.ts +4 -4
- package/build/types/option-pax.d.ts +4 -4
- package/build/types/option.d.ts +26 -26
- package/build/types/package-details-request.d.ts +12 -12
- package/build/types/package-flight.d.ts +11 -11
- package/build/types/package-flights.d.ts +5 -5
- package/build/types/package-option.d.ts +19 -19
- package/build/types/package-room-option.d.ts +8 -8
- package/build/types/package-room.d.ts +7 -7
- package/build/types/package-search-destination.d.ts +9 -9
- package/build/types/package-search-request-date.d.ts +4 -4
- package/build/types/package-search-request-room.d.ts +5 -5
- package/build/types/package-search-request.d.ts +21 -21
- package/build/types/package-search-response.d.ts +4 -4
- package/build/types/package-search-result.d.ts +12 -12
- package/build/types/package-sub-option.d.ts +6 -6
- package/build/types/pax.d.ts +4 -4
- package/build/types/regime.d.ts +5 -5
- package/build/types/traveler-grouping.d.ts +5 -5
- package/build/utils/booking-v2-client.d.ts +1 -1
- package/build/utils/bookingClient.d.ts +9 -9
- package/build/utils/client.d.ts +4 -4
- package/package.json +64 -64
- package/rollup.config.js +20 -20
- package/src/index.ts +71 -71
- package/src/services/odata.service.ts +158 -158
- package/src/types/aapi/accommodation-occupancy.ts +9 -9
- package/src/types/aapi/accommodation-with-available-places.ts +15 -15
- package/src/types/aapi/accommodation.ts +8 -8
- package/src/types/aapi/additional-services.ts +6 -6
- package/src/types/aapi/alternative-flight-data.ts +11 -11
- package/src/types/aapi/alternative-flight-leg.ts +18 -18
- package/src/types/aapi/alternative-flight.ts +13 -13
- package/src/types/aapi/availability-request.ts +12 -12
- package/src/types/aapi/availability.ts +6 -6
- package/src/types/aapi/available-products-request.ts +33 -33
- package/src/types/aapi/duration.ts +4 -4
- package/src/types/aapi/flight-leg.ts +18 -18
- package/src/types/aapi/flight.ts +24 -24
- package/src/types/aapi/hotel.ts +36 -36
- package/src/types/aapi/index.ts +22 -22
- package/src/types/aapi/mollie-payment-request.ts +6 -6
- package/src/types/aapi/mollie-payment.ts +3 -3
- package/src/types/aapi/option-pax.ts +4 -4
- package/src/types/aapi/option.ts +29 -29
- package/src/types/aapi/pax.ts +4 -4
- package/src/types/aapi/price-detail.ts +8 -8
- package/src/types/aapi/regime.ts +5 -5
- package/src/types/aapi/traveler-grouping.ts +5 -5
- package/src/types/company/agent/agent-invoice-item.ts +9 -9
- package/src/types/company/agent/change-entry-agent-surcharge-action.model.ts +5 -5
- package/src/types/company/agent/entry-totals.ts +7 -7
- package/src/types/company/agent/index.ts +3 -3
- package/src/types/company/agent-print-action-request.ts +11 -11
- package/src/types/company/agent-print-action.ts +7 -7
- package/src/types/company/custom-entry-status-item.ts +6 -6
- package/src/types/company/index.ts +5 -5
- package/src/types/company/number-string-pair.ts +4 -4
- package/src/types/enums/allotment-type.ts +5 -5
- package/src/types/enums/availability-search-type.ts +4 -4
- package/src/types/enums/data-type.ts +14 -14
- package/src/types/enums/dossier-type.ts +6 -6
- package/src/types/enums/entry-line-flag.ts +6 -6
- package/src/types/enums/entry-line-status.ts +19 -19
- package/src/types/enums/entry-status.ts +8 -8
- package/src/types/enums/export-status.ts +5 -5
- package/src/types/enums/gender.ts +5 -5
- package/src/types/enums/index.ts +17 -17
- package/src/types/enums/meta-data-type.ts +10 -10
- package/src/types/enums/payment-type.ts +6 -6
- package/src/types/enums/price-chart-type.ts +4 -4
- package/src/types/enums/print-action-group.ts +10 -10
- package/src/types/enums/requirement-type.ts +5 -5
- package/src/types/enums/room-type.ts +8 -8
- package/src/types/enums/sale-type.ts +4 -4
- package/src/types/enums/service-type.ts +28 -28
- package/src/types/index.ts +28 -28
- package/src/types/odata/column.ts +8 -8
- package/src/types/odata/filter-item.ts +14 -14
- package/src/types/odata/index.ts +3 -3
- package/src/types/odata/odata-params.ts +3 -3
- package/src/types/offer/additional-services.ts +6 -6
- package/src/types/offer/address.ts +11 -11
- package/src/types/offer/affiliate.ts +5 -5
- package/src/types/offer/alternative-flight-data.ts +11 -11
- package/src/types/offer/alternative-flight-leg.ts +18 -18
- package/src/types/offer/alternative-flight.ts +15 -15
- package/src/types/offer/available-package-accommodation.ts +8 -8
- package/src/types/offer/available-package-flight.ts +10 -10
- package/src/types/offer/available-package-option.ts +18 -18
- package/src/types/offer/available-package-pax-price.ts +6 -6
- package/src/types/offer/available-package-regime.ts +4 -4
- package/src/types/offer/available-package.ts +8 -8
- package/src/types/offer/base-price.ts +6 -6
- package/src/types/offer/base-prices-from-date-request.ts +12 -12
- package/src/types/offer/base-prices-request.ts +12 -12
- package/src/types/offer/book-request.ts +38 -38
- package/src/types/offer/booking-response.ts +4 -4
- package/src/types/offer/booking-v2/index.ts +3 -3
- package/src/types/offer/booking-v2/request/bookable-dates-request.ts +4 -4
- package/src/types/offer/booking-v2/request/booking-package-address.ts +14 -14
- package/src/types/offer/booking-v2/request/booking-package-book-request.ts +26 -26
- package/src/types/offer/booking-v2/request/booking-package-customer-request.ts +4 -4
- package/src/types/offer/booking-v2/request/booking-package-destination.ts +9 -9
- package/src/types/offer/booking-v2/request/booking-package-details-request.ts +24 -24
- package/src/types/offer/booking-v2/request/booking-package-flight-pool-request.ts +13 -13
- package/src/types/offer/booking-v2/request/booking-package-request.ts +5 -5
- package/src/types/offer/booking-v2/request/booking-package-search-request.ts +30 -30
- package/src/types/offer/booking-v2/request/booking-package-update-request.ts +5 -5
- package/src/types/offer/booking-v2/request/booking-package-voucher-request.ts +4 -4
- package/src/types/offer/booking-v2/request/index.ts +14 -14
- package/src/types/offer/booking-v2/request/selected-flight.ts +6 -6
- package/src/types/offer/booking-v2/request/selected-hotel.ts +5 -5
- package/src/types/offer/booking-v2/request/tour-codes.request.ts +3 -3
- package/src/types/offer/booking-v2/response/bookable-dates.ts +4 -4
- package/src/types/offer/booking-v2/response/booking-package-allotment-info.ts +17 -17
- package/src/types/offer/booking-v2/response/booking-package-dossier.ts +6 -6
- package/src/types/offer/booking-v2/response/booking-package-flight-pool.ts +6 -6
- package/src/types/offer/booking-v2/response/booking-package-hotel-pool.ts +5 -5
- package/src/types/offer/booking-v2/response/booking-package-item.ts +40 -40
- package/src/types/offer/booking-v2/response/booking-price-detail.ts +20 -20
- package/src/types/offer/booking-v2/response/booking-price-details.ts +15 -15
- package/src/types/offer/booking-v2/response/booking-price-per-pax.ts +4 -4
- package/src/types/offer/booking-v2/response/booking-product-notification.ts +7 -7
- package/src/types/offer/booking-v2/response/booking-room-status-option.ts +5 -5
- package/src/types/offer/booking-v2/response/booking-room-status.ts +6 -6
- package/src/types/offer/booking-v2/response/booking-travel-agent.ts +7 -7
- package/src/types/offer/booking-v2/response/booking-validity-line.ts +4 -4
- package/src/types/offer/booking-v2/response/booking-voucher-result.ts +3 -3
- package/src/types/offer/booking-v2/response/changed-line.ts +4 -4
- package/src/types/offer/booking-v2/response/index.ts +16 -16
- package/src/types/offer/booking-v2/response/tide-response.ts +6 -6
- package/src/types/offer/booking-v2/response/tour-codes-response.ts +3 -3
- package/src/types/offer/booking-v2/shared/airline-booking-package-option.ts +3 -3
- package/src/types/offer/booking-v2/shared/airport-booking-package-option.ts +3 -3
- package/src/types/offer/booking-v2/shared/booking-airline-group.ts +7 -7
- package/src/types/offer/booking-v2/shared/booking-airport-group.ts +7 -7
- package/src/types/offer/booking-v2/shared/booking-option-group.ts +5 -5
- package/src/types/offer/booking-v2/shared/booking-option-pax.ts +14 -14
- package/src/types/offer/booking-v2/shared/booking-option-unit.ts +13 -13
- package/src/types/offer/booking-v2/shared/booking-package-availability.ts +8 -8
- package/src/types/offer/booking-v2/shared/booking-package-flight-meta-data-line.ts +17 -17
- package/src/types/offer/booking-v2/shared/booking-package-flight-meta-data.ts +11 -11
- package/src/types/offer/booking-v2/shared/booking-package-flight.ts +15 -15
- package/src/types/offer/booking-v2/shared/booking-package-hotel-option.ts +10 -10
- package/src/types/offer/booking-v2/shared/booking-package-hotel-room.ts +6 -6
- package/src/types/offer/booking-v2/shared/booking-package-hotel.ts +27 -27
- package/src/types/offer/booking-v2/shared/booking-package-line.ts +17 -17
- package/src/types/offer/booking-v2/shared/booking-package-option.ts +55 -55
- package/src/types/offer/booking-v2/shared/booking-package-pax.ts +19 -19
- package/src/types/offer/booking-v2/shared/booking-package-request-room.ts +6 -6
- package/src/types/offer/booking-v2/shared/booking-package-room-option.ts +17 -17
- package/src/types/offer/booking-v2/shared/booking-package-room.ts +6 -6
- package/src/types/offer/booking-v2/shared/booking-package-tag.ts +5 -5
- package/src/types/offer/booking-v2/shared/booking-package.ts +13 -13
- package/src/types/offer/booking-v2/shared/index.ts +23 -23
- package/src/types/offer/booking-v2/shared/per-booking-package-option.ts +10 -10
- package/src/types/offer/booking-v2/shared/per-package-option.ts +10 -10
- package/src/types/offer/booking-v2/shared/per-pax-package-option.ts +6 -6
- package/src/types/offer/booking-v2/shared/per-unit-package-option.ts +8 -8
- package/src/types/offer/cached-package-search-result.ts +6 -6
- package/src/types/offer/confirmed-dossier-check.ts +6 -6
- package/src/types/offer/country-item.ts +5 -5
- package/src/types/offer/crm-contact-request.ts +37 -37
- package/src/types/offer/customer-request.ts +5 -5
- package/src/types/offer/dossier-default-product.ts +14 -14
- package/src/types/offer/dossier-view-result.ts +49 -49
- package/src/types/offer/entry-check-response.ts +5 -5
- package/src/types/offer/entry-line-meta-data.ts +5 -5
- package/src/types/offer/entry-line-pax.ts +9 -9
- package/src/types/offer/entry-line.ts +74 -74
- package/src/types/offer/entry-price-line.ts +40 -40
- package/src/types/offer/entry-room2.ts +5 -5
- package/src/types/offer/entry.ts +66 -66
- package/src/types/offer/flight-meta-data-line.ts +16 -16
- package/src/types/offer/flight-meta-data.ts +15 -15
- package/src/types/offer/flight-pool.ts +6 -6
- package/src/types/offer/index.ts +76 -76
- package/src/types/offer/item-tag.ts +3 -3
- package/src/types/offer/language.ts +5 -5
- package/src/types/offer/member-confirmation-request.ts +5 -5
- package/src/types/offer/member-forgot-password-request.ts +4 -4
- package/src/types/offer/member-info.ts +10 -10
- package/src/types/offer/member-login-request.ts +4 -4
- package/src/types/offer/member-login-response.ts +3 -3
- package/src/types/offer/member-reset-password-request.ts +4 -4
- package/src/types/offer/multiroom-book-request.ts +11 -11
- package/src/types/offer/note.ts +16 -16
- package/src/types/offer/other-product.ts +14 -14
- package/src/types/offer/package-book-request-room.ts +6 -6
- package/src/types/offer/package-book-request.ts +13 -13
- package/src/types/offer/package-flight.ts +14 -14
- package/src/types/offer/package-flights.ts +6 -6
- package/src/types/offer/package-option.ts +23 -23
- package/src/types/offer/package-price-details-request-room.ts +4 -4
- package/src/types/offer/package-price-details-request.ts +9 -9
- package/src/types/offer/package-room-option.ts +10 -10
- package/src/types/offer/package-room.ts +8 -8
- package/src/types/offer/package-search-destination.ts +9 -9
- package/src/types/offer/package-search-request-date.ts +4 -4
- package/src/types/offer/package-search-request-room.ts +5 -5
- package/src/types/offer/package-search-request.ts +23 -23
- package/src/types/offer/package-search-result.ts +13 -13
- package/src/types/offer/package-sub-option.ts +6 -6
- package/src/types/offer/page-result.ts +5 -5
- package/src/types/offer/pax.ts +30 -30
- package/src/types/offer/payment.ts +20 -20
- package/src/types/offer/person-country-preference.ts +7 -7
- package/src/types/offer/person-location-preference.ts +7 -7
- package/src/types/offer/person-oord-preference.ts +7 -7
- package/src/types/offer/person-period-date-range-preference.ts +6 -6
- package/src/types/offer/person-period-preference.ts +7 -7
- package/src/types/offer/person-region-preference.ts +7 -7
- package/src/types/offer/person-tour-group-preference.ts +7 -7
- package/src/types/offer/price-detail.ts +19 -19
- package/src/types/offer/price-per-pax.ts +6 -6
- package/src/types/offer/product-notification-result.ts +9 -9
- package/src/types/offer/web-contact-form-request.ts +13 -13
- package/src/types/offer/web-contact-has-tag-request.ts +4 -4
- package/src/types/tide-client-config.ts +5 -5
- package/src/utils/api.ts +54 -54
- package/src/utils/booking-client.ts +310 -310
- package/src/utils/booking-v2-client.ts +224 -224
- package/src/utils/common-client.ts +44 -44
- package/src/utils/json.ts +26 -26
- package/src/utils/member-client.ts +76 -76
- package/src/utils/mollie-client.ts +27 -27
- package/src/utils/search-client.ts +22 -22
- package/src/utils/web-agent-client.ts +176 -176
- package/src/utils/web-client.ts +58 -58
- package/src/utils/web-contact-client.ts +43 -43
- package/src/utils/web-file.ts +24 -24
- package/tests/bookingClient.test.ts +728 -728
- package/tests/mocks/available-products.json +183 -183
- package/tests/mocks/base-prices-from-date.json +74 -74
- package/tests/mocks/base-prices.json +236 -236
- package/tests/mocks/entry-multiroom.json +2043 -2043
- package/tests/mocks/entry-multiroom.short.json +4 -4
- package/tests/mocks/offer-entry.json +2043 -2043
- package/tests/mocks/offer-entry.short.json +4 -4
- package/tests/mocks/package-entry.json +2043 -2043
- package/tests/mocks/package-entry.short.json +4 -4
- package/tests/mocks/package-offer-entry.json +2043 -2043
- package/tests/mocks/package-offer-entry.short.json +4 -4
- package/tests/mocks/package-price-details.json +176 -176
- package/tests/mocks/package-search.json +179 -179
- package/tests/webClient.test.ts +38 -38
- package/tests/webContactClient.test.ts +61 -61
- package/tsconfig.json +23 -23
|
@@ -1,224 +1,224 @@
|
|
|
1
|
-
import { PackageSearchRequest, TideClientConfig } from "..";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AvailablePackage,
|
|
5
|
-
BookableDates,
|
|
6
|
-
BookableDatesRequest,
|
|
7
|
-
BookingPackage,
|
|
8
|
-
BookingPackageBookRequest,
|
|
9
|
-
BookingPackageDetailsRequest,
|
|
10
|
-
BookingPackageDossier,
|
|
11
|
-
BookingPackageFlightPool,
|
|
12
|
-
BookingPackageFlightPoolRequest,
|
|
13
|
-
BookingPackageHotelPool,
|
|
14
|
-
BookingPackageItem,
|
|
15
|
-
BookingPackageRequest,
|
|
16
|
-
BookingPackageSearchRequest,
|
|
17
|
-
BookingPackageUpdateRequest,
|
|
18
|
-
BookingPackageVoucherRequest,
|
|
19
|
-
BookingPriceDetails,
|
|
20
|
-
BookingTravelAgent,
|
|
21
|
-
BookingVoucherResult,
|
|
22
|
-
TideResponse,
|
|
23
|
-
TourCodesRequest,
|
|
24
|
-
TourCodesResponse,
|
|
25
|
-
} from "../types";
|
|
26
|
-
import { BookingPackageAvailability } from "../types/offer/booking-v2/shared/booking-package-availability";
|
|
27
|
-
import { get, post } from "./common-client";
|
|
28
|
-
|
|
29
|
-
const ENDPOINT = "/api/web/booking/v2";
|
|
30
|
-
const ENDPOINT_PACKAGE_SEARCH_LIST = `${ENDPOINT}/package-search-list`;
|
|
31
|
-
const ENDPOINT_SEARCH = `${ENDPOINT}/search`;
|
|
32
|
-
const ENDPOINT_SEARCH_WITH_ERROR_MAPPING = `${ENDPOINT}/search-with-error-mapping`;
|
|
33
|
-
const ENDPOINT_DETAILS = `${ENDPOINT}/details`;
|
|
34
|
-
const ENDPOINT_VALIDATE_VOUCHER = `${ENDPOINT}/validate-voucher`;
|
|
35
|
-
const ENDPOINT_ALTERNATE_HOTELS = `/alternate-hotels`;
|
|
36
|
-
const ENDPOINT_ALTERNATE_FLIGHTS = `/alternate-flights`;
|
|
37
|
-
const ENDPOINT_PRICE_DETAILS = `${ENDPOINT}/price-details`;
|
|
38
|
-
const ENDPOINT_BOOK = `${ENDPOINT}/book`;
|
|
39
|
-
const ENDPOINT_UPDATE = `${ENDPOINT}/update`;
|
|
40
|
-
const ENDPOINT_AGENTS = `${ENDPOINT}/agents`;
|
|
41
|
-
const ENDPOINT_AVAILABLE_ALLOTMENTS = `${ENDPOINT}/get-allotment-availability`;
|
|
42
|
-
const ENDPOINT_FLIGHT_POOL = `${ENDPOINT}/flight-pool`;
|
|
43
|
-
const ENDPOINT_BOOKABLE_DATES = `${ENDPOINT}/bookable-dates`;
|
|
44
|
-
const ENDPOINT_TOUR_CODES = `${ENDPOINT}/tourcodes`;
|
|
45
|
-
|
|
46
|
-
export const readPackageSearchList = (
|
|
47
|
-
config: TideClientConfig,
|
|
48
|
-
request: PackageSearchRequest,
|
|
49
|
-
signal?: AbortSignal
|
|
50
|
-
): Promise<AvailablePackage[]> => {
|
|
51
|
-
const url = `${config.host}${ENDPOINT_PACKAGE_SEARCH_LIST}`;
|
|
52
|
-
const apiKey = config.apiKey;
|
|
53
|
-
const body = JSON.stringify(request);
|
|
54
|
-
|
|
55
|
-
return post(url, apiKey, body, config.token, signal);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// PACKAGE SEARCH
|
|
59
|
-
export const search = (
|
|
60
|
-
config: TideClientConfig,
|
|
61
|
-
request: BookingPackageRequest<BookingPackageSearchRequest>,
|
|
62
|
-
signal?: AbortSignal
|
|
63
|
-
): Promise<BookingPackageItem[]> => {
|
|
64
|
-
const url = `${config.host}${ENDPOINT_SEARCH}`;
|
|
65
|
-
const apiKey = config.apiKey;
|
|
66
|
-
const body = JSON.stringify(request);
|
|
67
|
-
|
|
68
|
-
return post(url, apiKey, body, config.token, signal, true);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const searchWithErrorMapping = (
|
|
72
|
-
config: TideClientConfig,
|
|
73
|
-
request: BookingPackageRequest<BookingPackageSearchRequest>,
|
|
74
|
-
signal?: AbortSignal
|
|
75
|
-
): Promise<TideResponse<BookingPackageItem[]>> => {
|
|
76
|
-
const url = `${config.host}${ENDPOINT_SEARCH_WITH_ERROR_MAPPING}`;
|
|
77
|
-
const apiKey = config.apiKey;
|
|
78
|
-
const body = JSON.stringify(request);
|
|
79
|
-
|
|
80
|
-
return post(url, apiKey, body, config.token, signal, true);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const details = (
|
|
84
|
-
config: TideClientConfig,
|
|
85
|
-
request: BookingPackageRequest<BookingPackageDetailsRequest>,
|
|
86
|
-
signal?: AbortSignal,
|
|
87
|
-
languageCode?: string
|
|
88
|
-
): Promise<TideResponse<BookingPackage>> => {
|
|
89
|
-
const url = `${config.host}${ENDPOINT_DETAILS}`;
|
|
90
|
-
const apiKey = config.apiKey;
|
|
91
|
-
const body = JSON.stringify(request);
|
|
92
|
-
|
|
93
|
-
return post(url, apiKey, body, config.token, signal, true, languageCode);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const validateVoucher = (
|
|
97
|
-
config: TideClientConfig,
|
|
98
|
-
request: BookingPackageRequest<BookingPackageVoucherRequest>,
|
|
99
|
-
signal?: AbortSignal
|
|
100
|
-
): Promise<
|
|
101
|
-
const url = `${config.host}${ENDPOINT_VALIDATE_VOUCHER}`;
|
|
102
|
-
const apiKey = config.apiKey;
|
|
103
|
-
const body = JSON.stringify(request);
|
|
104
|
-
|
|
105
|
-
return post(url, apiKey, body, config.token, signal, true);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const alternateHotels = (
|
|
109
|
-
config: TideClientConfig,
|
|
110
|
-
transactionId: string,
|
|
111
|
-
signal?: AbortSignal
|
|
112
|
-
): Promise<BookingPackageHotelPool> => {
|
|
113
|
-
const url = `${config.host}${ENDPOINT_DETAILS}/${transactionId}${ENDPOINT_ALTERNATE_HOTELS}`;
|
|
114
|
-
const apiKey = config.apiKey;
|
|
115
|
-
|
|
116
|
-
return get(url, apiKey, config.token, signal, true);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const alternateFlights = (
|
|
120
|
-
config: TideClientConfig,
|
|
121
|
-
transactionId: string,
|
|
122
|
-
signal?: AbortSignal
|
|
123
|
-
): Promise<BookingPackageFlightPool> => {
|
|
124
|
-
const url = `${config.host}${ENDPOINT_DETAILS}/${transactionId}${ENDPOINT_ALTERNATE_FLIGHTS}`;
|
|
125
|
-
const apiKey = config.apiKey;
|
|
126
|
-
|
|
127
|
-
return get(url, apiKey, config.token, signal, true);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const priceDetails = (
|
|
131
|
-
config: TideClientConfig,
|
|
132
|
-
request: BookingPackageRequest<BookingPackageBookRequest>,
|
|
133
|
-
signal?: AbortSignal,
|
|
134
|
-
languageCode?: string
|
|
135
|
-
): Promise<BookingPriceDetails> => {
|
|
136
|
-
const url = `${config.host}${ENDPOINT_PRICE_DETAILS}`;
|
|
137
|
-
const apiKey = config.apiKey;
|
|
138
|
-
const body = JSON.stringify(request);
|
|
139
|
-
|
|
140
|
-
return post(url, apiKey, body, config.token, signal, true, languageCode);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const book = (
|
|
144
|
-
config: TideClientConfig,
|
|
145
|
-
request: BookingPackageRequest<BookingPackageBookRequest>,
|
|
146
|
-
signal?: AbortSignal,
|
|
147
|
-
languageCode?: string
|
|
148
|
-
): Promise<BookingPackageDossier> => {
|
|
149
|
-
const url = `${config.host}${ENDPOINT_BOOK}`;
|
|
150
|
-
const apiKey = config.apiKey;
|
|
151
|
-
const body = JSON.stringify(request);
|
|
152
|
-
|
|
153
|
-
return post(url, apiKey, body, config.token, signal, true, languageCode);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export const update = (
|
|
157
|
-
config: TideClientConfig,
|
|
158
|
-
request: BookingPackageRequest<BookingPackageUpdateRequest>,
|
|
159
|
-
signal?: AbortSignal
|
|
160
|
-
): Promise<BookingPackageDossier> => {
|
|
161
|
-
const url = `${config.host}${ENDPOINT_UPDATE}`;
|
|
162
|
-
const apiKey = config.apiKey;
|
|
163
|
-
const body = JSON.stringify(request);
|
|
164
|
-
|
|
165
|
-
return post(url, apiKey, body, config.token, signal, true);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export const agents = (
|
|
169
|
-
config: TideClientConfig,
|
|
170
|
-
signal?: AbortSignal
|
|
171
|
-
): Promise<BookingTravelAgent[]> => {
|
|
172
|
-
const url = `${config.host}${ENDPOINT_AGENTS}`;
|
|
173
|
-
const apiKey = config.apiKey;
|
|
174
|
-
|
|
175
|
-
return get(url, apiKey, config.token, signal, true);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export const getAllotmentAvailability = (
|
|
179
|
-
config: TideClientConfig,
|
|
180
|
-
eventId: string,
|
|
181
|
-
productCode: string,
|
|
182
|
-
signal?: AbortSignal
|
|
183
|
-
): Promise<BookingPackageAvailability[]> => {
|
|
184
|
-
const url = `${config.host}${ENDPOINT_AVAILABLE_ALLOTMENTS}/${eventId}/${productCode}`;
|
|
185
|
-
const apiKey = config.apiKey;
|
|
186
|
-
|
|
187
|
-
return get(url, apiKey, config.token, signal, true);
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export const searchFlightPool = (
|
|
191
|
-
config: TideClientConfig,
|
|
192
|
-
request: BookingPackageRequest<BookingPackageFlightPoolRequest>,
|
|
193
|
-
signal?: AbortSignal
|
|
194
|
-
): Promise<BookingPackageFlightPool> => {
|
|
195
|
-
const url = `${config.host}${ENDPOINT_FLIGHT_POOL}`;
|
|
196
|
-
const apiKey = config.apiKey;
|
|
197
|
-
const body = JSON.stringify(request);
|
|
198
|
-
|
|
199
|
-
return post(url, apiKey, body, config.token, signal, true);
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
export const bookableDates = (
|
|
203
|
-
config: TideClientConfig,
|
|
204
|
-
request: BookableDatesRequest,
|
|
205
|
-
signal?: AbortSignal
|
|
206
|
-
): Promise<BookableDates> => {
|
|
207
|
-
const url = `${config.host}${ENDPOINT_BOOKABLE_DATES}`;
|
|
208
|
-
const apiKey = config.apiKey;
|
|
209
|
-
const body = JSON.stringify(request);
|
|
210
|
-
|
|
211
|
-
return post(url, apiKey, body, config.token, signal, true);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export const tourCodes = (
|
|
215
|
-
config: TideClientConfig,
|
|
216
|
-
request: TourCodesRequest,
|
|
217
|
-
signal?: AbortSignal
|
|
218
|
-
): Promise<TourCodesResponse> => {
|
|
219
|
-
const url = `${config.host}${ENDPOINT_TOUR_CODES}`;
|
|
220
|
-
const apiKey = config.apiKey;
|
|
221
|
-
const body = JSON.stringify(request);
|
|
222
|
-
|
|
223
|
-
return post(url, apiKey, body, config.token, signal, true);
|
|
224
|
-
};
|
|
1
|
+
import { PackageSearchRequest, TideClientConfig } from "..";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AvailablePackage,
|
|
5
|
+
BookableDates,
|
|
6
|
+
BookableDatesRequest,
|
|
7
|
+
BookingPackage,
|
|
8
|
+
BookingPackageBookRequest,
|
|
9
|
+
BookingPackageDetailsRequest,
|
|
10
|
+
BookingPackageDossier,
|
|
11
|
+
BookingPackageFlightPool,
|
|
12
|
+
BookingPackageFlightPoolRequest,
|
|
13
|
+
BookingPackageHotelPool,
|
|
14
|
+
BookingPackageItem,
|
|
15
|
+
BookingPackageRequest,
|
|
16
|
+
BookingPackageSearchRequest,
|
|
17
|
+
BookingPackageUpdateRequest,
|
|
18
|
+
BookingPackageVoucherRequest,
|
|
19
|
+
BookingPriceDetails,
|
|
20
|
+
BookingTravelAgent,
|
|
21
|
+
BookingVoucherResult,
|
|
22
|
+
TideResponse,
|
|
23
|
+
TourCodesRequest,
|
|
24
|
+
TourCodesResponse,
|
|
25
|
+
} from "../types";
|
|
26
|
+
import { BookingPackageAvailability } from "../types/offer/booking-v2/shared/booking-package-availability";
|
|
27
|
+
import { get, post } from "./common-client";
|
|
28
|
+
|
|
29
|
+
const ENDPOINT = "/api/web/booking/v2";
|
|
30
|
+
const ENDPOINT_PACKAGE_SEARCH_LIST = `${ENDPOINT}/package-search-list`;
|
|
31
|
+
const ENDPOINT_SEARCH = `${ENDPOINT}/search`;
|
|
32
|
+
const ENDPOINT_SEARCH_WITH_ERROR_MAPPING = `${ENDPOINT}/search-with-error-mapping`;
|
|
33
|
+
const ENDPOINT_DETAILS = `${ENDPOINT}/details`;
|
|
34
|
+
const ENDPOINT_VALIDATE_VOUCHER = `${ENDPOINT}/validate-voucher`;
|
|
35
|
+
const ENDPOINT_ALTERNATE_HOTELS = `/alternate-hotels`;
|
|
36
|
+
const ENDPOINT_ALTERNATE_FLIGHTS = `/alternate-flights`;
|
|
37
|
+
const ENDPOINT_PRICE_DETAILS = `${ENDPOINT}/price-details`;
|
|
38
|
+
const ENDPOINT_BOOK = `${ENDPOINT}/book`;
|
|
39
|
+
const ENDPOINT_UPDATE = `${ENDPOINT}/update`;
|
|
40
|
+
const ENDPOINT_AGENTS = `${ENDPOINT}/agents`;
|
|
41
|
+
const ENDPOINT_AVAILABLE_ALLOTMENTS = `${ENDPOINT}/get-allotment-availability`;
|
|
42
|
+
const ENDPOINT_FLIGHT_POOL = `${ENDPOINT}/flight-pool`;
|
|
43
|
+
const ENDPOINT_BOOKABLE_DATES = `${ENDPOINT}/bookable-dates`;
|
|
44
|
+
const ENDPOINT_TOUR_CODES = `${ENDPOINT}/tourcodes`;
|
|
45
|
+
|
|
46
|
+
export const readPackageSearchList = (
|
|
47
|
+
config: TideClientConfig,
|
|
48
|
+
request: PackageSearchRequest,
|
|
49
|
+
signal?: AbortSignal
|
|
50
|
+
): Promise<AvailablePackage[]> => {
|
|
51
|
+
const url = `${config.host}${ENDPOINT_PACKAGE_SEARCH_LIST}`;
|
|
52
|
+
const apiKey = config.apiKey;
|
|
53
|
+
const body = JSON.stringify(request);
|
|
54
|
+
|
|
55
|
+
return post(url, apiKey, body, config.token, signal);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// PACKAGE SEARCH
|
|
59
|
+
export const search = (
|
|
60
|
+
config: TideClientConfig,
|
|
61
|
+
request: BookingPackageRequest<BookingPackageSearchRequest>,
|
|
62
|
+
signal?: AbortSignal
|
|
63
|
+
): Promise<BookingPackageItem[]> => {
|
|
64
|
+
const url = `${config.host}${ENDPOINT_SEARCH}`;
|
|
65
|
+
const apiKey = config.apiKey;
|
|
66
|
+
const body = JSON.stringify(request);
|
|
67
|
+
|
|
68
|
+
return post(url, apiKey, body, config.token, signal, true);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const searchWithErrorMapping = (
|
|
72
|
+
config: TideClientConfig,
|
|
73
|
+
request: BookingPackageRequest<BookingPackageSearchRequest>,
|
|
74
|
+
signal?: AbortSignal
|
|
75
|
+
): Promise<TideResponse<BookingPackageItem[]>> => {
|
|
76
|
+
const url = `${config.host}${ENDPOINT_SEARCH_WITH_ERROR_MAPPING}`;
|
|
77
|
+
const apiKey = config.apiKey;
|
|
78
|
+
const body = JSON.stringify(request);
|
|
79
|
+
|
|
80
|
+
return post(url, apiKey, body, config.token, signal, true);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const details = (
|
|
84
|
+
config: TideClientConfig,
|
|
85
|
+
request: BookingPackageRequest<BookingPackageDetailsRequest>,
|
|
86
|
+
signal?: AbortSignal,
|
|
87
|
+
languageCode?: string
|
|
88
|
+
): Promise<TideResponse<BookingPackage>> => {
|
|
89
|
+
const url = `${config.host}${ENDPOINT_DETAILS}`;
|
|
90
|
+
const apiKey = config.apiKey;
|
|
91
|
+
const body = JSON.stringify(request);
|
|
92
|
+
|
|
93
|
+
return post(url, apiKey, body, config.token, signal, true, languageCode);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const validateVoucher = (
|
|
97
|
+
config: TideClientConfig,
|
|
98
|
+
request: BookingPackageRequest<BookingPackageVoucherRequest>,
|
|
99
|
+
signal?: AbortSignal
|
|
100
|
+
): Promise<BookingVoucherResult> => {
|
|
101
|
+
const url = `${config.host}${ENDPOINT_VALIDATE_VOUCHER}`;
|
|
102
|
+
const apiKey = config.apiKey;
|
|
103
|
+
const body = JSON.stringify(request);
|
|
104
|
+
|
|
105
|
+
return post(url, apiKey, body, config.token, signal, true);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const alternateHotels = (
|
|
109
|
+
config: TideClientConfig,
|
|
110
|
+
transactionId: string,
|
|
111
|
+
signal?: AbortSignal
|
|
112
|
+
): Promise<BookingPackageHotelPool> => {
|
|
113
|
+
const url = `${config.host}${ENDPOINT_DETAILS}/${transactionId}${ENDPOINT_ALTERNATE_HOTELS}`;
|
|
114
|
+
const apiKey = config.apiKey;
|
|
115
|
+
|
|
116
|
+
return get(url, apiKey, config.token, signal, true);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const alternateFlights = (
|
|
120
|
+
config: TideClientConfig,
|
|
121
|
+
transactionId: string,
|
|
122
|
+
signal?: AbortSignal
|
|
123
|
+
): Promise<BookingPackageFlightPool> => {
|
|
124
|
+
const url = `${config.host}${ENDPOINT_DETAILS}/${transactionId}${ENDPOINT_ALTERNATE_FLIGHTS}`;
|
|
125
|
+
const apiKey = config.apiKey;
|
|
126
|
+
|
|
127
|
+
return get(url, apiKey, config.token, signal, true);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const priceDetails = (
|
|
131
|
+
config: TideClientConfig,
|
|
132
|
+
request: BookingPackageRequest<BookingPackageBookRequest>,
|
|
133
|
+
signal?: AbortSignal,
|
|
134
|
+
languageCode?: string
|
|
135
|
+
): Promise<BookingPriceDetails> => {
|
|
136
|
+
const url = `${config.host}${ENDPOINT_PRICE_DETAILS}`;
|
|
137
|
+
const apiKey = config.apiKey;
|
|
138
|
+
const body = JSON.stringify(request);
|
|
139
|
+
|
|
140
|
+
return post(url, apiKey, body, config.token, signal, true, languageCode);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const book = (
|
|
144
|
+
config: TideClientConfig,
|
|
145
|
+
request: BookingPackageRequest<BookingPackageBookRequest>,
|
|
146
|
+
signal?: AbortSignal,
|
|
147
|
+
languageCode?: string
|
|
148
|
+
): Promise<BookingPackageDossier> => {
|
|
149
|
+
const url = `${config.host}${ENDPOINT_BOOK}`;
|
|
150
|
+
const apiKey = config.apiKey;
|
|
151
|
+
const body = JSON.stringify(request);
|
|
152
|
+
|
|
153
|
+
return post(url, apiKey, body, config.token, signal, true, languageCode);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const update = (
|
|
157
|
+
config: TideClientConfig,
|
|
158
|
+
request: BookingPackageRequest<BookingPackageUpdateRequest>,
|
|
159
|
+
signal?: AbortSignal
|
|
160
|
+
): Promise<BookingPackageDossier> => {
|
|
161
|
+
const url = `${config.host}${ENDPOINT_UPDATE}`;
|
|
162
|
+
const apiKey = config.apiKey;
|
|
163
|
+
const body = JSON.stringify(request);
|
|
164
|
+
|
|
165
|
+
return post(url, apiKey, body, config.token, signal, true);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export const agents = (
|
|
169
|
+
config: TideClientConfig,
|
|
170
|
+
signal?: AbortSignal
|
|
171
|
+
): Promise<BookingTravelAgent[]> => {
|
|
172
|
+
const url = `${config.host}${ENDPOINT_AGENTS}`;
|
|
173
|
+
const apiKey = config.apiKey;
|
|
174
|
+
|
|
175
|
+
return get(url, apiKey, config.token, signal, true);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const getAllotmentAvailability = (
|
|
179
|
+
config: TideClientConfig,
|
|
180
|
+
eventId: string,
|
|
181
|
+
productCode: string,
|
|
182
|
+
signal?: AbortSignal
|
|
183
|
+
): Promise<BookingPackageAvailability[]> => {
|
|
184
|
+
const url = `${config.host}${ENDPOINT_AVAILABLE_ALLOTMENTS}/${eventId}/${productCode}`;
|
|
185
|
+
const apiKey = config.apiKey;
|
|
186
|
+
|
|
187
|
+
return get(url, apiKey, config.token, signal, true);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const searchFlightPool = (
|
|
191
|
+
config: TideClientConfig,
|
|
192
|
+
request: BookingPackageRequest<BookingPackageFlightPoolRequest>,
|
|
193
|
+
signal?: AbortSignal
|
|
194
|
+
): Promise<BookingPackageFlightPool> => {
|
|
195
|
+
const url = `${config.host}${ENDPOINT_FLIGHT_POOL}`;
|
|
196
|
+
const apiKey = config.apiKey;
|
|
197
|
+
const body = JSON.stringify(request);
|
|
198
|
+
|
|
199
|
+
return post(url, apiKey, body, config.token, signal, true);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const bookableDates = (
|
|
203
|
+
config: TideClientConfig,
|
|
204
|
+
request: BookableDatesRequest,
|
|
205
|
+
signal?: AbortSignal
|
|
206
|
+
): Promise<BookableDates> => {
|
|
207
|
+
const url = `${config.host}${ENDPOINT_BOOKABLE_DATES}`;
|
|
208
|
+
const apiKey = config.apiKey;
|
|
209
|
+
const body = JSON.stringify(request);
|
|
210
|
+
|
|
211
|
+
return post(url, apiKey, body, config.token, signal, true);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export const tourCodes = (
|
|
215
|
+
config: TideClientConfig,
|
|
216
|
+
request: TourCodesRequest,
|
|
217
|
+
signal?: AbortSignal
|
|
218
|
+
): Promise<TourCodesResponse> => {
|
|
219
|
+
const url = `${config.host}${ENDPOINT_TOUR_CODES}`;
|
|
220
|
+
const apiKey = config.apiKey;
|
|
221
|
+
const body = JSON.stringify(request);
|
|
222
|
+
|
|
223
|
+
return post(url, apiKey, body, config.token, signal, true);
|
|
224
|
+
};
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { post as apiPost, get as apiGet } from "./api";
|
|
2
|
-
import { reviver } from "./json";
|
|
3
|
-
|
|
4
|
-
export const post = async <T>(
|
|
5
|
-
url: string,
|
|
6
|
-
apiKey: string,
|
|
7
|
-
body: string,
|
|
8
|
-
token?: string,
|
|
9
|
-
signal?: AbortSignal,
|
|
10
|
-
skipReviver?: boolean,
|
|
11
|
-
languageCode?: string
|
|
12
|
-
): Promise<T> => {
|
|
13
|
-
const response = await apiPost(
|
|
14
|
-
url,
|
|
15
|
-
apiKey,
|
|
16
|
-
body,
|
|
17
|
-
token,
|
|
18
|
-
signal,
|
|
19
|
-
languageCode
|
|
20
|
-
);
|
|
21
|
-
const responseBody = await response.text();
|
|
22
|
-
|
|
23
|
-
const result: T = skipReviver
|
|
24
|
-
? JSON.parse(responseBody ?? "")
|
|
25
|
-
: JSON.parse(responseBody ?? "", reviver);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const get = async <T>(
|
|
30
|
-
url: string,
|
|
31
|
-
apiKey: string,
|
|
32
|
-
token?: string,
|
|
33
|
-
signal?: AbortSignal,
|
|
34
|
-
skipReviver?: boolean,
|
|
35
|
-
languageCode?: string
|
|
36
|
-
): Promise<T> => {
|
|
37
|
-
const response = await apiGet(url, apiKey, token, signal, languageCode);
|
|
38
|
-
const responseBody = await response.text();
|
|
39
|
-
|
|
40
|
-
const result: T = skipReviver
|
|
41
|
-
? JSON.parse(responseBody)
|
|
42
|
-
: JSON.parse(responseBody, reviver);
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
1
|
+
import { post as apiPost, get as apiGet } from "./api";
|
|
2
|
+
import { reviver } from "./json";
|
|
3
|
+
|
|
4
|
+
export const post = async <T>(
|
|
5
|
+
url: string,
|
|
6
|
+
apiKey: string,
|
|
7
|
+
body: string,
|
|
8
|
+
token?: string,
|
|
9
|
+
signal?: AbortSignal,
|
|
10
|
+
skipReviver?: boolean,
|
|
11
|
+
languageCode?: string
|
|
12
|
+
): Promise<T> => {
|
|
13
|
+
const response = await apiPost(
|
|
14
|
+
url,
|
|
15
|
+
apiKey,
|
|
16
|
+
body,
|
|
17
|
+
token,
|
|
18
|
+
signal,
|
|
19
|
+
languageCode
|
|
20
|
+
);
|
|
21
|
+
const responseBody = await response.text();
|
|
22
|
+
|
|
23
|
+
const result: T = skipReviver
|
|
24
|
+
? JSON.parse(responseBody ?? "")
|
|
25
|
+
: JSON.parse(responseBody ?? "", reviver);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const get = async <T>(
|
|
30
|
+
url: string,
|
|
31
|
+
apiKey: string,
|
|
32
|
+
token?: string,
|
|
33
|
+
signal?: AbortSignal,
|
|
34
|
+
skipReviver?: boolean,
|
|
35
|
+
languageCode?: string
|
|
36
|
+
): Promise<T> => {
|
|
37
|
+
const response = await apiGet(url, apiKey, token, signal, languageCode);
|
|
38
|
+
const responseBody = await response.text();
|
|
39
|
+
|
|
40
|
+
const result: T = skipReviver
|
|
41
|
+
? JSON.parse(responseBody)
|
|
42
|
+
: JSON.parse(responseBody, reviver);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
package/src/utils/json.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import moment from "moment";
|
|
2
|
-
|
|
3
|
-
export const reviver = (_: any, value: any) => {
|
|
4
|
-
const formats = [moment.ISO_8601, "MM/DD/YYYY"];
|
|
5
|
-
if (typeof value === "string") {
|
|
6
|
-
if (moment(value, formats, true).isValid()) {
|
|
7
|
-
return new Date(value);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return value;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const replacer = (_: any, value: any) => {
|
|
14
|
-
if (typeof value === "string") {
|
|
15
|
-
if (Date.parse(value)) {
|
|
16
|
-
const date = new Date(value);
|
|
17
|
-
if (date.toISOString() === value) {
|
|
18
|
-
const year = date.getFullYear();
|
|
19
|
-
const month = date.getMonth() + 1;
|
|
20
|
-
const day = date.getDate();
|
|
21
|
-
return `${year}-${month}-${day}`;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
};
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
|
|
3
|
+
export const reviver = (_: any, value: any) => {
|
|
4
|
+
const formats = [moment.ISO_8601, "MM/DD/YYYY"];
|
|
5
|
+
if (typeof value === "string") {
|
|
6
|
+
if (moment(value, formats, true).isValid()) {
|
|
7
|
+
return new Date(value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const replacer = (_: any, value: any) => {
|
|
14
|
+
if (typeof value === "string") {
|
|
15
|
+
if (Date.parse(value)) {
|
|
16
|
+
const date = new Date(value);
|
|
17
|
+
if (date.toISOString() === value) {
|
|
18
|
+
const year = date.getFullYear();
|
|
19
|
+
const month = date.getMonth() + 1;
|
|
20
|
+
const day = date.getDate();
|
|
21
|
+
return `${year}-${month}-${day}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|