UNPKG

@hubs101/js-api-skd-client

Version:
187 lines (186 loc) 11 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._updatePackages = exports._deleteColocatedEvents = exports._editColocatedEvents = exports._createColocatedEvents = exports._fetchColocatedEvents = exports._updateAccountGroup = exports._createAccountGroup = exports._fetchAccountGroups = exports._fetchEventsByAccount = exports._fetchAccountEvents = exports._deletePaymentAccount = exports._deleteFinanceManager = exports._inviteFinanceManager = exports._confirmManagerNative = exports._confirmManager = exports._registerManagerNative = 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.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, 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.PUBLIC_INVITATIONS}/accounts/${accountId}/managers/register`, data); return response; }); exports._registerManager = _registerManager; const _registerManagerNative = (basePath, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.postRequestSimple)(`${base.PUBLIC_INVITATIONS}/accounts/${accountId}/managers/register`, data); return response; }); exports._registerManagerNative = _registerManagerNative; const _confirmManager = (basePath, 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.PUBLIC_INVITATIONS}/accounts/${accountId}/managers/confirm`, data); return response; }); exports._confirmManager = _confirmManager; const _confirmManagerNative = (basePath, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.postRequestSimple)(`${base.PUBLIC_INVITATIONS}/accounts/${accountId}/managers/confirm`, data); return response; }); exports._confirmManagerNative = _confirmManagerNative; 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.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 response = yield (0, api_1.getRequest)(url, token); return response; }); exports._fetchAccountEvents = _fetchAccountEvents; const _fetchEventsByAccount = (basePath, token, accountId, params) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const url = params ? `${base.ACCOUNTS}/${accountId}/events?${params}` : `${base.ACCOUNTS}/${accountId}/events`; const response = yield (0, api_1.getRequest)(url, token); return response; }); exports._fetchEventsByAccount = _fetchEventsByAccount; const _fetchAccountGroups = (basePath, token, accountId, type) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const groups = yield (0, api_1.getRequest)(`${base.ACCOUNTS}/${accountId}/groups?type=${type}`, token); return groups; }); exports._fetchAccountGroups = _fetchAccountGroups; const _createAccountGroup = (basePath, token, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); return (0, api_1.postRequestWE)(`${base.ACCOUNTS}/${accountId}/groups`, data, token); }); exports._createAccountGroup = _createAccountGroup; const _updateAccountGroup = (basePath, token, accountId, groupId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const groups = yield (0, api_1.putRequest)(`${base.ACCOUNTS}/${accountId}/groups/${groupId}`, token, data); return groups; }); exports._updateAccountGroup = _updateAccountGroup; const _fetchColocatedEvents = (basePath, token, accountId) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const groups = yield (0, api_1.getRequest)(`${base.ACCOUNTS}/${accountId}/colocated-events`, token); return groups; }); exports._fetchColocatedEvents = _fetchColocatedEvents; const _createColocatedEvents = (basePath, token, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const groups = yield (0, api_1.postRequestWE)(`${base.ACCOUNTS}/${accountId}/colocated-events`, data, token); return groups; }); exports._createColocatedEvents = _createColocatedEvents; const _editColocatedEvents = (basePath, token, id, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const groups = yield (0, api_1.putRequest)(`${base.ACCOUNTS}/colocated-events/${id}`, token, data); return groups; }); exports._editColocatedEvents = _editColocatedEvents; const _deleteColocatedEvents = (basePath, token, id) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.deleteRequestWE)(`${base.ACCOUNTS}/colocated-events/${id}`, token); return response; }); exports._deleteColocatedEvents = _deleteColocatedEvents; const _updatePackages = (basePath, token, accountId, data) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const res = yield (0, api_1.putRequest)(`${base.ACCOUNTS}/${accountId}/packages`, token, data); return res; }); exports._updatePackages = _updatePackages;