import EventsRoutes from "../routes/EventsRoute"; import RecordingsRoute from "../routes/RecordingRoute"; import Requests from "../util/Requests"; import Response from "../util/Response"; import { AxiosPromise } from "axios"; class Events { /** * List all the events * * @see https://api.glitch.fun/api/documentation#/Event%20Route/resourceEventList * * @returns promise */ public static list(params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.list, undefined, undefined, params); } /** * Create a new event. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/newEventResourceStorage * * @param data The data to be passed when creating an event. * * @returns Promise */ public static create(data: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.create, data, undefined, params); } /** * Update a event * * @see https://api.glitch.fun/api/documentation#/Event%20Route/updateEventStorage * * @param event_id The id of the event to update. * @param data The data to update. * * @returns promise */ public static update(event_id: string, data: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.update, data, { event_id: event_id }, params); } /** * Retrieve the information for a single event. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/showEventStorage * * @param event_id The id fo the event to retrieve. * * @returns promise */ public static view(event_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.view, {}, { event_id: event_id }, params); } /** * Deletes a event. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/destoryEventStorage * * @param event_id The id of the event to delete. * @returns promise */ public static delete(event_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.delete, {}, { event_id: event_id }, params); } /** * The event is synced with Invirtu for the lie streams. This will allow you to update * * * @see https://api.glitch.fun/api/documentation#/Event%20Route/updateEventStorage * * @param event_id The id of the event to update. * @param data The data to update. * * @returns promise */ public static updateInvirtuEvent(event_id: string, data: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.updateInvirtu, data, { event_id: event_id }, params); } /** * Add an RTMP source to multicast a stream too. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/addRTMPSource * * @param event_id The id of the event. * @param data The data to be passed when adding an RTMP source. * * @returns promise */ public static addRTMPSource(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.addRTMPSource, data, { event_id: event_id }, params); } /** * Update an RTMP Source for multicasing. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/addRTMPSource * * @param event_id The id of the event. * @param data The data to be passed when adding an RTMP source. * * @returns promise */ public static updateRTMPSource(event_id: string, stream_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.updateRTMPSource, data, { event_id: event_id, subid: stream_id }, params); } /** * Remove a RTMP source for multicasing. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/addRTMPSource * * @param event_id The id of the event. * @param data The data to be passed when adding an RTMP source. * * @returns promise */ public static removeRTMPSource(event_id: string, stream_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.removeRTMPSource, data, { event_id: event_id, subid: stream_id }, params); } /** * Add a Twitch Stream to the current event. The user must have authenticatd with Twitch. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/addRTMPSource * * @param event_id The id of the event. * @param data The data to be passed when adding an RTMP source. * * @returns promise */ public static addTwitchMulticast(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.addTwitchMulticast, data, { event_id: event_id }, params); } /** * Add a Facebook Stream to the current event. The user must have authenticatd with Facebook. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/addRTMPSource * * @param event_id The id of the event. * @param data The data to be passed when adding an RTMP source. * * @returns promise */ public static addFacebookMulticast(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.addFacebookMulticast, data, { event_id: event_id }, params); } /** * Add a Youtube Stream to the current event. The user must have authenticatd with Google. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/addRTMPSource * * @param event_id The id of the event. * @param data The data to be passed when adding an RTMP source. * * @returns promise */ public static addYoutubeMulticast(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.addYoutubeMulticast, data, { event_id: event_id }, params); } /** * A function that should be run on an interval to set the event as live when the live stream is active. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/syncLive * * @param event_id The id of the event. * * @returns promise */ public static syncAsLive(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.syncAsLive, data, { event_id: event_id }, params); } /** * Updates the main image for the event using a File object. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/uploadMainEventImage * * @param file The file object to upload. * @param data Any additional data to pass along to the upload. * * @returns promise */ public static uploadMainImageFile(event_id: string, file: File, data?: object, params?: Record): AxiosPromise> { let url = EventsRoutes.routes.uploadMainImage.url.replace('{event_id}', event_id); return Requests.uploadFile(url, 'image', file, data); } /** * Updates the main image for the event using a Blob. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/uploadMainEventImage * * @param blob The blob to upload. * @param data Any additional data to pass along to the upload * * @returns promise */ public static uploadMainImageBlob(event_id: string, blob: Blob, data?: object, params?: Record): AxiosPromise> { let url = EventsRoutes.routes.uploadMainImage.url.replace('{event_id}', event_id); return Requests.uploadBlob(url, 'image', blob, data); } /** * Updates the banner image for the event using a File object. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/uploadBannerEventImage * * @param file The file object to upload. * @param data Any additional data to pass along to the upload. * * @returns promise */ public static uploadBannerImageFile(event_id: string, file: File, data?: object, params?: Record): AxiosPromise> { let url = EventsRoutes.routes.uploadBannerImage.url.replace('{event_id}', event_id); return Requests.uploadFile(url, 'image', file, data); } /** * Updates the banner image for the event using a Blob. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/uploadBannerEventImage * * @param blob The blob to upload. * @param data Any additional data to pass along to the upload * * @returns promise */ public static uploadBannerImageBlob(event_id: string, blob: Blob, data?: object, params?: Record): AxiosPromise> { let url = EventsRoutes.routes.uploadBannerImage.url.replace('{event_id}', event_id); return Requests.uploadBlob(url, 'image', blob, data); } /** * Enable Broadcast Mode. Broadcast mode is when the live stream is broadcasted from the game play through a protocol * such as screen sharing. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/enableBroadcastMode * * @param event_id The id of the event. * * @returns promise */ public static enableBroadcastMode(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.enableBroadcastMode, data, { event_id: event_id }, params); } /** * Enable livestream mode, in which the stream will be delivered to the invirtu RTMP endpoint for * streaming. * * @param event_id The id of the event. * * @returns promise */ public static enableLivestreamMode(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.enableLivestreamMode, data, { event_id: event_id }, params); } /** * Sends content that will appear on-screen to the user. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/sendOnScreenContent * * @param event_id The id of the event. * @param data The information to send on-screen. * * @returns promise */ public static sendOnScreenContent(event_id: string, data: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.enableLivestreamMode, data, { event_id: event_id }, params); } /** * Uploads an image that can be used and overlay later. A File object is used. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/uploadOverlayImage * * @param event_id The id of the event. * @param file The image as a file. * @param data Any additional data to be sent in the request. * * @returns promise */ public static addOverlayAsFile(event_id: string, file: File, data?: object): AxiosPromise> { let url = EventsRoutes.routes.addOverlay.url.replace('{event_id}', event_id); return Requests.uploadFile(url, 'image', file, data); } /** * Uploads an image that can be used and overlay later. A blob is used. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/uploadOverlayImage * * @param event_id The id of the event. * @param blob Image data as a blob * @param data Any additional data to be sent in the request. * * @returns promise */ public static addOverlayAsBlob(event_id: string, blob: Blob, data?: object, params?: Record): AxiosPromise> { let url = EventsRoutes.routes.addOverlay.url.replace('{event_id}', event_id); return Requests.uploadBlob(url, 'image', blob, data); } /** * Deletes an overlay image. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/destoryOverlayStorage * * @param event_id The id of the event. * @param overlay_id The id of the overlay. * * @returns promise */ public static removeOverlay(event_id: string, overlay_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.removeOverlay, {}, { event_id: event_id, subid: overlay_id }, params); } /** * Enables an overlay so that it will appear on screen. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/enableOverlayImage * * @param event_id The id of the event. * @param overlay_id The id of the overlay. * * @returns promise */ public static enableOverlay(event_id: string, overlay_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.enableOverlay, data, { event_id: event_id, subid: overlay_id }, params); } /** * Disables the overlay so it no longer appears on-screen. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/disableOverlay * * @param event_id The id of the event. * * @returns promise */ public static disableOverlay(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.disableOverlay, data, { event_id: event_id }, params); } /** * Enable the donations to appear on-screen * * @see https://api.glitch.fun/api/documentation#/Event%20Route/enableDonations * * @param event_id The id of the event. * * @returns promise */ public static enableDonations(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.enableDonations, data, { event_id: event_id }, params); } /** * Disable the donations and remove from the screen. * * @param event_id * @returns */ public static disableDonations(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.disableDonations, data, { event_id: event_id }, params); } public static sendInvite(event_id: string, data: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.sendInvite, data, { event_id: event_id }, params); } public static acceptInvite(event_id: string, token: string , params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.acceptInvite, { token: token }, { event_id: event_id }, params); } /** * Update a recording related to an event. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/updateEventRecording * * @param event_id The id of the event to update. * @param recording_id The id of the recording to update. * @param data The data to update. * * @returns promise */ public static updateRecording(event_id: string, recording_id: string, data: object, params?: Record): AxiosPromise> { return Requests.processRoute(RecordingsRoute.routes.update, data, { event_id: event_id, recording_id : recording_id }, params); } /** * Enable a widget for the current event. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/updateEventRecording * * @param event_id The id of the event to update. * @param widget_id The id of the widget to enable. * @param data The data, which should contain the roles. * * @returns promise */ public static enableWidget(event_id: string, widget_id: string, data: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.enableWidget, data, { event_id: event_id, widget_id : widget_id }, params); } /** * Disable a widget for the current event. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/updateEventRecording * * @param event_id The id of the event to update. * @param widget_id The id of the widget to disable. * * @returns promise */ public static disableWidget(event_id: string, widget_id: string, data: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.disableWidget, data, { event_id: event_id, widget_id : widget_id }, params); } /** * Get all the tips associated with the current event. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/updateEventRecording * * @param event_id The id of the event to update. * * @returns promise */ public static getTips(event_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.getTips, {}, { event_id: event_id }, params); } /** * Sets the personality attribute of the AI to adjust how it will respond. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/disableOverlay * * @param event_id The id of the event. * * @returns promise */ public static setAIAvatarPersonalityAttribute(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.setAIAvatarPersonalityAttribute, data, { event_id: event_id }, params); } /** * Sets the AI Avatars name, which it can respond too. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/disableOverlay * * @param event_id The id of the event. * * @returns promise */ public static setAIAvatarName(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.setAIAvatarName, data, { event_id: event_id }, params); } /** * Sets the AI Avatars accent, that will dictate the void in which it responds. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/disableOverlay * * @param event_id The id of the event. * * @returns promise */ public static setAIAccent(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.setAIAccent, data, { event_id: event_id }, params); } /** * Sets the AI Avatar to that it willr respond to users in the chat. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/disableOverlay * * @param event_id The id of the event. * * @returns promise */ public static setAIAvatarRespondToChat(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.setAIAvatarRespondToChat, data, { event_id: event_id }, params); } /** * Sets the AI Avatar so that it will respond to you. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/disableOverlay * * @param event_id The id of the event. * * @returns promise */ public static setAIAvatarRespondToMe(event_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.setAIAvatarRespondToMe, data, { event_id: event_id }, params); } /** * Get the associated statistics for the campaign. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/getStreamStatistics * * @returns promise */ public static statistics(event_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.statistics, undefined, { event_id: event_id }, params); } /** * Get the stream view counts for the campaign. * * @see https://api.glitch.fun/api/documentation#/Event%20Route/getEventStreamViewCounts * * @returns promise */ public static getStreamViewCounts(event_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(EventsRoutes.routes.streamViewCounts, undefined, { event_id: event_id }, params); } } export default Events;