UNPKG

event-app-api

Version:

Package for easy access to Event App API

120 lines (119 loc) 6.81 kB
"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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports._fetchAccountEvents = exports._deletePaymentAccount = exports._deleteFinanceManager = exports._inviteFinanceManager = exports._confirmManager = exports._registerManager = exports._deleteContentManager = exports._inviteContentManager = exports._updatePaymentAccount = exports._createPaymentAccount = exports._fetchPaymentAccounts = exports._fetchPaymentAccount = exports._sendNewPassword = exports._resetPassword = exports._logout = exports._login = void 0; const api_1 = require("../../utils/api"); const base_1 = require("../../utils/base"); const _login = (basePath, email, password) => __awaiter(void 0, void 0, void 0, function* () { if (!email) { return null; } const base = (0, base_1.getBasePath)(basePath); return (0, api_1.postRequest)(base.AUTH.LOGIN, { email, password, }); }); exports._login = _login; const _logout = (basePath, token) => __awaiter(void 0, void 0, void 0, function* () { if (!token) { return null; } const base = (0, base_1.getBasePath)(basePath); return yield (0, api_1.getRequest)(base.AUTH.LOGOUT, token); }); exports._logout = _logout; const _resetPassword = (basePath, body) => __awaiter(void 0, void 0, void 0, function* () { if (!basePath) { return null; } return (0, api_1.postRequest)(`${basePath}/v1/auth/password-reset-request`, body); }); exports._resetPassword = _resetPassword; const _sendNewPassword = (basePath, userId, body) => __awaiter(void 0, void 0, void 0, function* () { if (!basePath) { return null; } return (0, api_1.postRequest)(`${basePath}/v1/users/${userId}/reset-password`, body); }); exports._sendNewPassword = _sendNewPassword; const _fetchPaymentAccount = (basePath, token, paymentAccountId) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const { data: paymentAccount } = yield (0, api_1.getRequest)(`${base.PAYMENT_ACCOUNTS}/${paymentAccountId}/`, token); return paymentAccount; }); exports._fetchPaymentAccount = _fetchPaymentAccount; const _fetchPaymentAccounts = (basePath, token, accountId) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const { data: paymentAccounts } = yield (0, api_1.getRequest)(`${base.ACCOUNTS}/${accountId}/payment-accounts`, token); return paymentAccounts; }); exports._fetchPaymentAccounts = _fetchPaymentAccounts; const _createPaymentAccount = (basePath, token, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.postRequestWE)(base.PAYMENT_ACCOUNTS, data, token); return response; }); exports._createPaymentAccount = _createPaymentAccount; const _updatePaymentAccount = (basePath, token, paymentAccountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.putRequest)(`${base.PAYMENT_ACCOUNTS}/${paymentAccountId}`, token, data); return response; }); exports._updatePaymentAccount = _updatePaymentAccount; const _inviteContentManager = (basePath, token, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.postRequestWE)(`${base.PAYMENT_ACCOUNTS}/${accountId}/managers/content-managers`, data, token); return response; }); exports._inviteContentManager = _inviteContentManager; const _deleteContentManager = (basePath, token, accountId, profileId) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.deleteRequestWE)(`${base.ACCOUNTS}/${accountId}/managers/content-managers/${profileId}`, token); return response; }); exports._deleteContentManager = _deleteContentManager; const _registerManager = (basePath, token, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.postRequestWE)(`${base.PAYMENT_ACCOUNTS}/${accountId}/managers/content-managers`, data, token); return response; }); exports._registerManager = _registerManager; const _confirmManager = (basePath, token, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.postRequestWE)(`${base.PAYMENT_ACCOUNTS}/${accountId}/managers/confirm`, data, token); return response; }); exports._confirmManager = _confirmManager; const _inviteFinanceManager = (basePath, token, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.postRequestWE)(`${base.PAYMENT_ACCOUNTS}/${accountId}/managers/finances`, data, token); return response; }); exports._inviteFinanceManager = _inviteFinanceManager; const _deleteFinanceManager = (basePath, token, accountId, profileId) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.deleteRequestWE)(`${base.ACCOUNTS}/${accountId}/managers/finances/${profileId}`, token); return response; }); exports._deleteFinanceManager = _deleteFinanceManager; const _deletePaymentAccount = (basePath, token, paymentAccountId) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.deleteRequestWE)(`${base.PAYMENT_ACCOUNTS}/${paymentAccountId}`, token); return response; }); exports._deletePaymentAccount = _deletePaymentAccount; const _fetchAccountEvents = (basePath, token, url) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.getRequest)(url, token); return response; }); exports._fetchAccountEvents = _fetchAccountEvents;