@marceloclp/monzojs
Version:
Unofficial wrapper for the Monzo API written in TypeScript.
47 lines (46 loc) • 1.7 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withdrawFromPot = exports.depositIntoPot = exports.getPots = void 0;
const create_request_1 = __importDefault(require("../utils/create-request"));
/**
* Returns a list of pots owned by the currently authorised user that are
* associated with the specified account.
*
* @see https://docs.monzo.com/#list-pots
*/
const getPots = async (accessToken, { accountId }) => (0, create_request_1.default)(accessToken)
.withQuery({ current_account_id: accountId })
.get(`pots`)
.then(({ pots }) => pots);
exports.getPots = getPots;
/**
* Move money from an account owned by the currently authorised user into one of
* their pots.
*
* @see https://docs.monzo.com/#deposit-into-a-pot
*/
const depositIntoPot = async (accessToken, { potId, accountId, amount, dedupeId }) => (0, create_request_1.default)(accessToken)
.withFormData({
source_account_id: accountId,
amount: amount,
dedupe_id: dedupeId,
})
.put(`pots/${potId}/deposit`);
exports.depositIntoPot = depositIntoPot;
/**
* Move money from a pot owned by the currently authorised user into one of
* their accounts.
*
* @see https://docs.monzo.com/#withdraw-from-a-pot
*/
const withdrawFromPot = async (accessToken, { potId, accountId, amount, dedupeId }) => (0, create_request_1.default)(accessToken)
.withFormData({
destination_account_id: accountId,
amount: amount,
dedupe_id: dedupeId,
})
.put(`pots/${potId}/withdraw`);
exports.withdrawFromPot = withdrawFromPot;