@qite/tide-client 1.1.65 → 1.1.67

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.
@@ -0,0 +1,10 @@
1
+ export interface Airport {
2
+ iata: string;
3
+ name: string;
4
+ isDepartureLocation: boolean;
5
+ localizations: AirportLocalized[];
6
+ }
7
+ export interface AirportLocalized {
8
+ languageCode: string;
9
+ name: string;
10
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./affiliate";
2
+ export * from "./airport";
2
3
  export * from "./contact-form-request";
3
4
  export * from "./generate-booking-accommodation-request";
@@ -1,4 +1,4 @@
1
- import { CountryItem, PageResult, TideClientConfig } from "../types";
1
+ import { Airport, CountryItem, PageResult, TideClientConfig } from "../types";
2
2
  /**
3
3
  * api/search/countries
4
4
  * Gets all Countries
@@ -10,3 +10,7 @@ export declare const getCountries: (
10
10
  config: TideClientConfig,
11
11
  signal?: AbortSignal | undefined
12
12
  ) => Promise<PageResult<CountryItem>>;
13
+ export declare const getAirports: (
14
+ config: TideClientConfig,
15
+ signal?: AbortSignal | undefined
16
+ ) => Promise<Airport>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qite/tide-client",
3
- "version": "1.1.65",
3
+ "version": "1.1.67",
4
4
  "description": "Frontend client for Tide",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -0,0 +1,11 @@
1
+ export interface Airport {
2
+ iata: string;
3
+ name: string;
4
+ isDepartureLocation: boolean;
5
+ localizations: AirportLocalized[];
6
+ }
7
+
8
+ export interface AirportLocalized {
9
+ languageCode: string;
10
+ name: string;
11
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./affiliate";
2
+ export * from "./airport";
2
3
  export * from "./contact-form-request";
3
4
  export * from "./generate-booking-accommodation-request";
@@ -20,6 +20,10 @@ export const post = async <T>(
20
20
  );
21
21
  const responseBody = await response.text();
22
22
 
23
+ if (!responseBody) {
24
+ return null as unknown as T;
25
+ }
26
+
23
27
  const result: T = skipReviver
24
28
  ? JSON.parse(responseBody)
25
29
  : JSON.parse(responseBody, reviver);
@@ -45,6 +49,10 @@ export const patch = async <T>(
45
49
  );
46
50
  const responseBody = await response.text();
47
51
 
52
+ if (!responseBody) {
53
+ return {} as T;
54
+ }
55
+
48
56
  const result: T = skipReviver
49
57
  ? JSON.parse(responseBody)
50
58
  : JSON.parse(responseBody, reviver);
@@ -1,8 +1,9 @@
1
- import { CountryItem, PageResult, TideClientConfig } from "../types";
1
+ import { Airport, CountryItem, PageResult, TideClientConfig } from "../types";
2
2
  import { get } from "./common-client";
3
3
 
4
4
  const ENDPOINT = "/api/web/search";
5
5
  const ENDPOINT_COUNTRIES = `${ENDPOINT}/countries`;
6
+ const ENDPOINT_AIRPORTS = `${ENDPOINT}/airports`;
6
7
 
7
8
  /**
8
9
  * api/search/countries
@@ -20,3 +21,13 @@ export const getCountries = (
20
21
 
21
22
  return get(url, apiKey, config.token, signal, true);
22
23
  };
24
+
25
+ export const getAirports = (
26
+ config: TideClientConfig,
27
+ signal?: AbortSignal
28
+ ): Promise<Airport> => {
29
+ const url = `${config.host}${ENDPOINT_AIRPORTS}`;
30
+ const apiKey = config.apiKey;
31
+
32
+ return get(url, apiKey, config.token, signal, true);
33
+ };