sabre-client 0.1.0 → 0.2.1

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 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
- ## Get booking
37
+ ### Get booking v1.30
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
- ## Create booking
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
- ## Modify Booking
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
- ## Cancel Booking
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
- ## Void Flight Tickets
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
- ## Refund Flight Tickets
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
- ## Check Flight Tickets
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
 
@@ -93,6 +93,38 @@ Checks tickets with ticket numbers listed in the request for void, refund and ex
93
93
  await sabre.flightTickets.check(options);
94
94
  ```
95
95
 
96
+ ### Fulfill Flight Tickets
97
+
98
+ Processes the issuance of tickets and various electronic miscellaneous documents (EMDs). EMDs are currently not supported.
99
+
100
+ ```js
101
+ await sabre.flightTickets.fulfill(options);
102
+ ```
103
+
104
+ ### Bargain Finder Max (Search)
105
+
106
+ Searches for the lowest available priced itineraries for a given origin and destination.
107
+
108
+ ```js
109
+ await sabre.search.shop(options);
110
+ ```
111
+
112
+ ### Revalidate Itinerary (Search)
113
+
114
+ The Revalidate Itinerary API allows you to re-query the availability and price of a specific itinerary option without having to book it.
115
+
116
+ ```js
117
+ await sabre.search.revalidate(options);
118
+ ```
119
+
120
+ ### Issue Ticket (Ticketing)
121
+
122
+ Issues an airline ticket from an existing PNR (booking).
123
+
124
+ ```js
125
+ await sabre.ticketing.issue(options);
126
+ ```
127
+
96
128
  ## Development
97
129
 
98
130
  #### Install dependencies
@@ -1,3 +1,115 @@
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
+
27
+ // src/air/search.ts
28
+ var Search = class {
29
+ /**
30
+ * Bargain Finder Max v5
31
+ *
32
+ * Bargain Finder Max (BFM),
33
+ * nuestro producto de búsqueda de tarifas bajas líder en su clase,
34
+ * se utiliza para buscar los itinerarios con los precios más bajos disponibles según una fecha específica.
35
+ *
36
+ * Revalidate Itinerary v5
37
+ *
38
+ * La API Revalidate Itinerary permite volver a consultar la disponibilidad
39
+ * y el precio de una opción de itinerario específica sin tener que reservarla.
40
+ * La solución revalida si la opción de itinerario es válida para la compra.
41
+ * Revalidate Itinerary no admite contenido NDC.
42
+ *
43
+ * @param sabre Sabre Client Reference
44
+ */
45
+ constructor(sabre) {
46
+ this.sabre = sabre;
47
+ }
48
+ /**
49
+ * Crear solicitud de Buscador de ofertas Max.
50
+ *
51
+ * payload - El mensaje de solicitud de búsqueda de tarifa baja solicita opciones
52
+ * de itinerario para vuelos entre pares de ciudades específicos, en fechas específicas,
53
+ * para un número y tipo de pasajeros específicos.
54
+ * La información opcional de la solicitud puede incluir:
55
+ * hora/ventana horaria, ciudades de conexión
56
+ * y preferencias del cliente (aerolíneas, cabina, tipo de vuelo, etc.).
57
+ * La solicitud de búsqueda de tarifa baja contiene información similar a
58
+ * la de una búsqueda de tarifa baja en el CRS o GDS de una aerolínea.
59
+ * @param payload BargainFinderMaxOptions
60
+ * @returns {Promise<BargainFinderMaxResponseSuccess>}
61
+ */
62
+ async shop(payload) {
63
+ const path = "/v5/offers/shop";
64
+ return this.sabre.post(path, payload);
65
+ }
66
+ /**
67
+ * Crear solicitud de revalidación de itinerario.
68
+ *
69
+ * payload - El mensaje de solicitud de búsqueda de tarifa baja solicita opciones
70
+ * de itinerario para vuelos entre pares de ciudades específicos, en fechas específicas,
71
+ * para un número y tipo de pasajeros específicos.
72
+ * La información opcional de la solicitud puede incluir:
73
+ * hora/ventana horaria, ciudades de conexión
74
+ * y preferencias del cliente (aerolíneas, cabina, tipo de vuelo, etc.).
75
+ * La solicitud de búsqueda de tarifa baja contiene información similar a
76
+ * la de una búsqueda de tarifa baja en el CRS o GDS de una aerolínea.
77
+ * @param payload RevalidateItineraryOptions
78
+ * @returns {Promise<RevalidateItineraryResponseSuccess>}
79
+ */
80
+ async revalidate(payload) {
81
+ const path = "/v5/shop/flights/revalidate";
82
+ return this.sabre.post(path, payload);
83
+ }
84
+ };
85
+
86
+ // src/air/ticketing.ts
87
+ var Ticketing = class {
88
+ /**
89
+ * Enhanced Air Ticket v1.3.0
90
+ *
91
+ * La API de boletos aéreos mejorados se utiliza para emitir uno o varios boletos aéreos
92
+ * y/o EMD (documentos electrónicos varios) dentro de una sola llamada API.
93
+ *
94
+ * @param sabre Sabre Client Reference
95
+ */
96
+ constructor(sabre) {
97
+ this.sabre = sabre;
98
+ }
99
+ /**
100
+ * La API de boletos aéreos mejorados (AirTicketRQ)
101
+ * se utiliza para emitir boletos aéreos y documentos electrónicos varios (EMD) en una sola solicitud.
102
+ *
103
+ * payload - Solicitud de API de boletos aéreos orquestada.
104
+ * @param payload EnhancedAirTicketOptions
105
+ * @returns {Promise<EnhancedAirTicketResponseSuccess>}
106
+ */
107
+ async issue(payload) {
108
+ const path = "/v1.3.0/air/ticket";
109
+ return this.sabre.post(path, payload);
110
+ }
111
+ };
112
+
1
113
  // src/authentication/authentication.ts
2
114
  var grantType = new URLSearchParams({ "grant_type": "client_credentials" }).toString();
3
115
  var Authentication = class {
@@ -5,24 +117,22 @@ var Authentication = class {
5
117
  this.sabre = sabre;
6
118
  }
7
119
  /**
8
- * V2 AUTH TOKEN
120
+ * OAuth Token Create REST API v2
9
121
  * See https://developer.sabre.com/docs/rest_apis/session_management/token_create_api/v2
10
122
  * @param payload El tipo de concesión utilizado para obtener el token. Sólo se admiten 'client_credentials'.
11
- * @param options CreateTokenRequestOptions
12
123
  * @returns TokenResponse
13
124
  */
14
- async OAuthTokenV2(payload = grantType, options = {}) {
125
+ async OAuthTokenV2(payload = grantType) {
15
126
  const data = await this.sabre.auth(
16
127
  "/v2/auth/token",
17
- payload,
18
- options
128
+ payload
19
129
  );
20
130
  this.sabre.setAuthorization(data.access_token);
21
131
  return data;
22
132
  }
23
133
  };
24
134
 
25
- // src/booking-management/booking/booking.ts
135
+ // src/booking-management/booking.ts
26
136
  var Booking = class {
27
137
  /**
28
138
  * Booking
@@ -39,9 +149,9 @@ var Booking = class {
39
149
  *
40
150
  * payload - Contiene elementos tanto obligatorios como opcionales para realizar una solicitud de reserva.
41
151
  * @param payload GetBookingOptions
42
- * @returns GetBookingResponse
152
+ * @returns {Promise<GetBookingResponseSuccess>}
43
153
  */
44
- async get(payload) {
154
+ get(payload) {
45
155
  const path = "/v1/trip/orders/getBooking";
46
156
  return this.sabre.post(path, payload);
47
157
  }
@@ -50,7 +160,7 @@ var Booking = class {
50
160
  *
51
161
  * payload - Contiene elementos obligatorios y opcionales para realizar una solicitud de reserva.
52
162
  * @param payload CreateBookingOptions
53
- * @returns CreateBookingResponse
163
+ * @returns {Promise<CreateBookingResponseSuccess>}
54
164
  */
55
165
  async create(payload) {
56
166
  const path = "/v1/trip/orders/createBooking";
@@ -61,7 +171,7 @@ var Booking = class {
61
171
  *
62
172
  * payload - Contiene elementos obligatorios y opcionales para cancelar la totalidad o partes de una reserva.
63
173
  * @param payload CancelBookingOptions
64
- * @returns CancelBookingRequest
174
+ * @returns {Promise<CancelBookingResponseSuccess>}
65
175
  */
66
176
  async cancel(payload) {
67
177
  const path = "/v1/trip/orders/cancelBooking";
@@ -72,7 +182,7 @@ var Booking = class {
72
182
  *
73
183
  * payload - Contiene elementos obligatorios y opcionales para modificar datos no relacionados con el itinerario en la reserva existente.
74
184
  * @param payload ModifyBookingOptions
75
- * @returns ModifyBookingResponse
185
+ * @returns {Promise<ModifyBookingResponseSuccess>}
76
186
  */
77
187
  async modify(payload) {
78
188
  const path = "/v1/trip/orders/modifyBooking";
@@ -80,7 +190,7 @@ var Booking = class {
80
190
  }
81
191
  };
82
192
 
83
- // src/booking-management/flight-tickets/flight-tickets.ts
193
+ // src/booking-management/flight-tickets.ts
84
194
  var FlightTickets = class {
85
195
  /**
86
196
  * Flight Tickets
@@ -98,7 +208,7 @@ var FlightTickets = class {
98
208
  *
99
209
  * payload - Contiene elementos obligatorios y opcionales para anular los billetes.
100
210
  * @param payload VoidTicketsOptions
101
- * @returns VoidTicketsResponse
211
+ * @returns {Promise<VoidTicketsResponseSuccess>}
102
212
  */
103
213
  async void(payload) {
104
214
  const path = "/v1/trip/orders/voidFlightTickets";
@@ -110,7 +220,7 @@ var FlightTickets = class {
110
220
  *
111
221
  * payload - Contiene elementos obligatorios y opcionales para el reembolso de los billetes.
112
222
  * @param payload RefundTicketsOptions
113
- * @returns RefundTicketsResponse
223
+ * @returns {Promise<RefundTicketsResponseSuccess>}
114
224
  */
115
225
  async refund(payload) {
116
226
  const path = "/v1/trip/orders/refundFlightTickets";
@@ -122,19 +232,19 @@ var FlightTickets = class {
122
232
  *
123
233
  * payload - Contiene elementos obligatorios y opcionales para consultar los tickets.
124
234
  * @param payload CheckTicketsOptions
125
- * @returns CheckTicketsResponse
235
+ * @returns {Promise<CheckTicketsResponseSuccess>} CheckTicketsResponse
126
236
  */
127
237
  async check(payload) {
128
238
  const path = "/v1/trip/orders/checkFlightTickets";
129
239
  return this.sabre.post(path, payload);
130
240
  }
131
241
  /**
132
- * Procesa tickets proporcionando una solicitud que contiene una lista de números de ticket que se verificarán.
242
+ * Procesa la emisión de billetes y documentos varios electrónicos (EMD).
133
243
  * Actualmente, los EMD no son compatibles.
134
244
  *
135
- * payload - Contiene elementos obligatorios y opcionales para consultar los tickets.
136
- * @param payload CheckTicketsOptions
137
- * @returns CheckTicketsResponse
245
+ * payload - Contiene elementos obligatorios y opcionales para la emisión de billetes.
246
+ * @param payload FulfillTicketsOptions
247
+ * @returns {Promise<FulfillTicketsResponseSuccess>}
138
248
  */
139
249
  async fulfill(payload) {
140
250
  const path = "/v1/trip/orders/fulfillFlightTickets";
@@ -143,7 +253,7 @@ var FlightTickets = class {
143
253
  };
144
254
 
145
255
  // package.json
146
- var version = "0.1.0";
256
+ var version = "0.2.1";
147
257
 
148
258
  // src/config.ts
149
259
  var defaultBaseUrl = "https://api.platform.sabre.com";
@@ -155,6 +265,18 @@ var userAgent = typeof process !== "undefined" && process.env ? process.env.SABR
155
265
  var domain = typeof process !== "undefined" && process.env ? process.env.SABRE_DOMAIN || defaultDomain : defaultDomain;
156
266
  var conversationId = typeof process !== "undefined" && process.env ? process.env.SABRE_CONVERSATION_ID || defaultConversationId : defaultConversationId;
157
267
 
268
+ // src/errors.ts
269
+ var SabreError = class extends Error {
270
+ details;
271
+ statusCode;
272
+ constructor(message, statusCode, details) {
273
+ super(message);
274
+ this.name = "SabreError";
275
+ this.statusCode = statusCode;
276
+ this.details = details;
277
+ }
278
+ };
279
+
158
280
  // src/sabre.ts
159
281
  var Sabre = class {
160
282
  constructor(options = {}) {
@@ -184,6 +306,8 @@ var Sabre = class {
184
306
  authentication = new Authentication(this);
185
307
  booking = new Booking(this);
186
308
  flightTickets = new FlightTickets(this);
309
+ search = new Search(this);
310
+ ticketing = new Ticketing(this);
187
311
  setAuthorization(token) {
188
312
  this.headers.set("Authorization", `Bearer ${token}`);
189
313
  this.headers.set("Content-Type", "application/json");
@@ -191,8 +315,19 @@ var Sabre = class {
191
315
  async fetchRequest(path, options = {}) {
192
316
  const response = await fetch(`${baseUrl}${path}`, options);
193
317
  if (!response.ok) {
194
- const error = await response.json();
195
- throw new Error(JSON.stringify(error));
318
+ let errorDetails = `Request failed with status ${response.status}`;
319
+ try {
320
+ const jsonError = await response.json();
321
+ errorDetails = JSON.stringify(jsonError);
322
+ } catch (e) {
323
+ console.error(e);
324
+ errorDetails = response.statusText;
325
+ }
326
+ throw new SabreError(
327
+ `Request failed with status ${response.status}`,
328
+ response.status,
329
+ errorDetails
330
+ );
196
331
  }
197
332
  const data = await response.json();
198
333
  return data;
@@ -225,6 +360,7 @@ var Sabre = class {
225
360
  return btoa(`V1:${this.options.username}:${this.options.organization}:${domain}`);
226
361
  }
227
362
  };
228
- export {
363
+ // Annotate the CommonJS export names for ESM import in node:
364
+ 0 && (module.exports = {
229
365
  Sabre
230
- };
366
+ });