@accounty/moneybird
v1.0.4
Published
<img src="https://cdn.jsdelivr.net/npm/@accounty/moneybird/banner.png" alt="Accounty — Many providers. One interface." />
Readme
@accounty/moneybird
Sales invoices, external sales invoices, and their contacts from Moneybird.
Installation
yarn add @accounty/moneybirdUsage
Authentication: OAuth 2.0 or an existing access token.
import Moneybird from '@accounty/moneybird'
const provider = new Moneybird()
await provider.setCredentials({ accessToken: '<access-token>' })
const [administration] = await provider.getAdministrations()
if (!administration) {
throw new Error('No administration available')
}
await provider.setSettings(administration)
const { data: invoices } = await provider.fetchInvoicesWithCompany()Select the administration your user intends to access; the example uses the first.
For OAuth authorization and token refresh, pass clientId, clientSecret, and redirectUri
to the constructor. Persist credentials returned by getOauthToken() or
setCredentials(). See the OAuth guide.
Supported behavior
getAdministrations()lists administrations; pass the selected object tosetSettings(). Itsidandlanguageare used by requests and mappings.fetchInvoices()reads both sales invoices and external sales invoices.fetchInvoicesWithCompany()includes the contact embedded in each invoice.createInvoice(input)accepts the exportedMoneybirdCreateSalesInvoicetype and returns the nativeMoneybirdSalesInvoiceresponse.downloadInvoice(remoteId)uses the sales-invoice PDF endpoint; it is not an external-invoice download method.fetchCompanies()is not implemented and throws. UsefetchInvoicesWithCompany()when you need invoice contacts.
Fetch methods return { data, version? }. Amounts are integer cents, dates are
Date objects, and remoteData preserves provider records. Filter support varies
by provider.
