1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import { isAdminRequired } from "./hooks";
- // eslint-disable-next-line
- import moduleManager from "../../index";
- const UtilsModule = moduleManager.modules.utils;
- const YouTubeModule = moduleManager.modules.youtube;
- export default {
- /**
- * Returns details about the YouTube quota usage
- *
- * @returns {{status: string, data: object}}
- */
- getQuotaStatus: isAdminRequired(function getQuotaStatus(session, fromDate, cb) {
- YouTubeModule.runJob("GET_QUOTA_STATUS", { fromDate }, this)
- .then(response => {
- this.log("SUCCESS", "YOUTUBE_GET_QUOTA_STATUS", `Getting quota status was successful.`);
- return cb({ status: "success", data: { status: response.status } });
- })
- .catch(async err => {
- err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
- this.log("ERROR", "YOUTUBE_GET_QUOTA_STATUS", `Getting quota status failed. "${err}"`);
- return cb({ status: "error", message: err });
- });
- }),
- /**
- * Returns api requests
- *
- * @returns {{status: string, data: object}}
- */
- getApiRequests: isAdminRequired(function getApiRequests(session, fromDate, cb) {
- YouTubeModule.runJob("GET_API_REQUESTS", { fromDate }, this)
- .then(response => {
- this.log("SUCCESS", "YOUTUBE_GET_API_REQUESTS", `Getting api requests was successful.`);
- return cb({ status: "success", data: { apiRequests: response.apiRequests } });
- })
- .catch(async err => {
- err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
- this.log("ERROR", "YOUTUBE_GET_API_REQUESTS", `Getting api requests failed. "${err}"`);
- return cb({ status: "error", message: err });
- });
- }),
- /**
- * Returns a specific api request
- *
- * @returns {{status: string, data: object}}
- */
- getApiRequest: isAdminRequired(function getApiRequest(session, apiRequestId, cb) {
- YouTubeModule.runJob("GET_API_REQUEST", { apiRequestId }, this)
- .then(response => {
- this.log(
- "SUCCESS",
- "YOUTUBE_GET_API_REQUEST",
- `Getting api request with id ${apiRequestId} was successful.`
- );
- return cb({ status: "success", data: { apiRequest: response.apiRequest } });
- })
- .catch(async err => {
- err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
- this.log(
- "ERROR",
- "YOUTUBE_GET_API_REQUEST",
- `Getting api request with id ${apiRequestId} failed. "${err}"`
- );
- return cb({ status: "error", message: err });
- });
- })
- };
|