vista-co
Version:
286 lines (285 loc) • 17.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RESTData = void 0;
//RESTData.ts
const axios_master_1 = require("axios-master");
const __1 = require("..");
const RESTData = (config) => {
return {
// Implementation Notes: This function fetches the discount availability for a specified cinema from the RESTData service.
// It accepts the cinemaId as a path parameter and optional headers for authentication and region code.
GetDiscountAvailabilityForCinema: async (cinemaId) => {
var _a, _b, _c;
try {
// Construct the request URL with the cinemaId path parameter.
const url = `${config.host}/WSVistaWebClient/RESTData.svc/cinemas/${cinemaId}/discount-availability`;
// Send the GET request with headers including API token and region code if provided.
const res = await (0, axios_master_1.axiosMasterMain)({
method: "GET",
url,
headers: {
connectapitoken: `${config.token}`, // API token for authentication
"Content-Type": "application/json", // Ensures the response format is JSON
"Connect-Region-Code": config.regionCode, // Region code for localization
},
}, {
name: "GetDiscountAvailabilityForCinema", // Request identifier for logging and debugging
timeout: 20000, // Timeout of 20 seconds for the request
logger(data) {
if (config.logger) {
console.log(data); // Logs request data for debugging purposes
}
},
});
// Return the 'data' from the successful response.
return {
success: true,
message: "Request successful",
data: res,
};
}
catch (error) {
// Logs and returns an error message if the request fails.
console.error("Request failed", (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data);
return {
success: false,
message: ((_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) || "An error occurred",
};
}
},
// Implementation Notes: This function fetches the seat plan for a specified cinema and screen number from the RESTData service.
// It accepts the cinemaId and screenNumber as path parameters and optional headers for authentication and region code.
GetSeatPlan: async (cinemaId, screenNumber, seatLayoutId) => {
var _a, _b, _c;
try {
const query = (0, __1.jsonToQueryString)({ seatLayoutId: seatLayoutId });
// Construct the request URL with the cinemaId and screenNumber path parameters.
let url = `${config.host}/WSVistaWebClient/RESTData.svc/cinemas/${cinemaId}/screens/${screenNumber}/seat-plan${query}`;
// Send the GET request with headers including API token and region code if provided.
const res = await (0, axios_master_1.axiosMasterMain)({
method: "GET",
url,
headers: {
connectapitoken: `${config.token}`, // API token for authentication
"Content-Type": "application/json", // Ensures the response format is JSON
"Connect-Region-Code": config.regionCode, // Region code for localization
},
}, {
name: "GetSeatPlan", // Request identifier for logging and debugging
timeout: 20000, // Timeout of 20 seconds for the request
logger(data) {
if (config.logger) {
console.log(data); // Logs request data for debugging purposes
}
},
});
// Return the 'data' from the successful response.
return {
success: true,
message: "Request successful",
data: res,
};
}
catch (error) {
// Logs and returns an error message if the request fails.
console.error("Request failed", (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data);
return {
success: false,
message: ((_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) || "An error occurred",
};
}
},
// Implementation Notes: This function fetches the film sessions for a specified cinema and promotion ID from the RESTData service.
// It accepts cinemaId and promotionId as path parameters and optional headers for authentication and region code.
GetSeasonPassDealFilmSessions: async (cinemaId, promotionId) => {
var _a, _b, _c;
try {
// Construct the request URL with the cinemaId and promotionId path parameters.
const url = `${config.host}/WSVistaWebClient/RESTData.svc/cinemas/${cinemaId}/seasonpassdeals/${promotionId}/filmsessions`;
// Send the GET request with headers including API token and region code if provided.
const res = await (0, axios_master_1.axiosMasterMain)({
method: "GET",
url,
headers: {
connectapitoken: `${config.token}`, // API token for authentication
"Content-Type": "application/json", // Ensures the response format is JSON
"Connect-Region-Code": config.regionCode, // Region code for localization
},
}, {
name: "GetSeasonPassDealFilmSessions", // Request identifier for logging and debugging
timeout: 20000, // Timeout of 20 seconds for the request
logger(data) {
if (config.logger) {
console.log(data); // Logs request data for debugging purposes
}
},
});
// Return the 'data' from the successful response.
return {
success: true,
message: "Request successful",
data: res,
};
}
catch (error) {
// Logs and returns an error message if the request fails.
console.error("Request failed", (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data);
return {
success: false,
message: ((_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) || "An error occurred",
};
}
},
// Implementation Notes: This function fetches the seat plan for a specified cinema session from the RESTData service.
// It accepts cinemaId and sessionId as path parameters and optional headers for authentication, region code, and user session.
GetSessionSeatPlan: async (cinemaId, sessionId, returnSoldSeatsOnly, userSessionId) => {
var _a, _b, _c;
try {
const query = (0, __1.jsonToQueryString)({
returnSoldSeatsOnly: returnSoldSeatsOnly,
userSessionIdP: userSessionId,
});
// Construct the request URL with the cinemaId and sessionId path parameters.
let url = `${config.host}/WSVistaWebClient/RESTData.svc/cinemas/${cinemaId}/sessions/${sessionId}/seat-plan${query}`;
// Send the GET request with headers including API token and region code if provided.
const res = await (0, axios_master_1.axiosMasterMain)({
method: "GET",
url,
headers: {
connectapitoken: `${config.token}`, // API token for authentication
"Content-Type": "application/json", // Ensures the response format is JSON
"Connect-Region-Code": config.regionCode, // Region code for localization
},
}, {
name: "GetSessionSeatPlan", // Request identifier for logging and debugging
timeout: 20000, // Timeout of 20 seconds for the request
logger(data) {
if (config.logger) {
console.log(data); // Logs request data for debugging purposes
}
},
});
// Return the 'data' from the successful response.
return {
success: true,
message: "Request successful",
data: res.SeatLayoutData,
};
}
catch (error) {
// Logs and returns an error message if the request fails.
console.error("Request failed", (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data);
return {
success: false,
message: ((_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) || "An error occurred",
};
}
},
// Implementation Notes: This function fetches available tickets for a specified session from the RESTData service.
// It accepts cinemaId and sessionId as path parameters and optional query parameters for user session and ticket options.
GetSessionTickets: async (cinemaId, sessionId, salesChannel, userSessionId, returnOnlyTicketsForLoyaltyMembers, includeLoyaltyTickets, includeNonLoyaltyTickets, includeComplimentaryTickets, includePackageTickets, includeRedemptionTickets, includeAdvanceSalesTickets) => {
var _a, _b, _c;
try {
const query = (0, __1.jsonToQueryString)({
salesChannel: salesChannel,
userSessionId: userSessionId,
returnOnlyTicketsForLoyaltyMembers: returnOnlyTicketsForLoyaltyMembers,
includeLoyaltyTickets: includeLoyaltyTickets,
includeNonLoyaltyTickets: includeNonLoyaltyTickets,
includeComplimentaryTickets: includeComplimentaryTickets,
includePackageTickets: includePackageTickets,
includeRedemptionTickets: includeRedemptionTickets,
includeAdvanceSalesTickets: includeAdvanceSalesTickets,
});
// Construct the request URL with the cinemaId and sessionId path parameters.
let url = `${config.host}/WSVistaWebClient/RESTData.svc/cinemas/${cinemaId}/sessions/${sessionId}/tickets${query}`;
// Send the GET request with headers including API token and region code if provided.
const res = await (0, axios_master_1.axiosMasterMain)({
method: "GET",
url,
headers: {
connectapitoken: `${config.token}`, // API token for authentication
"Content-Type": "application/json", // Ensures the response format is JSON
"Connect-Region-Code": config.regionCode, // Region code for localization
},
}, {
name: "GetSessionTickets", // Request identifier for logging and debugging
timeout: 20000, // Timeout of 20 seconds for the request
logger(data) {
if (config.logger) {
console.log(data); // Logs request data for debugging purposes
}
},
});
// Return the 'data' from the successful response.
return {
success: true,
message: "Request successful",
data: res,
};
}
catch (error) {
// Logs and returns an error message if the request fails.
console.error("Request failed", (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data);
return {
success: false,
message: ((_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) || "An error occurred",
};
}
},
// Implementation Notes: This function fetches tickets for a specific barcode for a given session and cinema from the RESTData service.
// It accepts cinemaId, sessionId, and barcode as path and query parameters and provides options for ticket type filters.
GetTicketsForBarcode: async (cinemaId, sessionId, barcode, salesChannel, userSessionId, includeComplimentaryTickets, includePackageTickets, includeRedemptionTickets, includeAdvanceSalesTickets, includeNonLoyaltyTickets, includeLoyaltyTickets, includeLoyaltyRecognitionTickets) => {
var _a, _b, _c;
try {
const query = (0, __1.jsonToQueryString)({
barcode: barcode,
salesChannel: salesChannel,
userSessionId: userSessionId,
includeComplimentaryTickets: includeComplimentaryTickets,
includePackageTickets: includePackageTickets,
includeRedemptionTickets: includeRedemptionTickets,
includeAdvanceSalesTickets: includeAdvanceSalesTickets,
includeNonLoyaltyTickets: includeNonLoyaltyTickets,
includeLoyaltyTickets: includeLoyaltyTickets,
includeLoyaltyRecognitionTickets: includeLoyaltyRecognitionTickets,
});
// Construct the request URL with the cinemaId and sessionId path parameters.
let url = `${config.host}/WSVistaWebClient/RESTData.svc/cinemas/${cinemaId}/sessions/${sessionId}/tickets-for-barcode${query}`;
// Send the GET request with headers including API token and region code if provided.
const res = await (0, axios_master_1.axiosMasterMain)({
method: "GET",
url,
headers: {
connectapitoken: `${config.token}`, // API token for authentication
"Content-Type": "application/json", // Ensures the response format is JSON
"Connect-Region-Code": config.regionCode, // Region code for localization
},
}, {
name: "GetTicketsForBarcode", // Request identifier for logging and debugging
timeout: 20000, // Timeout of 20 seconds for the request
logger(data) {
if (config.logger) {
console.log(data); // Logs request data for debugging purposes
}
},
});
// Return the 'data' from the successful response.
return {
success: true,
message: "Request successful",
data: res,
};
}
catch (error) {
// Logs and returns an error message if the request fails.
console.error("Request failed", (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data);
return {
success: false,
message: ((_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) || "An error occurred",
};
}
},
};
};
exports.RESTData = RESTData;