@qite/tide-client 1.0.73 → 1.0.76

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.
@@ -1,120 +1,121 @@
1
- import { PackageSearchRequest, TideClientConfig } from "..";
2
-
3
- import {
4
- AvailablePackage,
5
- BookingPackage,
6
- BookingPackageBookRequest,
7
- BookingPackageDetailsRequest,
8
- BookingPackageDossier,
9
- BookingPackageFlightPool,
10
- BookingPackageHotelPool,
11
- BookingPackageItem,
12
- BookingPackageRequest,
13
- BookingPackageSearchRequest,
14
- BookingPriceDetails,
15
- BookingTravelAgent,
16
- } from "../types";
17
- import { get, post } from "./common-client";
18
-
19
- const ENDPOINT = "/api/web/booking/v2";
20
- const ENDPOINT_PACKAGE_SEARCH_LIST = `${ENDPOINT}/package-search-list`;
21
- const ENDPOINT_SEARCH = `${ENDPOINT}/search`;
22
- const ENDPOINT_DETAILS = `${ENDPOINT}/details`;
23
- const ENDPOINT_ALTERNATE_HOTELS = `/alternate-hotels`;
24
- const ENDPOINT_ALTERNATE_FLIGHTS = `/alternate-flights`;
25
- const ENDPOINT_PRICE_DETAILS = `${ENDPOINT}/price-details`;
26
- const ENDPOINT_BOOK = `${ENDPOINT}/book`;
27
- const ENDPOINT_AGENTS = `${ENDPOINT}/agents`;
28
-
29
- export const readPackageSearchList = (
30
- config: TideClientConfig,
31
- request: PackageSearchRequest,
32
- signal?: AbortSignal
33
- ): Promise<AvailablePackage[]> => {
34
- const url = `${config.host}${ENDPOINT_PACKAGE_SEARCH_LIST}`;
35
- const apiKey = config.apiKey;
36
- const body = JSON.stringify(request);
37
-
38
- return post(url, apiKey, body, signal);
39
- };
40
-
41
- // PACKAGE SEARCH
42
- export const search = (
43
- config: TideClientConfig,
44
- request: BookingPackageRequest<BookingPackageSearchRequest>,
45
- signal?: AbortSignal
46
- ): Promise<BookingPackageItem[]> => {
47
- const url = `${config.host}${ENDPOINT_SEARCH}`;
48
- const apiKey = config.apiKey;
49
- const body = JSON.stringify(request);
50
-
51
- return post(url, apiKey, body, signal, true);
52
- };
53
-
54
- export const details = (
55
- config: TideClientConfig,
56
- request: BookingPackageRequest<BookingPackageDetailsRequest>,
57
- signal?: AbortSignal
58
- ): Promise<BookingPackage> => {
59
- const url = `${config.host}${ENDPOINT_DETAILS}`;
60
- const apiKey = config.apiKey;
61
- const body = JSON.stringify(request);
62
-
63
- return post(url, apiKey, body, signal, true);
64
- };
65
-
66
- export const alternateHotels = (
67
- config: TideClientConfig,
68
- transactionId: string,
69
- signal?: AbortSignal
70
- ): Promise<BookingPackageHotelPool> => {
71
- const url = `${config.host}${ENDPOINT_DETAILS}/${transactionId}${ENDPOINT_ALTERNATE_HOTELS}`;
72
- const apiKey = config.apiKey;
73
-
74
- return get(url, apiKey, signal, true);
75
- };
76
-
77
- export const alternateFlights = (
78
- config: TideClientConfig,
79
- transactionId: string,
80
- signal?: AbortSignal
81
- ): Promise<BookingPackageFlightPool> => {
82
- const url = `${config.host}${ENDPOINT_DETAILS}/${transactionId}${ENDPOINT_ALTERNATE_FLIGHTS}`;
83
- const apiKey = config.apiKey;
84
-
85
- return get(url, apiKey, signal, true);
86
- };
87
-
88
- export const priceDetails = (
89
- config: TideClientConfig,
90
- request: BookingPackageRequest<BookingPackageBookRequest>,
91
- signal?: AbortSignal
92
- ): Promise<BookingPriceDetails> => {
93
- const url = `${config.host}${ENDPOINT_PRICE_DETAILS}`;
94
- const apiKey = config.apiKey;
95
- const body = JSON.stringify(request);
96
-
97
- return post(url, apiKey, body, signal, true);
98
- };
99
-
100
- export const book = (
101
- config: TideClientConfig,
102
- request: BookingPackageRequest<BookingPackageBookRequest>,
103
- signal?: AbortSignal
104
- ): Promise<BookingPackageDossier> => {
105
- const url = `${config.host}${ENDPOINT_BOOK}`;
106
- const apiKey = config.apiKey;
107
- const body = JSON.stringify(request);
108
-
109
- return post(url, apiKey, body, signal, true);
110
- };
111
-
112
- export const agents = (
113
- config: TideClientConfig,
114
- signal?: AbortSignal
115
- ): Promise<BookingTravelAgent[]> => {
116
- const url = `${config.host}${ENDPOINT_AGENTS}`;
117
- const apiKey = config.apiKey;
118
-
119
- return get(url, apiKey, signal, true);
120
- };
1
+ import { PackageSearchRequest, TideClientConfig } from "..";
2
+
3
+ import {
4
+ AvailablePackage,
5
+ BookingPackage,
6
+ BookingPackageBookRequest,
7
+ BookingPackageDetailsRequest,
8
+ BookingPackageDossier,
9
+ BookingPackageFlightPool,
10
+ BookingPackageHotelPool,
11
+ BookingPackageItem,
12
+ BookingPackageRequest,
13
+ BookingPackageSearchRequest,
14
+ BookingPriceDetails,
15
+ BookingTravelAgent,
16
+ TideResponse,
17
+ } from "../types";
18
+ import { get, post } from "./common-client";
19
+
20
+ const ENDPOINT = "/api/web/booking/v2";
21
+ const ENDPOINT_PACKAGE_SEARCH_LIST = `${ENDPOINT}/package-search-list`;
22
+ const ENDPOINT_SEARCH = `${ENDPOINT}/search`;
23
+ const ENDPOINT_DETAILS = `${ENDPOINT}/details`;
24
+ const ENDPOINT_ALTERNATE_HOTELS = `/alternate-hotels`;
25
+ const ENDPOINT_ALTERNATE_FLIGHTS = `/alternate-flights`;
26
+ const ENDPOINT_PRICE_DETAILS = `${ENDPOINT}/price-details`;
27
+ const ENDPOINT_BOOK = `${ENDPOINT}/book`;
28
+ const ENDPOINT_AGENTS = `${ENDPOINT}/agents`;
29
+
30
+ export const readPackageSearchList = (
31
+ config: TideClientConfig,
32
+ request: PackageSearchRequest,
33
+ signal?: AbortSignal
34
+ ): Promise<AvailablePackage[]> => {
35
+ const url = `${config.host}${ENDPOINT_PACKAGE_SEARCH_LIST}`;
36
+ const apiKey = config.apiKey;
37
+ const body = JSON.stringify(request);
38
+
39
+ return post(url, apiKey, body, signal);
40
+ };
41
+
42
+ // PACKAGE SEARCH
43
+ export const search = (
44
+ config: TideClientConfig,
45
+ request: BookingPackageRequest<BookingPackageSearchRequest>,
46
+ signal?: AbortSignal
47
+ ): Promise<BookingPackageItem[]> => {
48
+ const url = `${config.host}${ENDPOINT_SEARCH}`;
49
+ const apiKey = config.apiKey;
50
+ const body = JSON.stringify(request);
51
+
52
+ return post(url, apiKey, body, signal, true);
53
+ };
54
+
55
+ export const details = (
56
+ config: TideClientConfig,
57
+ request: BookingPackageRequest<BookingPackageDetailsRequest>,
58
+ signal?: AbortSignal
59
+ ): Promise<TideResponse<BookingPackage>> => {
60
+ const url = `${config.host}${ENDPOINT_DETAILS}`;
61
+ const apiKey = config.apiKey;
62
+ const body = JSON.stringify(request);
63
+
64
+ return post(url, apiKey, body, signal, true);
65
+ };
66
+
67
+ export const alternateHotels = (
68
+ config: TideClientConfig,
69
+ transactionId: string,
70
+ signal?: AbortSignal
71
+ ): Promise<BookingPackageHotelPool> => {
72
+ const url = `${config.host}${ENDPOINT_DETAILS}/${transactionId}${ENDPOINT_ALTERNATE_HOTELS}`;
73
+ const apiKey = config.apiKey;
74
+
75
+ return get(url, apiKey, signal, true);
76
+ };
77
+
78
+ export const alternateFlights = (
79
+ config: TideClientConfig,
80
+ transactionId: string,
81
+ signal?: AbortSignal
82
+ ): Promise<BookingPackageFlightPool> => {
83
+ const url = `${config.host}${ENDPOINT_DETAILS}/${transactionId}${ENDPOINT_ALTERNATE_FLIGHTS}`;
84
+ const apiKey = config.apiKey;
85
+
86
+ return get(url, apiKey, signal, true);
87
+ };
88
+
89
+ export const priceDetails = (
90
+ config: TideClientConfig,
91
+ request: BookingPackageRequest<BookingPackageBookRequest>,
92
+ signal?: AbortSignal
93
+ ): Promise<BookingPriceDetails> => {
94
+ const url = `${config.host}${ENDPOINT_PRICE_DETAILS}`;
95
+ const apiKey = config.apiKey;
96
+ const body = JSON.stringify(request);
97
+
98
+ return post(url, apiKey, body, signal, true);
99
+ };
100
+
101
+ export const book = (
102
+ config: TideClientConfig,
103
+ request: BookingPackageRequest<BookingPackageBookRequest>,
104
+ signal?: AbortSignal
105
+ ): Promise<BookingPackageDossier> => {
106
+ const url = `${config.host}${ENDPOINT_BOOK}`;
107
+ const apiKey = config.apiKey;
108
+ const body = JSON.stringify(request);
109
+
110
+ return post(url, apiKey, body, signal, true);
111
+ };
112
+
113
+ export const agents = (
114
+ config: TideClientConfig,
115
+ signal?: AbortSignal
116
+ ): Promise<BookingTravelAgent[]> => {
117
+ const url = `${config.host}${ENDPOINT_AGENTS}`;
118
+ const apiKey = config.apiKey;
119
+
120
+ return get(url, apiKey, signal, true);
121
+ };
@@ -12,8 +12,8 @@ export const post = async <T>(
12
12
  const responseBody = await response.text();
13
13
 
14
14
  const result: T = skipReviver
15
- ? JSON.parse(responseBody)
16
- : JSON.parse(responseBody, reviver);
15
+ ? JSON.parse(responseBody ?? "")
16
+ : JSON.parse(responseBody ?? "", reviver);
17
17
  return result;
18
18
  };
