sabre-client 0.1.0 → 0.2.0
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 +7 -7
- package/dist/{index.mjs → index.cjs} +72 -24
- package/dist/index.d.cts +5454 -0
- package/dist/index.d.ts +5346 -7352
- package/dist/index.js +45 -51
- package/package.json +15 -12
- package/dist/index.d.mts +0 -7460
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Send the request for acquiring an authentication ATK session token.
|
|
|
34
34
|
await sabre.authentication.OAuthTokenV2();
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
### Get booking
|
|
38
38
|
|
|
39
39
|
Displays comprehensive booking details irrespective of source, optionally narrowing down the response to selected elements.
|
|
40
40
|
|
|
@@ -45,7 +45,7 @@ await sabre.booking.get({
|
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
### Create booking
|
|
49
49
|
|
|
50
50
|
Creates an air booking (NDC/ATPCO/LCC).
|
|
51
51
|
|
|
@@ -53,7 +53,7 @@ Creates an air booking (NDC/ATPCO/LCC).
|
|
|
53
53
|
await sabre.booking.create(options);
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
### Modify Booking
|
|
57
57
|
|
|
58
58
|
Creates a list of booking items that need to be modified.
|
|
59
59
|
|
|
@@ -61,7 +61,7 @@ Creates a list of booking items that need to be modified.
|
|
|
61
61
|
await sabre.booking.modify(options);
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
### Cancel Booking
|
|
65
65
|
|
|
66
66
|
Cancels a booking or specified booking items, optionally voiding or refunding related flight tickets.
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ Cancels a booking or specified booking items, optionally voiding or refunding re
|
|
|
69
69
|
await sabre.booking.cancel(options);
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
### Void Flight Tickets
|
|
73
73
|
|
|
74
74
|
Voids tickets with ticket numbers listed in the request, optionally including nonelectronic tickets (paper).
|
|
75
75
|
|
|
@@ -77,7 +77,7 @@ Voids tickets with ticket numbers listed in the request, optionally including no
|
|
|
77
77
|
await sabre.flightTickets.void(options);
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
### Refund Flight Tickets
|
|
81
81
|
|
|
82
82
|
Processes tickets by providing a request containing a list of ticket numbers which should be refunded. EMDs are currently not supported.
|
|
83
83
|
|
|
@@ -85,7 +85,7 @@ Processes tickets by providing a request containing a list of ticket numbers whi
|
|
|
85
85
|
await sabre.flightTickets.refund(options);
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
### Check Flight Tickets
|
|
89
89
|
|
|
90
90
|
Checks tickets with ticket numbers listed in the request for void, refund and exchange conditions. EMDs are currently not supported.
|
|
91
91
|
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Sabre: () => Sabre
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
1
27
|
// src/authentication/authentication.ts
|
|
2
28
|
var grantType = new URLSearchParams({ "grant_type": "client_credentials" }).toString();
|
|
3
29
|
var Authentication = class {
|
|
@@ -5,24 +31,22 @@ var Authentication = class {
|
|
|
5
31
|
this.sabre = sabre;
|
|
6
32
|
}
|
|
7
33
|
/**
|
|
8
|
-
*
|
|
34
|
+
* OAuth Token Create REST API v2
|
|
9
35
|
* See https://developer.sabre.com/docs/rest_apis/session_management/token_create_api/v2
|
|
10
36
|
* @param payload El tipo de concesión utilizado para obtener el token. Sólo se admiten 'client_credentials'.
|
|
11
|
-
* @param options CreateTokenRequestOptions
|
|
12
37
|
* @returns TokenResponse
|
|
13
38
|
*/
|
|
14
|
-
async OAuthTokenV2(payload = grantType
|
|
39
|
+
async OAuthTokenV2(payload = grantType) {
|
|
15
40
|
const data = await this.sabre.auth(
|
|
16
41
|
"/v2/auth/token",
|
|
17
|
-
payload
|
|
18
|
-
options
|
|
42
|
+
payload
|
|
19
43
|
);
|
|
20
44
|
this.sabre.setAuthorization(data.access_token);
|
|
21
45
|
return data;
|
|
22
46
|
}
|
|
23
47
|
};
|
|
24
48
|
|
|
25
|
-
// src/booking-management/booking
|
|
49
|
+
// src/booking-management/booking.ts
|
|
26
50
|
var Booking = class {
|
|
27
51
|
/**
|
|
28
52
|
* Booking
|
|
@@ -39,9 +63,9 @@ var Booking = class {
|
|
|
39
63
|
*
|
|
40
64
|
* payload - Contiene elementos tanto obligatorios como opcionales para realizar una solicitud de reserva.
|
|
41
65
|
* @param payload GetBookingOptions
|
|
42
|
-
* @returns
|
|
66
|
+
* @returns {Promise<GetBookingResponseSuccess>}
|
|
43
67
|
*/
|
|
44
|
-
|
|
68
|
+
get(payload) {
|
|
45
69
|
const path = "/v1/trip/orders/getBooking";
|
|
46
70
|
return this.sabre.post(path, payload);
|
|
47
71
|
}
|
|
@@ -50,7 +74,7 @@ var Booking = class {
|
|
|
50
74
|
*
|
|
51
75
|
* payload - Contiene elementos obligatorios y opcionales para realizar una solicitud de reserva.
|
|
52
76
|
* @param payload CreateBookingOptions
|
|
53
|
-
* @returns
|
|
77
|
+
* @returns {Promise<CreateBookingResponseSuccess>}
|
|
54
78
|
*/
|
|
55
79
|
async create(payload) {
|
|
56
80
|
const path = "/v1/trip/orders/createBooking";
|
|
@@ -61,7 +85,7 @@ var Booking = class {
|
|
|
61
85
|
*
|
|
62
86
|
* payload - Contiene elementos obligatorios y opcionales para cancelar la totalidad o partes de una reserva.
|
|
63
87
|
* @param payload CancelBookingOptions
|
|
64
|
-
* @returns
|
|
88
|
+
* @returns {Promise<CancelBookingResponseSuccess>}
|
|
65
89
|
*/
|
|
66
90
|
async cancel(payload) {
|
|
67
91
|
const path = "/v1/trip/orders/cancelBooking";
|
|
@@ -72,7 +96,7 @@ var Booking = class {
|
|
|
72
96
|
*
|
|
73
97
|
* payload - Contiene elementos obligatorios y opcionales para modificar datos no relacionados con el itinerario en la reserva existente.
|
|
74
98
|
* @param payload ModifyBookingOptions
|
|
75
|
-
* @returns
|
|
99
|
+
* @returns {Promise<ModifyBookingResponseSuccess>}
|
|
76
100
|
*/
|
|
77
101
|
async modify(payload) {
|
|
78
102
|
const path = "/v1/trip/orders/modifyBooking";
|
|
@@ -80,7 +104,7 @@ var Booking = class {
|
|
|
80
104
|
}
|
|
81
105
|
};
|
|
82
106
|
|
|
83
|
-
// src/booking-management/flight-tickets
|
|
107
|
+
// src/booking-management/flight-tickets.ts
|
|
84
108
|
var FlightTickets = class {
|
|
85
109
|
/**
|
|
86
110
|
* Flight Tickets
|
|
@@ -98,7 +122,7 @@ var FlightTickets = class {
|
|
|
98
122
|
*
|
|
99
123
|
* payload - Contiene elementos obligatorios y opcionales para anular los billetes.
|
|
100
124
|
* @param payload VoidTicketsOptions
|
|
101
|
-
* @returns
|
|
125
|
+
* @returns {Promise<VoidTicketsResponseSuccess>}
|
|
102
126
|
*/
|
|
103
127
|
async void(payload) {
|
|
104
128
|
const path = "/v1/trip/orders/voidFlightTickets";
|
|
@@ -110,7 +134,7 @@ var FlightTickets = class {
|
|
|
110
134
|
*
|
|
111
135
|
* payload - Contiene elementos obligatorios y opcionales para el reembolso de los billetes.
|
|
112
136
|
* @param payload RefundTicketsOptions
|
|
113
|
-
* @returns
|
|
137
|
+
* @returns {Promise<RefundTicketsResponseSuccess>}
|
|
114
138
|
*/
|
|
115
139
|
async refund(payload) {
|
|
116
140
|
const path = "/v1/trip/orders/refundFlightTickets";
|
|
@@ -122,19 +146,19 @@ var FlightTickets = class {
|
|
|
122
146
|
*
|
|
123
147
|
* payload - Contiene elementos obligatorios y opcionales para consultar los tickets.
|
|
124
148
|
* @param payload CheckTicketsOptions
|
|
125
|
-
* @returns CheckTicketsResponse
|
|
149
|
+
* @returns {Promise<CheckTicketsResponseSuccess>} CheckTicketsResponse
|
|
126
150
|
*/
|
|
127
151
|
async check(payload) {
|
|
128
152
|
const path = "/v1/trip/orders/checkFlightTickets";
|
|
129
153
|
return this.sabre.post(path, payload);
|
|
130
154
|
}
|
|
131
155
|
/**
|
|
132
|
-
* Procesa
|
|
156
|
+
* Procesa la emisión de billetes y documentos varios electrónicos (EMD).
|
|
133
157
|
* Actualmente, los EMD no son compatibles.
|
|
134
158
|
*
|
|
135
|
-
* payload - Contiene elementos obligatorios y opcionales para
|
|
136
|
-
* @param payload
|
|
137
|
-
* @returns
|
|
159
|
+
* payload - Contiene elementos obligatorios y opcionales para la emisión de billetes.
|
|
160
|
+
* @param payload FulfillTicketsOptions
|
|
161
|
+
* @returns {Promise<FulfillTicketsResponseSuccess>}
|
|
138
162
|
*/
|
|
139
163
|
async fulfill(payload) {
|
|
140
164
|
const path = "/v1/trip/orders/fulfillFlightTickets";
|
|
@@ -143,7 +167,7 @@ var FlightTickets = class {
|
|
|
143
167
|
};
|
|
144
168
|
|
|
145
169
|
// package.json
|
|
146
|
-
var version = "0.
|
|
170
|
+
var version = "0.2.0";
|
|
147
171
|
|
|
148
172
|
// src/config.ts
|
|
149
173
|
var defaultBaseUrl = "https://api.platform.sabre.com";
|
|
@@ -155,6 +179,18 @@ var userAgent = typeof process !== "undefined" && process.env ? process.env.SABR
|
|
|
155
179
|
var domain = typeof process !== "undefined" && process.env ? process.env.SABRE_DOMAIN || defaultDomain : defaultDomain;
|
|
156
180
|
var conversationId = typeof process !== "undefined" && process.env ? process.env.SABRE_CONVERSATION_ID || defaultConversationId : defaultConversationId;
|
|
157
181
|
|
|
182
|
+
// src/errors.ts
|
|
183
|
+
var SabreError = class extends Error {
|
|
184
|
+
details;
|
|
185
|
+
statusCode;
|
|
186
|
+
constructor(message, statusCode, details) {
|
|
187
|
+
super(message);
|
|
188
|
+
this.name = "SabreError";
|
|
189
|
+
this.statusCode = statusCode;
|
|
190
|
+
this.details = details;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
158
194
|
// src/sabre.ts
|
|
159
195
|
var Sabre = class {
|
|
160
196
|
constructor(options = {}) {
|
|
@@ -191,8 +227,19 @@ var Sabre = class {
|
|
|
191
227
|
async fetchRequest(path, options = {}) {
|
|
192
228
|
const response = await fetch(`${baseUrl}${path}`, options);
|
|
193
229
|
if (!response.ok) {
|
|
194
|
-
|
|
195
|
-
|
|
230
|
+
let errorDetails = `Request failed with status ${response.status}`;
|
|
231
|
+
try {
|
|
232
|
+
const jsonError = await response.json();
|
|
233
|
+
errorDetails = JSON.stringify(jsonError);
|
|
234
|
+
} catch (e) {
|
|
235
|
+
console.error(e);
|
|
236
|
+
errorDetails = response.statusText;
|
|
237
|
+
}
|
|
238
|
+
throw new SabreError(
|
|
239
|
+
`Request failed with status ${response.status}`,
|
|
240
|
+
response.status,
|
|
241
|
+
errorDetails
|
|
242
|
+
);
|
|
196
243
|
}
|
|
197
244
|
const data = await response.json();
|
|
198
245
|
return data;
|
|
@@ -225,6 +272,7 @@ var Sabre = class {
|
|
|
225
272
|
return btoa(`V1:${this.options.username}:${this.options.organization}:${domain}`);
|
|
226
273
|
}
|
|
227
274
|
};
|
|
228
|
-
export
|
|
275
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
276
|
+
0 && (module.exports = {
|
|
229
277
|
Sabre
|
|
230
|
-
};
|
|
278
|
+
});
|