tickethead-sdk
Version:
SDK for the Tickethead API
1,094 lines • 50.2 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventService = void 0;
const query_string_1 = __importDefault(require("query-string"));
const query_1 = require("../common/query");
const types_1 = require("../blockchain/types");
const upload_1 = require("../utils/upload");
/**
* Service class for event API calls. Requires an organizer to be set (call to `useOrganizer`)
*/
class EventService {
constructor(client, version) {
this.client = client;
this.version = version;
}
/**
* Returns true if the service is reachable
*
* @returns Services' online status
*/
health() {
return __awaiter(this, void 0, void 0, function* () {
try {
const res = yield this.client.get(`event/health`);
if (res.data.status === 'ok') {
return { online: true };
}
}
catch (e) {
// Do nothing
}
return { online: false };
});
}
/**
* Creates a new event. Subobjects except for the subcategory can be added later.
* `endAt` needs to be after `startAt` and both need to be in the future.
* After an event is created, it needs to be published to be available for purchase.
* To publish an event, it needs to have at least one ticket configuration.
*
* @returns new Event
*/
createEvent(name, newEvent) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${name.name}/event`, newEvent);
return res.data.data;
});
}
/**
* Updates existing event.
* @param id Org ID and event ID of the event you want to update
* @param updatedEventFields Fields on the event to be updated
* @returns new Event
*/
updateEvent(id, updatedEventFields) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}`, updatedEventFields);
return res.data.data;
});
}
/**
* Deletes existing event.
* @param id Org ID and event ID of the event you want to delete
*/
deleteEvent(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}`);
return res.data.data;
});
}
/**
* Cancels existing event.
* @param id Org ID and event ID of the event you want to cancel
*/
cancelEvent(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/cancel`);
return res.data.data;
});
}
/**
* @param id Org ID and event ID of the event you want to publish
* @returns Publish event payload
*/
getEventPublishingPayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/chaincode_payload`);
return {
fcn: types_1.BlockchainFunction.CreateEvent,
args: res.data.data,
};
});
}
/**
* Returns payload when creating an event on the blockchain.
*
* @param id Org ID and event ID of the event you want to publish
* @returns payload to be when creating it on the blockchain
*/
getEventPublishPayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/chaincode/publish/proposal`);
return res.data.data;
});
}
/**
* Returns QR Code payload when creating an event on the blockchain.
*
* @param id Org ID and event ID of the event you want to publish
* @returns QR Code payload
*/
getEventPublishQRCodePayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/chaincode/publish/qrcode_payload`);
return res.data.data;
});
}
/**
* Returns payload when updating an event on the blockchain.
*
* @param id Org ID and event ID of the event you want to publish
* @returns payload when updating an even on the blockchain
*/
getEventUpdatePayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/chaincode/update/proposal`);
return res.data.data;
});
}
/**
* Returns QR Code payload when updating an event on the blockchain.
*
* @param id Org ID and event ID of the event you want to publish
* @returns QR Code payload
*/
getEventUpdateQRCodePayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/chaincode/update/qrcode_payload`);
return res.data.data;
});
}
/**
* Returns the public key for ticket signature validation
*
* @param id Org ID and event ID of the tickets
* @returns Public key for signature validation
*/
getTicketSigningKey(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/public_key`);
return res.data.data;
});
}
/**
* Returns an event by its ID.
*
* @param req ID and additional query params
* @returns Event object
*/
getEvent(req) {
return __awaiter(this, void 0, void 0, function* () {
const query = query_string_1.default.stringify({
include_occurrences: req.include_occurrences,
q: req.query,
public: true,
with: !req.with
? '[ticket_config,ticket_discount,subcategory,ticket_format,timeslot,occurrence.ticket_config,sector]'
: (0, query_1.buildQuery)(req.with),
organizer_id: req.organizer_id,
}, { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/event/${req.id}?${query}`);
return res.data.data;
});
}
/**
* Returns an unpublished event by its ID.
*
* @param req ID and access_token of the event and additional query params
* @returns Event object
*/
getPrivateEvent(req) {
return __awaiter(this, void 0, void 0, function* () {
const query = query_string_1.default.stringify({
with: !req.with ? undefined : (0, query_1.buildQuery)(req.with),
}, { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/event/${req.id}/private/${req.access_token}?${query}`);
return res.data.data;
});
}
/**
* Returns a list of active events.
*
* @param req.q String value for text-based search on event
* @param req.start_at Date range where the event start_at field is filtered
* @param req.include_occurrences If true, in case of recurring events it includes occurrences
* @param req.with Field selector query attribute
* @returns
*/
listEvents() {
return __awaiter(this, arguments, void 0, function* (req = {}) {
const query = query_string_1.default.stringify(Object.assign(Object.assign({}, req), { q: req.query, query: undefined, public: true, with: !req.with ? undefined : (0, query_1.buildQuery)(req.with), start_at: req.start_at !== undefined
? `${req.start_at[0].toISOString()};${req.start_at[1].toISOString()}`
: undefined }), { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/event?${query}`);
return res.data;
});
}
listOrganizerEvents(id_1) {
return __awaiter(this, arguments, void 0, function* (id, req = {}) {
const query = query_string_1.default.stringify(Object.assign(Object.assign({}, req), { with: (req === null || req === void 0 ? void 0 : req.with) ? (0, query_1.buildQuery)(req.with) : undefined }), { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/organizer/${id.name}/event?${query}`);
return res.data;
});
}
getOrganizerEvent(id_1) {
return __awaiter(this, arguments, void 0, function* (id, req = {}) {
const query = query_string_1.default.stringify(Object.assign(Object.assign({}, req), { with: req.with ? (0, query_1.buildQuery)(req.with) : undefined }), { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}?${query}`);
return res.data.data;
});
}
/** Returns the number of sold and total number of tickets per ticket configuration on an event. */
getTicketConfigStatistics(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/statistics/ticket_config`);
return res.data.data;
});
}
listOrganizerEventTicketConfigs(id_1) {
return __awaiter(this, arguments, void 0, function* (id, req = {}) {
const query = query_string_1.default.stringify(Object.assign(Object.assign({}, req), { with: req.with ? (0, query_1.buildQuery)(req.with) : undefined }), { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/ticket_config?${query}`);
return res.data;
});
}
/**
* Returns a ticket configuration.
*
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.eventId ID of the event to which the ticket config belongs to
* @param id.ticketConfigId ID of the ticket config
* @returns
*/
getTicketConfig(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}`);
return res.data.data;
});
}
/**
* Returns newly created ticket configuration.
*
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.id ID of the event to which the ticket config belongs to
* @param ticketConfig data based on which ticket config should be created
* @returns new ticket config
*/
createTicketConfig(id, ticketConfig) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/ticket_config`, ticketConfig);
return res.data.data;
});
}
/**
* Returns updated ticket configuration.
*
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.eventId ID of the event to which the ticket config belongs to
* @param id.ticketConfigId ID of the ticket config to be updated
* @param ticketConfig data based on which ticket config should be updated
* @returns new ticket config
*/
updateTicketConfig(id, ticketConfig) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}`, ticketConfig);
return res.data.data;
});
}
/**
* Deletes ticket config.
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.eventId ID of the event to which the ticket config belongs to
* @param id.ticketConfigId ID of the ticket config to be deleted
*/
deleteTicketConfig(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}`);
});
}
/**
* Returns payload when publishing a ticket config on the blockchain.
*
* @param id Org ID, event ID and ID of the ticket config you want to publish
* @returns payload when publishing a ticket config on the blockchain.
*/
getTicketConfigPublishPayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/chaincode/publish/payload`);
return res.data.data;
});
}
/**
* Returns QR Code payload when publishing a ticket config on the blockchain.
*
* @param id Org ID, event ID and ID of the ticket config you want to publish
* @returns QR Code payload
*/
getTicketConfigPublishQRCodePayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/chaincode/publish/qrcode_payload`);
return res.data.data;
});
}
/**
* Returns payload when updating a ticket config on the blockchain.
*
* @param id Org ID, event ID and ID of the ticket config you want to update
* @returns payload when updating a ticket config on the blockchain.
*/
getTicketConfigUpdatePayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/chaincode/update/proposal`);
return res.data.data;
});
}
/**
* Returns QR Code payload when updating a ticket config on the blockchain.
*
* @param id Org ID, event ID and ID of the ticket config you want to update
* @returns QR Code payload
*/
getTicketConfigUpdateQRCodePayload(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/chaincode/update/qrcode_payload`);
return res.data.data;
});
}
/**
* Returns events with secure tickets for the authorized enrolled user.
*
* @param req.date Filter events by `end_at` date comparing with `midnight`. Expected values are `future`, `past` and `all`.
* @returns
*/
getMyEvents(req) {
return __awaiter(this, void 0, void 0, function* () {
const query = query_string_1.default.stringify({
date: req.date,
});
const res = yield this.client.get(`event/${this.version}/my_events?${query}`);
return res.data.data;
});
}
/**
* Returns ticket counts for a given event (one entry per ticket-configuration)
*
* @param req
* @returns
*/
getTicketCount(req) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${req.organizer_id}/event/${req.id}/statistics/validator/ticket_count`);
return res.data.data;
});
}
/**
* Returns all QR codes (for unused tickets) for a given event
*/
getQrCodes(req) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${req.organizer_id}/event/${req.id}/qr_codes`);
return res.data.data;
});
}
/**
* Returns all external ticket codes for a given event
*/
getExternalTickets(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/external_ticket`);
return res.data.data;
});
}
/**
* Imports given external tickets into an event
*/
importExternalTicketJson(id, externalTickets) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/external_ticket/import`, externalTickets);
});
}
/**
* Imports given external tickets in a CSV format into an event.
* Requires table headers and that it has a `code` column.
*/
importExternalTicketCsv(id, fileData) {
return __awaiter(this, void 0, void 0, function* () {
const boundary = (0, upload_1.generateBoundary)();
const body = (0, upload_1.writeMultipartForm)(fileData.filename, fileData.content, boundary, 'tickets.csv', 'text/csv');
yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/external_ticket/import/csv`, body, {
headers: {
'Content-Type': `multipart/form-data; boundary=${boundary}`,
},
});
});
}
/**
* Marks the ticket as invalidated. Throws if the ticket is already used.
* @returns The data of the ticket which was invalidated, if successful
*/
invalidateExternalTicket(id, ticket) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/external_ticket/invalidate`, ticket);
return res.data.data;
});
}
/**
* Deletes external ticket
*/
deleteExternalTicket(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/external_ticket/${id.id}`);
});
}
/**
* Create an access code for a given event
*/
createAccessCode(id, accessCode) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/access_code`, accessCode);
return res.data.data;
});
}
/**
* Create a batch of access codes for a given event. If unspecified, the length of the codes is 6.
* @returns all generated codes
*/
createAccessCodeBatch(id, accessCodeBatch) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/access_code/batch`, accessCodeBatch);
return res.data.data;
});
}
/**
* Returns an access code for a given event
*/
getAccessCode(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/access_code/${id.id}`);
return res.data.data;
});
}
/**
* Returns all access codes for a given event
*/
getAccessCodes(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/access_code`);
return res.data.data;
});
}
/**
* Update an access codes for a given event
*/
updateAccessCode(id, accessCode) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/access_code/${id.id}`, accessCode);
return res.data.data;
});
}
/**
* Deletes an access code for an event
*/
deleteAccessCode(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/access_code/${id.id}`);
});
}
/**
* Imports access codes into an event. Access codes with the same code will be deleted and readded.
*/
importAccessCodeJson(id, accessCodes) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/access_code/import`, accessCodes);
});
}
/**
* Imports given access codes in a CSV format into an event.
* Requires table headers and that it has a `code` and `max_tickets` column.
* Access codes with the same code will be deleted and readded.
*/
importAccessCodeCsv(id, fileData) {
return __awaiter(this, void 0, void 0, function* () {
const boundary = (0, upload_1.generateBoundary)();
const body = (0, upload_1.writeMultipartForm)(fileData.filename, fileData.content, boundary, 'tickets.csv', 'text/csv');
yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/access_code/import/csv`, body, {
headers: {
'Content-Type': `multipart/form-data; boundary=${boundary}`,
},
});
});
}
createNftDrop(nftDrop) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${nftDrop.organizerId}/nft_drop`, nftDrop);
return res.data.data;
});
}
updateNftDrop(nftDrop) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${nftDrop.organizerId}/nft_drop/${nftDrop.id}`, nftDrop);
return res.data.data;
});
}
sendNftDrop(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/nft_drop/${id.id}/send`);
});
}
deleteNftDrop(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/nft_drop/${id.id}`);
});
}
deleteNftDropFilter(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/nft_drop/${id.nftDropId}/nft_drop_filter/${id.id}`);
});
}
/**
* Returns a specific NFT collection with the given relations
*/
getNftDrop(id_1) {
return __awaiter(this, arguments, void 0, function* (id, req = {}) {
const query = query_string_1.default.stringify({ with: req.with ? (0, query_1.buildQuery)(req.with) : undefined }, { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/nft_drop/${id.id}?${query}`);
return res.data.data;
});
}
listNftDrops(id_1) {
return __awaiter(this, arguments, void 0, function* (id, req = {}) {
const query = query_string_1.default.stringify(Object.assign(Object.assign({}, req), { with: !req.with ? undefined : (0, query_1.buildQuery)(req.with) }), { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/organizer/${id.name}/nft_drop?${query}`);
return res.data;
});
}
/**
* Creates a ticket discount.
* @param id.organizerId Name of the organizer to whom the ticket discount belongs to
* @param id.eventId ID of the event to which the ticket discount belongs to
* @returns new TicketDiscount
*/
createTicketDiscount(id, ticketDiscount) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/ticket_discount`, ticketDiscount);
return res.data.data;
});
}
/**
* Updates ticket discount.
* @param id.organizerId Name of the organizer to whom the ticket discount belongs to
* @param id.eventId ID of the event to which the ticket discount belongs to
* @param id.id ID of the ticket discount to update
* @returns updated ticket discount
*/
updateTicketDiscount(id, ticketDiscount) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_discount/${id.id}`, ticketDiscount);
return res.data.data;
});
}
/**
* Deletes ticket discount.
* @param id.organizerId Name of the organizer to whom the ticket discount belongs to
* @param id.eventId ID of the event to which the ticket discount belongs to
* @param id.id ID of the ticket discount to be deleted
*/
deleteTicketDiscount(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_discount/${id.id}`);
});
}
/**
* Fetches ticket discount.
* @param id.organizerId Name of the organizer to whom the ticket discount belongs to
* @param id.eventId ID of the event to which the ticket discount belongs to
* @param id.id ID of the ticket discount to be fetched
*/
getTicketDiscount(id_1) {
return __awaiter(this, arguments, void 0, function* (id, req = {}) {
const query = query_string_1.default.stringify(Object.assign(Object.assign({}, req), { with: req.with ? (0, query_1.buildQuery)(req.with) : undefined }), { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_discount/${id.id}?${query}`);
return res.data.data;
});
}
/**
* Creates discounts in batches.
* @param id.organizerId Name of the organizer to whom the ticket discount belongs to
* @param id.eventId ID of the event to which the ticket discount belongs to
* @param id.id ID of the ticket discount to be duplicated
*/
createDiscountBatch(id, discountBatch) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_discount/${id.id}/batch`, discountBatch);
return res.data.data;
});
}
listTicketDiscounts(id_1) {
return __awaiter(this, arguments, void 0, function* (id, req = {}) {
const query = query_string_1.default.stringify(Object.assign(Object.assign({}, req), { with: !req.with ? undefined : (0, query_1.buildQuery)(req.with) }), { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/ticket_discount?${query}`);
return res.data;
});
}
/**
* Create a single promo section
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.eventId ID of the event to which the ticket config belongs to
* @param id.TicketConfigId ID of the ticket config which the promo section should belong to
* @param promoSection Created promo section
* @returns The created promo section
*/
createPromoSection(id, promoSection) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/promo_section`, promoSection);
return res.data.data;
});
}
/**
* Update a single promo section
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.eventId ID of the event to which the ticket config belongs to
* @param id.ticketConfigId ID of the ticket config which the promo section belongs to
* @param id.id ID of the promo section
* @param promoSection Updated promo section
* @returns The updated promo section
*/
updatePromoSection(id, promoSection) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/promo_section/${id.id}`, promoSection);
return res.data.data;
});
}
/**
* Get a single promo section
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.eventId ID of the event to which the ticket config belongs to
* @param id.ticketConfigId ID of the ticket config which the promo section belongs to
* @param id.id ID of the promo section
* @returns Single promo section
*/
getPromoSection(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/promo_section/${id.id}`);
return res.data.data;
});
}
/**
* List promo sections
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.eventId ID of the event to which the ticket config belongs to
* @param id.ticketConfigId ID of the ticket config which the promo section belongs to
* @returns List of the promo sections
*/
listPromoSections(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/promo_section`);
return res.data;
});
}
/**
* Delete a single promo section
* @param id.organizerId Name of the organizer to whom the ticket config belongs to
* @param id.eventId ID of the event to which the ticket config belongs to
* @param id.ticketConfigId ID of the ticket config which the promo section belongs to
* @param id.id ID of the promo section
*/
deletePromoSection(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/promo_section/${id.id}`);
});
}
/**
* Create a sector on an event.
* @param id.id ID of the event the sector should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param sector The sector that should be created
* @param sector.ticketConfig IDs of the ticket configs that should be applied to the sector
*/
createSector(id, sector) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/sector`, sector);
return res.data.data;
});
}
/**
* Update a sector on an event.
* @param id.eventId ID of the event which the sector belongs to
* @param id.organizerId Name of the organizer the event is belonging to
* @param id.id ID of the sector that should be updated
* @param sector.ticketConfig IDs of the ticket configs that should be applied to the sector
*/
updateSector(id, sector) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/sector/${id.id}`, sector);
return res.data.data;
});
}
/**
* List sectors on an event
* @param id.id ID of the event the sector should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param query.with Allows fetching the associated ticket configs with the sector
*/
listSectors(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/sector?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data;
});
}
/**
* Get a sector on an event
* @param id.eventId ID of the event which the sector belongs to
* @param id.organizerId Name of the organizer the event is belonging to
* @param id.id ID of the sector that should be fetched
* @param query Allows fetching the associated ticket configs with the sector
*/
getSector(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/sector/${id.id}?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data.data;
});
}
/**
* Delete a sector from an event
* @param id.eventId ID of the event which the sector belongs to
* @param id.organizerId Name of the organizer the event is belonging to
* @param id.id ID of the sector that should be deleted
*/
deleteSector(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/sector/${id.id}`);
});
}
/**
* Create a timeslot on an event.
* @param id.id ID of the event the timeslot should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param timeslot The timeslot that should be created
* @param timeslot.ticketConfig IDs of the ticket configs that should be applied to the timeslot
*/
createTimeslot(id, timeslot) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/timeslot`, timeslot);
return res.data.data;
});
}
/**
* Update a timeslot on an event.
* @param id.eventId ID of the event which the timeslot belongs to
* @param id.organizerId Name of the organizer the event is belonging to
* @param id.id ID of the timeslot that should be updated
* @param timeslot.ticketConfig IDs of the ticket configs that should be applied to the timeslot
*/
updateTimeslot(id, timeslot) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/timeslot/${id.id}`, timeslot);
return res.data.data;
});
}
/**
* Get a timeslot on an event
* @param id.eventId ID of the event which the timeslot belongs to
* @param id.organizerId Name of the organizer the event is belonging to
* @param id.id ID of the timeslot that should be fetched
* @param query Allows fetching the associated ticket configs with the timeslot
*/
getTimeslot(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/timeslot/${id.id}?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data.data;
});
}
/**
* Delete a timeslot from an event
* @param id.eventId ID of the event which the timeslot belongs to
* @param id.organizerId Name of the organizer the event is belonging to
* @param id.id ID of the timeslot that should be deleted
*/
deleteTimeslot(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/timeslot/${id.id}`);
});
}
/**
* List timeslots on an event
* @param id.id ID of the event the timeslot should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param query.with Allows fetching the associated ticket configs with the timeslots
*/
listTimeslots(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/timeslot?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data;
});
}
/**
* List all emails in all states for an event.
* @param id.id ID of the event the emails should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param query.with Allows fetching the associated ticket configs for the information email filter
*/
listInformationEmails(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/information_email?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data;
});
}
/**
* Get one information email.
* @param id.id ID of the event the emails should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param emailId ID of the information email that should be fetched
*/
getInformationEmail(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/information_email/${id.id}?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data.data;
});
}
/**
* Saves an information email.
* @param id.id ID of the event the emails should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param informationEmail Information email data that should be saved
*/
saveInformationEmail(id, informationEmail) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/information_email`, informationEmail);
return res.data.data;
});
}
/**
* Update an information email.
* @param id.eventId ID of the event the emails should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param id.id ID of the information email that should be updated
* @param informationEmail Information email data that should be updated
*/
updateInformationEmail(id, informationEmail) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/information_email/${id.id}`, informationEmail);
return res.data.data;
});
}
/**
* Send an information email to all recipients.
* @param id.eventId ID of the event the emails should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param id.id ID of the information email that should be sent
*/
sendInformationEmail(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/information_email/${id.id}/send`);
});
}
/**
* Delete an information email.
* @param id.eventId ID of the event the emails should belong to
* @param id.organizerId Name of the organizer whom the event belongs to
* @param id.id ID of the information email that should be sent
*/
deleteInformationEmail(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/information_email/${id.id}`);
});
}
/**
* List ticket formats
* @returns Array of ticket formats
*/
listTicketFormats() {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/ticket_format`);
return res.data;
});
}
/**
* Fetch ticket format
* @param id.id ID of the ticket format
* @returns ticket format
*/
getTicketFormat(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/ticket_format/${id.id}`);
return res.data.data;
});
}
/**
* List event categories
* @returns Array of categories
*/
listEventCategories() {
return __awaiter(this, arguments, void 0, function* (req = {}) {
const query = query_string_1.default.stringify(Object.assign(Object.assign({}, req), { with: !req.with ? undefined : (0, query_1.buildQuery)(req.with) }), { arrayFormat: 'comma', skipNull: true, skipEmptyString: true });
const res = yield this.client.get(`event/${this.version}/category?${query}`);
return res.data;
});
}
/**
* Returns a per-ticket-config array of enrollment IDs for ticket holders
*
* @param id Org ID and event ID of the tickets
* @returns Public key for signature validation
*/
getHolderList(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/holders`);
return res.data.data;
});
}
/**
* Returns all questionnaires for given organizer
*
* @param id.id Organizer ID
*/
listOrganizerQuestionnaires(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.id}/questionnaire?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data;
});
}
/**
* Creates new questionnaire
*
* @param id.id Organizer ID
* @param questionnaireData Data based on which new questionnaire is created
*/
createQuestionnaire(id, questionnaireData) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.id}/questionnaire`, questionnaireData);
return res.data.data;
});
}
/**
* Fetches queried questionnaire
*
* @param id.id Questionnaire ID
* @param id.organizerId Organizer ID
*/
getOrganizerQuestionnaire(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/questionnaire/${id.id}?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data.data;
});
}
/**
* Updates existing questionnaire
*
* @param id.id Questionnaire ID
* @param id.organizerId Organizer ID
* @param questionnaireData Data based on which questionnaire is updated
*/
updateQuestionnaire(id, questionnaireData) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.patch(`event/${this.version}/organizer/${id.organizerId}/questionnaire/${id.id}`, questionnaireData);
return res.data.data;
});
}
/**
* Deletes questionnaire with specified ID
*
* @param id.id Questionnaire ID
* @param id.organizerId Organizer ID
*/
deleteQuestionnaire(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/questionnaire/${id.id}`);
});
}
/**
* Fetches queried questionnaire
*
* @param id.id Questionnaire ID
*/
getQuestionnaire(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/questionnaire/${id.id}?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data.data;
});
}
/**
* Returns all questions for given organizer
*
* @param id.id Organizer ID
*/
listOrganizerQuestions(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.id}/question?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data;
});
}
/**
* Creates new question
*
* @param id.id Organizer ID
* @param questionData Data based on which new question is created
*/
createQuestion(id, questionData) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/organizer/${id.id}/question`, questionData);
return res.data.data;
});
}
/**
* Fetches queried question
*
* @param id.id Question ID
* @param id.organizerId Organizer ID
*/
getQuestion(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/question/${id.id}`);
return res.data.data;
});
}
/**
* Deletes question with specified ID
*
* @param id.id Question ID
* @param id.organizerId Organizer ID
*/
deleteQuestion(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.delete(`event/${this.version}/organizer/${id.organizerId}/question/${id.id}`);
});
}
/**
* Sends tickets to users with provided emails
*
* @param ticketsData Data based on which the tickets are sent
*/
sendTickets(ticketsData) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.client.post(`event/${this.version}/ticket/send-group`, ticketsData);
return res.data.data;
});
}
/**
* Returns send ticket request by specified organizer for specified event
*
* @param id.organizerId Organizer ID
* @param id.id Event ID
*/
listSendTicketRequest(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/send_ticket_request?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data;
});
}
/**
* Returns send ticket request by its ID
*
* @param id.organizerId Organizer ID
* @param id.eventId Event ID
* @param id.id Send Request ID
*/
getSendTicketRequest(id_1) {
return __awaiter(this, arguments, void 0, function* (id, query = {}) {
const res = yield this.client.get(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/send_ticket_request/${id.id}?${(0, query_1.getStringifiedQuery)(query)}`);
return res.data.data;
});
}
/**
* Resends tickets for a specified send ticket request
*
* @param id.organizerId Organizer ID
* @param id.eventId Event ID
* @param id.id Send Request ID
*/
resendSendTicketRequest(id) {
return __awaiter(this, void 0, void 0, function* () {
yield this.client.post(`event/${this.version}/organizer/${id.organizerId