mybudget-test
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

MyBudget API Client

This library is the the wrapper client for MyBudget API (@TODO: Paste API Address) for lastest browsers and Node.js. It needs an MyBudget API key to be configured.

Installation

yarn add mybudget
npm install mybudget

Usage

import MyBudget from 'mybudget'

const myBudgetApiKey = 'xyz-...-123'
const mb = new MyBudget(myBudgetApiKey)

async function addIncome() {
    try {
        const amountInPennies = 30000
        await mb.income.add('earn', amountInPennies)
        await mb.income.add('dividend', amountInPennies)
    } catch (e) {
        // Error occured while adding income
    }

}

async function addExpense() {
    try {
        const amountInPennies = 10000
        await mb.expense.add('house', amountInPennies)
        await mb.expense.add('food', amountInPennies)
    } catch (e) {
        // Error occured while adding expense
    }

}

async function getWallet() {
    try {
        const wallet = await mb.wallet.getByCurrency('PLN')

        /*
            wallet = {
                balance: 20000,
                currency: 'PLN'
            }

        */
    } catch (e) {
        // Error occured while getting wallet
    }

}

Readme

Keywords

Package Sidebar

Install

npm i mybudget-test

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

20.6 kB

Total Files

29

Last publish

Collaborators

  • jurijtokarski