1.0.1 • Published 9 months ago

@invoicedesk/client v1.0.1

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

Official SDK for Invoice Desk API

This is the official SDK for the Invoice Desk API. If you would like to learn more about Inovice Desk, please visit https://inovicedesk.app.

This SDK is available on NPM at https://npmjs.com/@invoicedesk/sdk

This SDK allows you to easily interact with invoice desk's APIs. It fully typed requests, responses and entity objects so you don't have to refer to the documentation to get things rights.

Installation

npm

$ npm install @invoicedesk/sdk

yarn

$ yarn add @invoicedesk/sdk

pnpm

$ pnpm add @invoicedesk/sdk

Usage

All invocations requires a JWT token to authenticate requests with the server. The client accepts the following parameters on initialization. You can find the full documentation at Invoice Desk Docs page

ParameterDescriptionRequired?Default Value
hostInvoice Desk API hostNohttps://api.invoicedesk.app
versionThe version of the API to useNov1
import { InvoiceDesk } from '@invoicedesk/sdk';

const inoviceDesk = new InvoiceDesk();

Examples

Companies

async function listCompanies() {
  const companies = await invoiceDesk.companies.listCompanies({
    accountId: '...'
  });

  return companies;
}

Invoices

async function createInvoice(data) {
  const { data: invoice } = await invoiceDesk.invoices.createInvoice({
    createInvoicePayload: {
      clientId: "id-of-client-being-invoiced",
      date: "2021-01-01",
      currency: "USD",
      lineItems: [{
        title: "Nike Air",
        quantity: 1,
        price: 10000, // price in cents
        sortOrder: 0 // order the line item appears in the invoice
      }]
    },
    accountId: "...",
    companyId: "..."
  });

  return invoice;
}