19
19
 
@@ -7,6 +7,7 @@ import {
7
7
  MemberResetPasswordRequest,
8
8
  } from "../types";
9
9
  import { post } from "./common-client";
10
+ import { post as apiPost } from "./api";
10
11
 
11
12
  const ENDPOINT = "/api/member";
12
13
  const ENDPOINT_LOGIN = `${ENDPOINT}/login`;
@@ -35,7 +36,7 @@ export const logout = (
35
36
  const apiKey = config.apiKey;
36
37
  const body = "";
37
38
 
38
- return post(url, apiKey, body, signal);
39
+ return apiPost(url, apiKey, body, signal);
39
40
  };
40
41
 
41
42
  export const confirm = (
@@ -47,7 +48,7 @@ export const confirm = (
47
48
  const apiKey = config.apiKey;
48
49
  const body = JSON.stringify(request);
49
50
 
50
- return post(url, apiKey, body, signal);
51
+ return apiPost(url, apiKey, body, signal);
51
52
  };
52
53
 
53
54
  export const forgotPassword = (
@@ -59,7 +60,7 @@ export const forgotPassword = (
59
60
  const apiKey = config.apiKey;
60
61
  const body = JSON.stringify(request);
61
62
 
62
- return post(url, apiKey, body, signal);
63
+ return apiPost(url, apiKey, body, signal);
63
64
  };
64
65
 
65
66
  export const resetPassword = (
@@ -71,5 +72,5 @@ export const resetPassword = (
71
72
  const apiKey = config.apiKey;
72
73
  const body = JSON.stringify(request);
73
74
 
74
- return post(url, apiKey, body, signal);
75
+ return apiPost(url, apiKey, body, signal);
75
76
  };