@nicertravel/sdk 0.0.0 → 1.0.0-beta.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.
- package/README.md +89 -3
- package/dist/_/codec.d.ts +93 -0
- package/dist/_/codec.js +298 -0
- package/dist/_/error.d.ts +27 -0
- package/dist/_/error.js +68 -0
- package/dist/_/hooks/envelope.d.ts +11 -0
- package/dist/_/hooks/envelope.js +15 -0
- package/dist/_/index.d.ts +3 -0
- package/dist/_/index.js +5 -0
- package/dist/_/transport.d.ts +146 -0
- package/dist/_/transport.js +220 -0
- package/dist/activities/client.d.ts +35 -0
- package/dist/activities/client.js +23 -0
- package/dist/activities/index.d.ts +5 -0
- package/dist/activities/index.js +4 -0
- package/dist/activities/models.d.ts +27 -0
- package/dist/activities/models.js +3 -0
- package/dist/activityDestinations/client.d.ts +24 -0
- package/dist/activityDestinations/client.js +17 -0
- package/dist/activityDestinations/index.d.ts +4 -0
- package/dist/activityDestinations/index.js +4 -0
- package/dist/balances/client.d.ts +29 -0
- package/dist/balances/client.js +18 -0
- package/dist/balances/index.d.ts +5 -0
- package/dist/balances/index.js +4 -0
- package/dist/balances/models.d.ts +12 -0
- package/dist/balances/models.js +3 -0
- package/dist/bookingSelections/client.d.ts +54 -0
- package/dist/bookingSelections/client.js +25 -0
- package/dist/bookingSelections/index.d.ts +5 -0
- package/dist/bookingSelections/index.js +4 -0
- package/dist/bookingSelections/models.d.ts +35 -0
- package/dist/bookingSelections/models.js +3 -0
- package/dist/carRentals/client.d.ts +55 -0
- package/dist/carRentals/client.js +25 -0
- package/dist/carRentals/index.d.ts +5 -0
- package/dist/carRentals/index.js +4 -0
- package/dist/carRentals/models.d.ts +157 -0
- package/dist/carRentals/models.js +3 -0
- package/dist/carriers/client.d.ts +32 -0
- package/dist/carriers/client.js +18 -0
- package/dist/carriers/index.d.ts +5 -0
- package/dist/carriers/index.js +4 -0
- package/dist/carriers/models.d.ts +9 -0
- package/dist/carriers/models.js +3 -0
- package/dist/chats/client.d.ts +69 -0
- package/dist/chats/client.js +38 -0
- package/dist/chats/index.d.ts +5 -0
- package/dist/chats/index.js +4 -0
- package/dist/chats/models.d.ts +25 -0
- package/dist/chats/models.js +3 -0
- package/dist/checkouts/client.d.ts +27 -0
- package/dist/checkouts/client.js +18 -0
- package/dist/checkouts/index.d.ts +5 -0
- package/dist/checkouts/index.js +4 -0
- package/dist/checkouts/models.d.ts +23 -0
- package/dist/checkouts/models.js +3 -0
- package/dist/client.d.ts +95 -0
- package/dist/client.js +220 -0
- package/dist/commissionExports/client.d.ts +62 -0
- package/dist/commissionExports/client.js +33 -0
- package/dist/commissionExports/index.d.ts +5 -0
- package/dist/commissionExports/index.js +4 -0
- package/dist/commissionExports/models.d.ts +165 -0
- package/dist/commissionExports/models.js +3 -0
- package/dist/commissionImports/client.d.ts +61 -0
- package/dist/commissionImports/client.js +34 -0
- package/dist/commissionImports/index.d.ts +5 -0
- package/dist/commissionImports/index.js +4 -0
- package/dist/commissionImports/models.d.ts +118 -0
- package/dist/commissionImports/models.js +3 -0
- package/dist/commissionItems/client.d.ts +128 -0
- package/dist/commissionItems/client.js +41 -0
- package/dist/commissionItems/index.d.ts +5 -0
- package/dist/commissionItems/index.js +4 -0
- package/dist/commissionItems/models.d.ts +217 -0
- package/dist/commissionItems/models.js +3 -0
- package/dist/commissionReports/client.d.ts +76 -0
- package/dist/commissionReports/client.js +18 -0
- package/dist/commissionReports/index.d.ts +5 -0
- package/dist/commissionReports/index.js +4 -0
- package/dist/commissionReports/models.d.ts +208 -0
- package/dist/commissionReports/models.js +3 -0
- package/dist/crmSettings/client.d.ts +50 -0
- package/dist/crmSettings/client.js +25 -0
- package/dist/crmSettings/index.d.ts +5 -0
- package/dist/crmSettings/index.js +4 -0
- package/dist/crmSettings/models.d.ts +313 -0
- package/dist/crmSettings/models.js +3 -0
- package/dist/earnings/client.d.ts +30 -0
- package/dist/earnings/client.js +18 -0
- package/dist/earnings/index.d.ts +5 -0
- package/dist/earnings/index.js +4 -0
- package/dist/earnings/models.d.ts +16 -0
- package/dist/earnings/models.js +3 -0
- package/dist/externalBookings/client.d.ts +56 -0
- package/dist/externalBookings/client.js +33 -0
- package/dist/externalBookings/index.d.ts +5 -0
- package/dist/externalBookings/index.js +4 -0
- package/dist/externalBookings/models.d.ts +93 -0
- package/dist/externalBookings/models.js +3 -0
- package/dist/externalPayments/client.d.ts +23 -0
- package/dist/externalPayments/client.js +18 -0
- package/dist/externalPayments/index.d.ts +5 -0
- package/dist/externalPayments/index.js +4 -0
- package/dist/externalPayments/models.d.ts +47 -0
- package/dist/externalPayments/models.js +3 -0
- package/dist/favorites/client.d.ts +87 -0
- package/dist/favorites/client.js +63 -0
- package/dist/favorites/index.d.ts +5 -0
- package/dist/favorites/index.js +4 -0
- package/dist/favorites/models.d.ts +79 -0
- package/dist/favorites/models.js +3 -0
- package/dist/flightSchedules/client.d.ts +29 -0
- package/dist/flightSchedules/client.js +18 -0
- package/dist/flightSchedules/index.d.ts +5 -0
- package/dist/flightSchedules/index.js +4 -0
- package/dist/flightSchedules/models.d.ts +25 -0
- package/dist/flightSchedules/models.js +3 -0
- package/dist/flights/client.d.ts +73 -0
- package/dist/flights/client.js +25 -0
- package/dist/flights/index.d.ts +5 -0
- package/dist/flights/index.js +4 -0
- package/dist/flights/models.d.ts +345 -0
- package/dist/flights/models.js +3 -0
- package/dist/hotels/client.d.ts +104 -0
- package/dist/hotels/client.js +26 -0
- package/dist/hotels/index.d.ts +5 -0
- package/dist/hotels/index.js +4 -0
- package/dist/hotels/models.d.ts +355 -0
- package/dist/hotels/models.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/insuranceQuotes/client.d.ts +27 -0
- package/dist/insuranceQuotes/client.js +18 -0
- package/dist/insuranceQuotes/index.d.ts +5 -0
- package/dist/insuranceQuotes/index.js +4 -0
- package/dist/insuranceQuotes/models.d.ts +76 -0
- package/dist/insuranceQuotes/models.js +3 -0
- package/dist/itineraries/client.d.ts +165 -0
- package/dist/itineraries/client.js +86 -0
- package/dist/itineraries/index.d.ts +5 -0
- package/dist/itineraries/index.js +4 -0
- package/dist/itineraries/models.d.ts +1619 -0
- package/dist/itineraries/models.js +4 -0
- package/dist/models.d.ts +1361 -0
- package/dist/models.js +3 -0
- package/dist/notes/client.d.ts +82 -0
- package/dist/notes/client.js +41 -0
- package/dist/notes/index.d.ts +5 -0
- package/dist/notes/index.js +4 -0
- package/dist/notes/models.d.ts +116 -0
- package/dist/notes/models.js +3 -0
- package/dist/offers/client.d.ts +27 -0
- package/dist/offers/client.js +17 -0
- package/dist/offers/index.d.ts +5 -0
- package/dist/offers/index.js +4 -0
- package/dist/offers/models.d.ts +19 -0
- package/dist/offers/models.js +3 -0
- package/dist/options/index.d.ts +114 -0
- package/dist/options/index.js +115 -0
- package/dist/orders/client.d.ts +154 -0
- package/dist/orders/client.js +65 -0
- package/dist/orders/index.d.ts +5 -0
- package/dist/orders/index.js +4 -0
- package/dist/orders/models.d.ts +2510 -0
- package/dist/orders/models.js +3 -0
- package/dist/payees/client.d.ts +48 -0
- package/dist/payees/client.js +26 -0
- package/dist/payees/index.d.ts +5 -0
- package/dist/payees/index.js +4 -0
- package/dist/payees/models.d.ts +50 -0
- package/dist/payees/models.js +3 -0
- package/dist/paymentMethods/client.d.ts +24 -0
- package/dist/paymentMethods/client.js +18 -0
- package/dist/paymentMethods/index.d.ts +5 -0
- package/dist/paymentMethods/index.js +4 -0
- package/dist/paymentMethods/models.d.ts +60 -0
- package/dist/paymentMethods/models.js +3 -0
- package/dist/places/client.d.ts +61 -0
- package/dist/places/client.js +25 -0
- package/dist/places/index.d.ts +5 -0
- package/dist/places/index.js +4 -0
- package/dist/places/models.d.ts +51 -0
- package/dist/places/models.js +3 -0
- package/dist/profileForms/client.d.ts +38 -0
- package/dist/profileForms/client.js +25 -0
- package/dist/profileForms/index.d.ts +5 -0
- package/dist/profileForms/index.js +4 -0
- package/dist/profileForms/models.d.ts +24 -0
- package/dist/profileForms/models.js +3 -0
- package/dist/quotes/client.d.ts +30 -0
- package/dist/quotes/client.js +18 -0
- package/dist/quotes/index.d.ts +5 -0
- package/dist/quotes/index.js +4 -0
- package/dist/quotes/models.d.ts +47 -0
- package/dist/quotes/models.js +3 -0
- package/dist/remittanceBatches/client.d.ts +78 -0
- package/dist/remittanceBatches/client.js +42 -0
- package/dist/remittanceBatches/index.d.ts +5 -0
- package/dist/remittanceBatches/index.js +4 -0
- package/dist/remittanceBatches/models.d.ts +131 -0
- package/dist/remittanceBatches/models.js +3 -0
- package/dist/remittanceClaims/client.d.ts +27 -0
- package/dist/remittanceClaims/client.js +18 -0
- package/dist/remittanceClaims/index.d.ts +5 -0
- package/dist/remittanceClaims/index.js +4 -0
- package/dist/remittanceClaims/models.d.ts +5 -0
- package/dist/remittanceClaims/models.js +3 -0
- package/dist/remittanceLines/client.d.ts +27 -0
- package/dist/remittanceLines/client.js +18 -0
- package/dist/remittanceLines/index.d.ts +5 -0
- package/dist/remittanceLines/index.js +4 -0
- package/dist/remittanceLines/models.d.ts +5 -0
- package/dist/remittanceLines/models.js +3 -0
- package/dist/remittances/client.d.ts +78 -0
- package/dist/remittances/client.js +42 -0
- package/dist/remittances/index.d.ts +5 -0
- package/dist/remittances/index.js +4 -0
- package/dist/remittances/models.d.ts +116 -0
- package/dist/remittances/models.js +3 -0
- package/dist/statements/client.d.ts +75 -0
- package/dist/statements/client.js +34 -0
- package/dist/statements/index.d.ts +5 -0
- package/dist/statements/index.js +4 -0
- package/dist/statements/models.d.ts +147 -0
- package/dist/statements/models.js +3 -0
- package/dist/suppliers/client.d.ts +71 -0
- package/dist/suppliers/client.js +41 -0
- package/dist/suppliers/index.d.ts +5 -0
- package/dist/suppliers/index.js +4 -0
- package/dist/suppliers/models.d.ts +130 -0
- package/dist/suppliers/models.js +3 -0
- package/dist/taskTemplates/client.d.ts +36 -0
- package/dist/taskTemplates/client.js +18 -0
- package/dist/taskTemplates/index.d.ts +5 -0
- package/dist/taskTemplates/index.js +4 -0
- package/dist/taskTemplates/models.d.ts +15 -0
- package/dist/taskTemplates/models.js +3 -0
- package/dist/tasks/client.d.ts +105 -0
- package/dist/tasks/client.js +41 -0
- package/dist/tasks/index.d.ts +5 -0
- package/dist/tasks/index.js +4 -0
- package/dist/tasks/models.d.ts +59 -0
- package/dist/tasks/models.js +3 -0
- package/dist/timeline/client.d.ts +42 -0
- package/dist/timeline/client.js +18 -0
- package/dist/timeline/index.d.ts +5 -0
- package/dist/timeline/index.js +4 -0
- package/dist/timeline/models.d.ts +65 -0
- package/dist/timeline/models.js +3 -0
- package/dist/travelProfile/client.d.ts +56 -0
- package/dist/travelProfile/client.js +25 -0
- package/dist/travelProfile/index.d.ts +5 -0
- package/dist/travelProfile/index.js +4 -0
- package/dist/travelProfile/models.d.ts +95 -0
- package/dist/travelProfile/models.js +3 -0
- package/dist/travelers/client.d.ts +214 -0
- package/dist/travelers/client.js +76 -0
- package/dist/travelers/index.d.ts +5 -0
- package/dist/travelers/index.js +4 -0
- package/dist/travelers/models.d.ts +576 -0
- package/dist/travelers/models.js +3 -0
- package/dist/trips/client.d.ts +224 -0
- package/dist/trips/client.js +88 -0
- package/dist/trips/index.d.ts +5 -0
- package/dist/trips/index.js +4 -0
- package/dist/trips/models.d.ts +486 -0
- package/dist/trips/models.js +3 -0
- package/package.json +35 -2
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { type Codec } from './codec.js';
|
|
2
|
+
/**
|
|
3
|
+
* The options every client takes.
|
|
4
|
+
*/
|
|
5
|
+
export interface BaseClientOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The API token, sent as `Authorization: Bearer <token>`.
|
|
8
|
+
*/
|
|
9
|
+
token: string;
|
|
10
|
+
/**
|
|
11
|
+
* The URL the paths of the API are relative to.
|
|
12
|
+
*/
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The fetch function to send requests with; the global one by default.
|
|
16
|
+
*/
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
/**
|
|
19
|
+
* Headers sent with every request.
|
|
20
|
+
*/
|
|
21
|
+
headers?: HeadersInit;
|
|
22
|
+
/**
|
|
23
|
+
* Query parameters sent with every request.
|
|
24
|
+
*/
|
|
25
|
+
query?: URLSearchParams;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The options of a call. Every member is optional.
|
|
29
|
+
*/
|
|
30
|
+
export interface RequestOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Aborts the request.
|
|
33
|
+
*/
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
/**
|
|
36
|
+
* Headers sent with the request, which replace those of the client.
|
|
37
|
+
*/
|
|
38
|
+
headers?: HeadersInit;
|
|
39
|
+
/**
|
|
40
|
+
* Query parameters appended after those of the client.
|
|
41
|
+
*/
|
|
42
|
+
query?: URLSearchParams;
|
|
43
|
+
/**
|
|
44
|
+
* Called with the response before its body is read.
|
|
45
|
+
*/
|
|
46
|
+
onResponse?: (response: Response) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* How a paginated operation moves from one page to the next. Each function
|
|
50
|
+
* reads the response of a page, and the value of `param` that picked it.
|
|
51
|
+
*/
|
|
52
|
+
export interface Pagination {
|
|
53
|
+
/**
|
|
54
|
+
* Returns the items of a page.
|
|
55
|
+
*/
|
|
56
|
+
items(response: unknown): readonly unknown[] | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The request field that picks the page.
|
|
59
|
+
*/
|
|
60
|
+
param: string;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the value of `param` for the next page.
|
|
63
|
+
*/
|
|
64
|
+
next(response: unknown, param: unknown): unknown;
|
|
65
|
+
/**
|
|
66
|
+
* Returns whether there is a next page.
|
|
67
|
+
*/
|
|
68
|
+
more(response: unknown, param: unknown): unknown;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* An operation of the API, as the generated clients describe it.
|
|
72
|
+
*/
|
|
73
|
+
export interface Operation {
|
|
74
|
+
/**
|
|
75
|
+
* The HTTP method.
|
|
76
|
+
*/
|
|
77
|
+
method: string;
|
|
78
|
+
/**
|
|
79
|
+
* The path of the URL, with each path parameter as `{field}`.
|
|
80
|
+
*/
|
|
81
|
+
route: string;
|
|
82
|
+
/**
|
|
83
|
+
* The path parameters that fall back to the client's options.
|
|
84
|
+
*/
|
|
85
|
+
variables?: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* The wire names of the query parameters, by field.
|
|
88
|
+
*/
|
|
89
|
+
query?: {
|
|
90
|
+
readonly [field: string]: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The query parameters whose arrays are joined with commas.
|
|
94
|
+
*/
|
|
95
|
+
joined?: readonly string[];
|
|
96
|
+
/**
|
|
97
|
+
* Where the body is: the fields of the request that are not parameters
|
|
98
|
+
* ("flat"), or its `body` field ("nested"). No body when absent.
|
|
99
|
+
*/
|
|
100
|
+
body?: 'flat' | 'nested';
|
|
101
|
+
/**
|
|
102
|
+
* The media type of the body, when not application/json.
|
|
103
|
+
*/
|
|
104
|
+
contentType?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The codec of the body, when it has something to convert.
|
|
107
|
+
*/
|
|
108
|
+
request?: Codec;
|
|
109
|
+
/**
|
|
110
|
+
* The codec of the response body, null when it has nothing to convert,
|
|
111
|
+
* and absent when the operation has no response body.
|
|
112
|
+
*/
|
|
113
|
+
response?: Codec | null;
|
|
114
|
+
/**
|
|
115
|
+
* The declared error responses, by status, range such as "4XX", or
|
|
116
|
+
* "default": the codec of the body, true for a JSON body with nothing to
|
|
117
|
+
* convert, and false for a body that is not JSON.
|
|
118
|
+
*/
|
|
119
|
+
errors?: {
|
|
120
|
+
readonly [status: string]: Codec | boolean;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* How the operation pages.
|
|
124
|
+
*/
|
|
125
|
+
pagination?: Pagination;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Sends the requests of the generated clients.
|
|
129
|
+
*/
|
|
130
|
+
export declare class Transport {
|
|
131
|
+
#private;
|
|
132
|
+
/**
|
|
133
|
+
* Checks the options of a client. `baseUrl` is used when the options have
|
|
134
|
+
* none.
|
|
135
|
+
*/
|
|
136
|
+
constructor(options: BaseClientOptions, baseUrl?: string);
|
|
137
|
+
/**
|
|
138
|
+
* Sends a request for operation and returns its decoded response.
|
|
139
|
+
*/
|
|
140
|
+
send<T>(operation: Operation, request: object | undefined, options: RequestOptions | undefined): Promise<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Sends a request for a paginated operation. Awaiting the result gives
|
|
143
|
+
* the first page, and iterating it gives every item of every page.
|
|
144
|
+
*/
|
|
145
|
+
paginate<T, I>(operation: Operation, request: object | undefined, options: RequestOptions | undefined): Promise<T> & AsyncIterable<I>;
|
|
146
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Code generated by forge. DO NOT EDIT.
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { isRecord, parse, set, toBase64 } from './codec.js';
|
|
4
|
+
import { ApiError, errorMessage } from './error.js';
|
|
5
|
+
import { unwrapEnvelope } from './hooks/envelope.js';
|
|
6
|
+
// The fields of each operation that are parameters rather than body.
|
|
7
|
+
const paramFields = new WeakMap();
|
|
8
|
+
function paramsOf(operation) {
|
|
9
|
+
let fields = paramFields.get(operation);
|
|
10
|
+
if (fields === undefined) {
|
|
11
|
+
fields = new Set(Object.keys(operation.query ?? {}));
|
|
12
|
+
for (const [, field] of operation.route.matchAll(/\{([^}]+)\}/g)) {
|
|
13
|
+
fields.add(field);
|
|
14
|
+
}
|
|
15
|
+
paramFields.set(operation, fields);
|
|
16
|
+
}
|
|
17
|
+
return fields;
|
|
18
|
+
}
|
|
19
|
+
function toParam(value) {
|
|
20
|
+
if (value instanceof Uint8Array) {
|
|
21
|
+
return toBase64(value);
|
|
22
|
+
}
|
|
23
|
+
if (isRecord(value)) {
|
|
24
|
+
return JSON.stringify(value);
|
|
25
|
+
}
|
|
26
|
+
return String(value);
|
|
27
|
+
}
|
|
28
|
+
function lookup(errors, status) {
|
|
29
|
+
if (errors === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
for (const key of [String(status), `${Math.floor(status / 100)}XX`]) {
|
|
33
|
+
if (Object.hasOwn(errors, key)) {
|
|
34
|
+
return errors[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return Object.hasOwn(errors, 'default') ? errors['default'] : undefined;
|
|
38
|
+
}
|
|
39
|
+
async function apiError(operation, response) {
|
|
40
|
+
const text = await response.text();
|
|
41
|
+
let body;
|
|
42
|
+
let json = false;
|
|
43
|
+
if (text !== '') {
|
|
44
|
+
try {
|
|
45
|
+
body = parse(text);
|
|
46
|
+
json = true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// The body is kept as text.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const declared = lookup(operation.errors, response.status);
|
|
53
|
+
let details = text === '' ? undefined : text;
|
|
54
|
+
if (json && declared !== undefined && declared !== false) {
|
|
55
|
+
details = declared === true ? body : declared.decode(body);
|
|
56
|
+
}
|
|
57
|
+
const message = (json ? errorMessage(body) : undefined) ?? `${response.status} ${response.statusText}`.trim();
|
|
58
|
+
return new ApiError(message, response, details);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sends the requests of the generated clients.
|
|
62
|
+
*/
|
|
63
|
+
export class Transport {
|
|
64
|
+
#options;
|
|
65
|
+
#baseUrl;
|
|
66
|
+
/**
|
|
67
|
+
* Checks the options of a client. `baseUrl` is used when the options have
|
|
68
|
+
* none.
|
|
69
|
+
*/
|
|
70
|
+
constructor(options, baseUrl) {
|
|
71
|
+
if (typeof options?.token !== 'string' || options.token === '') {
|
|
72
|
+
throw new TypeError('createClient: token is required');
|
|
73
|
+
}
|
|
74
|
+
const url = options.baseUrl ?? baseUrl;
|
|
75
|
+
if (url === undefined || url === '') {
|
|
76
|
+
throw new TypeError('createClient: baseUrl is required');
|
|
77
|
+
}
|
|
78
|
+
this.#options = options;
|
|
79
|
+
this.#baseUrl = url.replace(/\/+$/, '');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sends a request for operation and returns its decoded response.
|
|
83
|
+
*/
|
|
84
|
+
send(operation, request, options) {
|
|
85
|
+
return this.#send(operation, (request ?? {}), options);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sends a request for a paginated operation. Awaiting the result gives
|
|
89
|
+
* the first page, and iterating it gives every item of every page.
|
|
90
|
+
*/
|
|
91
|
+
paginate(operation, request, options) {
|
|
92
|
+
const fields = (request ?? {});
|
|
93
|
+
const first = this.#send(operation, fields, options);
|
|
94
|
+
return Object.assign(first, {
|
|
95
|
+
[Symbol.asyncIterator]: () => this.#items(operation, fields, options, first),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async *#items(operation, request, options, first) {
|
|
99
|
+
const pagination = operation.pagination;
|
|
100
|
+
let current = request;
|
|
101
|
+
let response = await first;
|
|
102
|
+
for (;;) {
|
|
103
|
+
yield* pagination.items(response) ?? [];
|
|
104
|
+
const param = current[pagination.param];
|
|
105
|
+
if (!pagination.more(response, param)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const next = pagination.next(response, param);
|
|
109
|
+
// A next page that is the one just fetched would loop forever.
|
|
110
|
+
if (next === undefined || next === null || next === param) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
current = { ...current, [pagination.param]: next };
|
|
114
|
+
response = await this.#send(operation, current, options);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async #send(operation, request, options) {
|
|
118
|
+
const url = this.#url(operation, request, options);
|
|
119
|
+
const headers = new Headers({ accept: 'application/json' });
|
|
120
|
+
headers.set('authorization', `Bearer ${this.#options.token}`);
|
|
121
|
+
const init = { method: operation.method, headers };
|
|
122
|
+
const body = this.#body(operation, request);
|
|
123
|
+
if (body !== undefined) {
|
|
124
|
+
headers.set('content-type', operation.contentType ?? 'application/json');
|
|
125
|
+
init.body = JSON.stringify(body);
|
|
126
|
+
}
|
|
127
|
+
new Headers(this.#options.headers).forEach((value, key) => {
|
|
128
|
+
headers.set(key, value);
|
|
129
|
+
});
|
|
130
|
+
new Headers(options?.headers).forEach((value, key) => {
|
|
131
|
+
headers.set(key, value);
|
|
132
|
+
});
|
|
133
|
+
if (options?.signal !== undefined) {
|
|
134
|
+
init.signal = options.signal;
|
|
135
|
+
}
|
|
136
|
+
const fetcher = this.#options.fetch ?? fetch;
|
|
137
|
+
const response = await fetcher(url, init);
|
|
138
|
+
options?.onResponse?.(response);
|
|
139
|
+
if (response.status < 200 || response.status > 299) {
|
|
140
|
+
throw await apiError(operation, response);
|
|
141
|
+
}
|
|
142
|
+
if (operation.response === undefined) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
const text = await response.text();
|
|
146
|
+
if (text === '') {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
let value;
|
|
150
|
+
try {
|
|
151
|
+
value = parse(text);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
throw new ApiError('the response body is not valid JSON', response, text, {
|
|
155
|
+
cause: e,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
value = unwrapEnvelope(response, value);
|
|
159
|
+
return operation.response === null ? value : operation.response.decode(value);
|
|
160
|
+
}
|
|
161
|
+
#url(operation, request, options) {
|
|
162
|
+
const client = this.#options;
|
|
163
|
+
const path = operation.route.replace(/\{([^}]+)\}/g, (_, field) => {
|
|
164
|
+
let value = request[field];
|
|
165
|
+
if (value === undefined && operation.variables?.includes(field)) {
|
|
166
|
+
value = client[field];
|
|
167
|
+
}
|
|
168
|
+
if (value === undefined || value === null || value === '') {
|
|
169
|
+
throw new TypeError(`${field} is required: set it in the request or the client options`);
|
|
170
|
+
}
|
|
171
|
+
return encodeURIComponent(toParam(value));
|
|
172
|
+
});
|
|
173
|
+
const url = new URL(this.#baseUrl + path);
|
|
174
|
+
const query = url.searchParams;
|
|
175
|
+
for (const [field, wire] of Object.entries(operation.query ?? {})) {
|
|
176
|
+
const value = request[field];
|
|
177
|
+
if (value === undefined || value === null) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (!Array.isArray(value)) {
|
|
181
|
+
query.append(wire, toParam(value));
|
|
182
|
+
}
|
|
183
|
+
else if (operation.joined?.includes(field)) {
|
|
184
|
+
query.append(wire, value.map(toParam).join(','));
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
for (const item of value) {
|
|
188
|
+
query.append(wire, toParam(item));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this.#options.query?.forEach((value, key) => {
|
|
193
|
+
query.append(key, value);
|
|
194
|
+
});
|
|
195
|
+
options?.query?.forEach((value, key) => {
|
|
196
|
+
query.append(key, value);
|
|
197
|
+
});
|
|
198
|
+
return url;
|
|
199
|
+
}
|
|
200
|
+
#body(operation, request) {
|
|
201
|
+
let body;
|
|
202
|
+
if (operation.body === 'nested') {
|
|
203
|
+
body = request['body'];
|
|
204
|
+
}
|
|
205
|
+
else if (operation.body === 'flat') {
|
|
206
|
+
const params = paramsOf(operation);
|
|
207
|
+
const fields = {};
|
|
208
|
+
for (const key of Object.keys(request)) {
|
|
209
|
+
if (!params.has(key)) {
|
|
210
|
+
set(fields, key, request[key]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
body = fields;
|
|
214
|
+
}
|
|
215
|
+
if (body === undefined || operation.request === undefined) {
|
|
216
|
+
return body;
|
|
217
|
+
}
|
|
218
|
+
return operation.request.encode(body);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type BaseClientOptions, type RequestOptions, Transport } from "../_/index.js";
|
|
2
|
+
import type { SearchProductsBody } from "./models.js";
|
|
3
|
+
export interface ClientOptions extends BaseClientOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The URL the paths of the API are relative to.
|
|
6
|
+
*/
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Client {
|
|
10
|
+
/**
|
|
11
|
+
* Get a tour or activity
|
|
12
|
+
*
|
|
13
|
+
* Returns one the activities provider product by its product code, shaped as
|
|
14
|
+
* an itinerary activity segment. Because the provider's detail call carries
|
|
15
|
+
* no pricing, pass the price seen in search results to have it preserved on
|
|
16
|
+
* the segment.
|
|
17
|
+
*/
|
|
18
|
+
get(request: GetRequest, options?: RequestOptions): Promise<GetResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Search tours and activities
|
|
21
|
+
*
|
|
22
|
+
* Searches the the activities provider catalogue for tours and activities and
|
|
23
|
+
* returns them already shaped as itinerary activity segments, with paging and
|
|
24
|
+
* the currency the prices are quoted in.
|
|
25
|
+
*/
|
|
26
|
+
search(request: SearchRequest, options?: RequestOptions): Promise<SearchResponse>;
|
|
27
|
+
}
|
|
28
|
+
export declare function createClient(options: ClientOptions): Client;
|
|
29
|
+
export declare function bind(transport: Transport): Client;
|
|
30
|
+
export interface GetRequest {
|
|
31
|
+
productCode: string;
|
|
32
|
+
}
|
|
33
|
+
export type GetResponse = void;
|
|
34
|
+
export type SearchRequest = SearchProductsBody;
|
|
35
|
+
export type SearchResponse = void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Code generated by forge. DO NOT EDIT.
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { Transport, } from "../_/index.js";
|
|
4
|
+
export function createClient(options) {
|
|
5
|
+
return bind(new Transport(options));
|
|
6
|
+
}
|
|
7
|
+
export function bind(transport) {
|
|
8
|
+
return {
|
|
9
|
+
get: (request, options) => transport.send(GetOperation, request, options),
|
|
10
|
+
search: (request, options) => transport.send(SearchOperation, request, options),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const GetOperation = {
|
|
14
|
+
method: "GET",
|
|
15
|
+
route: "/tour-viator/products/{productCode}",
|
|
16
|
+
errors: { "400": true, "401": true, "403": true },
|
|
17
|
+
};
|
|
18
|
+
const SearchOperation = {
|
|
19
|
+
method: "POST",
|
|
20
|
+
route: "/tour-viator/products",
|
|
21
|
+
body: "flat",
|
|
22
|
+
errors: { "400": true, "401": true, "403": true },
|
|
23
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ApiError } from "../_/index.js";
|
|
2
|
+
export type { RequestOptions } from "../_/index.js";
|
|
3
|
+
export { createClient } from "./client.js";
|
|
4
|
+
export type { Client, ClientOptions, GetRequest, GetResponse, SearchRequest, SearchResponse, } from "./client.js";
|
|
5
|
+
export type { SearchProductsBody } from "./models.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface SearchProductsBody {
|
|
2
|
+
currency?: string;
|
|
3
|
+
dates?: {
|
|
4
|
+
endDate: string;
|
|
5
|
+
startDate: string;
|
|
6
|
+
};
|
|
7
|
+
destinationId: string;
|
|
8
|
+
filters?: {
|
|
9
|
+
duration?: {
|
|
10
|
+
maxMinutes?: number;
|
|
11
|
+
minMinutes?: number;
|
|
12
|
+
};
|
|
13
|
+
flags?: ("NEW_ON_VIATOR" | "FREE_CANCELLATION" | "SKIP_THE_LINE" | "PRIVATE_TOUR" | "SPECIAL_OFFER" | "LIKELY_TO_SELL_OUT")[];
|
|
14
|
+
priceRange?: {
|
|
15
|
+
max?: number;
|
|
16
|
+
min?: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
pagination?: {
|
|
20
|
+
page?: number;
|
|
21
|
+
pageSize?: number;
|
|
22
|
+
};
|
|
23
|
+
sort?: {
|
|
24
|
+
direction: "asc" | "desc";
|
|
25
|
+
field: "price" | "recommended";
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type BaseClientOptions, type RequestOptions, Transport } from "../_/index.js";
|
|
2
|
+
export interface ClientOptions extends BaseClientOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The URL the paths of the API are relative to.
|
|
5
|
+
*/
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Client {
|
|
9
|
+
/**
|
|
10
|
+
* Search tour destinations
|
|
11
|
+
*
|
|
12
|
+
* Text search over the activities provider destinations, optionally bounded
|
|
13
|
+
* by a radius, used to anchor an activity search to a place.
|
|
14
|
+
*/
|
|
15
|
+
search(request: SearchRequest, options?: RequestOptions): Promise<SearchResponse>;
|
|
16
|
+
}
|
|
17
|
+
export declare function createClient(options: ClientOptions): Client;
|
|
18
|
+
export declare function bind(transport: Transport): Client;
|
|
19
|
+
export interface SearchRequest {
|
|
20
|
+
query: string;
|
|
21
|
+
radiusKm?: number;
|
|
22
|
+
limit?: number;
|
|
23
|
+
}
|
|
24
|
+
export type SearchResponse = void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Code generated by forge. DO NOT EDIT.
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { Transport, } from "../_/index.js";
|
|
4
|
+
export function createClient(options) {
|
|
5
|
+
return bind(new Transport(options));
|
|
6
|
+
}
|
|
7
|
+
export function bind(transport) {
|
|
8
|
+
return {
|
|
9
|
+
search: (request, options) => transport.send(SearchOperation, request, options),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const SearchOperation = {
|
|
13
|
+
method: "GET",
|
|
14
|
+
route: "/tour-viator/destinations",
|
|
15
|
+
query: { query: "query", radiusKm: "radiusKm", limit: "limit" },
|
|
16
|
+
errors: { "400": true, "401": true, "403": true },
|
|
17
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type BaseClientOptions, type RequestOptions, Transport } from "../_/index.js";
|
|
2
|
+
import type { BalancesGetResponse } from "./models.js";
|
|
3
|
+
export interface ClientOptions extends BaseClientOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The URL the paths of the API are relative to.
|
|
6
|
+
*/
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Client {
|
|
10
|
+
/**
|
|
11
|
+
* Get account balances
|
|
12
|
+
*
|
|
13
|
+
* Returns the company's ledger balances by beneficiary and currency,
|
|
14
|
+
* optionally narrowed to one beneficiary or to a beneficiary kind (advisor,
|
|
15
|
+
* company, traveler or the platform). A bucket below zero is money still
|
|
16
|
+
* owed: it counts as receivable, never as a negative balance. Advisors and
|
|
17
|
+
* travelers see their own; admins anyone's of the company, and Nicer staff
|
|
18
|
+
* anyone's of the company they name in `x-nicer-company` (each staff read is
|
|
19
|
+
* audited).
|
|
20
|
+
*/
|
|
21
|
+
list(request?: ListRequest, options?: RequestOptions): Promise<ListResponse>;
|
|
22
|
+
}
|
|
23
|
+
export declare function createClient(options: ClientOptions): Client;
|
|
24
|
+
export declare function bind(transport: Transport): Client;
|
|
25
|
+
export interface ListRequest {
|
|
26
|
+
beneficiaryId?: string;
|
|
27
|
+
beneficiaryKind?: "ADVISOR" | "COMPANY" | "NICER" | "TRAVELER";
|
|
28
|
+
}
|
|
29
|
+
export type ListResponse = BalancesGetResponse;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Code generated by forge. DO NOT EDIT.
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { Transport, } from "../_/index.js";
|
|
4
|
+
export function createClient(options) {
|
|
5
|
+
return bind(new Transport(options));
|
|
6
|
+
}
|
|
7
|
+
export function bind(transport) {
|
|
8
|
+
return {
|
|
9
|
+
list: (request, options) => transport.send(ListOperation, request, options),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const ListOperation = {
|
|
13
|
+
method: "GET",
|
|
14
|
+
route: "/commerce/finance/balances",
|
|
15
|
+
query: { beneficiaryId: "beneficiaryId", beneficiaryKind: "beneficiaryKind" },
|
|
16
|
+
response: null,
|
|
17
|
+
errors: { "400": true, "401": true, "403": true },
|
|
18
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ApiError } from "../_/index.js";
|
|
2
|
+
export type { RequestOptions } from "../_/index.js";
|
|
3
|
+
export { createClient } from "./client.js";
|
|
4
|
+
export type { Client, ClientOptions, ListRequest, ListResponse, } from "./client.js";
|
|
5
|
+
export type { BalancesGetResponse } from "./models.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CurrencyCode } from "../models.js";
|
|
2
|
+
export interface BalancesGetResponse {
|
|
3
|
+
balances: {
|
|
4
|
+
accountCode: string;
|
|
5
|
+
availableMinor: number;
|
|
6
|
+
beneficiaryId: string | null;
|
|
7
|
+
beneficiaryKind: "ADVISOR" | "COMPANY" | "NICER" | "TRAVELER";
|
|
8
|
+
currency: CurrencyCode;
|
|
9
|
+
pendingMinor: number;
|
|
10
|
+
receivableMinor: number;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type BaseClientOptions, type RequestOptions, Transport } from "../_/index.js";
|
|
2
|
+
import type { CreateBookingSelectionBody, CreateBookingSelectionResponse, GetBookingSelectionResponse } from "./models.js";
|
|
3
|
+
export interface ClientOptions extends BaseClientOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The URL the paths of the API are relative to.
|
|
6
|
+
*/
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Client {
|
|
10
|
+
/**
|
|
11
|
+
* Save an offer as a booking selection
|
|
12
|
+
*
|
|
13
|
+
* Re-validates a live search offer with the provider and stores it as a
|
|
14
|
+
* selection that stays bookable until `bookableUntil` (retained 30 days).
|
|
15
|
+
* Requires an authenticated company user and an `Idempotency-Key`; replaying
|
|
16
|
+
* the key with a different body returns 409
|
|
17
|
+
* `BOOKING_SELECTION_IDEMPOTENCY_CONFLICT`, an expired or unknown offer
|
|
18
|
+
* returns 409 `BOOKING_OFFER_UNAVAILABLE`, and a Sabre offer with no DK to
|
|
19
|
+
* book with (the advisor has none and the agency has no default DK) returns
|
|
20
|
+
* 422 `BOOKING_SABRE_DK_REQUIRED`. Returns the selection id and a preview of
|
|
21
|
+
* product, price and payment terms; the preview carries the commercial
|
|
22
|
+
* snapshot (expected commission and earnings) only for the agency's advisors
|
|
23
|
+
* and admins and for Nicer staff, and leaves it out for travelers.
|
|
24
|
+
*/
|
|
25
|
+
create(request: CreateRequest, options?: RequestOptions): Promise<CreateResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Read and re-price a booking selection
|
|
28
|
+
*
|
|
29
|
+
* Returns a stored selection and, when the last refresh is older than 15
|
|
30
|
+
* minutes, re-prices it against the provider, persists the new price and
|
|
31
|
+
* expiry, and projects them onto the linked itinerary item. Any refresh
|
|
32
|
+
* failure still serves the last stored offer; only a provider that no longer
|
|
33
|
+
* offers the product sets `availability` to `UNAVAILABLE`. Readable by
|
|
34
|
+
* whoever may open the trip it belongs to: the trip's travelers, its advisor
|
|
35
|
+
* of record (the assigned advisor, or the primary traveler of a self-booked
|
|
36
|
+
* trip without one), the agency's admins and Nicer staff; a selection outside
|
|
37
|
+
* any trip by the person who saved it, the agency's admins and Nicer staff.
|
|
38
|
+
* The preview carries the commercial snapshot (expected commission and
|
|
39
|
+
* earnings) only for the agency's advisors and admins and for Nicer staff.
|
|
40
|
+
* Returns 404 `BOOKING_SELECTION_NOT_FOUND` when missing, expired or not
|
|
41
|
+
* readable by the caller, checked before any provider call, and 409
|
|
42
|
+
* `BOOKING_SELECTION_TRAVEL_PAST` once the travel dates are more than a day
|
|
43
|
+
* past.
|
|
44
|
+
*/
|
|
45
|
+
get(request: GetRequest, options?: RequestOptions): Promise<GetResponse>;
|
|
46
|
+
}
|
|
47
|
+
export declare function createClient(options: ClientOptions): Client;
|
|
48
|
+
export declare function bind(transport: Transport): Client;
|
|
49
|
+
export type CreateRequest = CreateBookingSelectionBody;
|
|
50
|
+
export type CreateResponse = CreateBookingSelectionResponse;
|
|
51
|
+
export interface GetRequest {
|
|
52
|
+
selectionId: string;
|
|
53
|
+
}
|
|
54
|
+
export type GetResponse = GetBookingSelectionResponse;
|