0.2.191 • Published 4 months ago

qbo v0.2.191

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

QBO

https://www.npmjs.com/package/qbo

Installation

yarn add qbo

or

npm install qbo

Usage

Initializing the client

import * as qbo from 'qbo';

const qboAPI = await qbo.client({
  access_token: "<QBO access token>", // Get this from completing OAuth2 flow with QBO
  refresh_token: "<QBO refresh token>", // Get this from completing OAuth2 flow with QBO
  client_id: "<YOUR QBO CLIENT ID>", // Get this from QBO developer portal
  client_secret: "<YOUR QBO ClIENT SECRET>", // Get this from QBO developer portal
  realm_id: "<YOUR QBO REALM ID>", // Get this from QBO developer portal
  use_sandbox: true // Do you want to use the QBO sandbox environment?
});

list

Return multiple records for an entity

arguments:
  • entity (string): the QBO entity
  • opts (optional object): an options object
    • offset (optional integer): after how many entity records to start the results at
    • limit (optional integer): how many total records to return
    • fetch_all (optional boolean): if true, return all entity records
    • asc (optional, cannot be used with desc): A field on the QBO entity being queried which the results should be sorted by in the ascending order
    • desc (optional, cannot be used with asc): A field on the QBO entity being queried which the results should be sorted by in the descending order
    • where (optional array of objects)
      • field (field name string): the QBO entity's field to use in this filter
      • value (string or number): the value against which this filter is tested
      • operator (one of =, IN, <, >, <=, >=, LIKE as a string): the operator to use in the comparison

basic usage

const customers = await qboAPI.list({
  entity: "customers"
});

// customers[0].PrimaryEmailAddr.Email etc. 

const accounts = await qboAPI.list({
  entity: "account"
});

advanced queries

const customers = await qboAPI.list({
  entity: "customer",
  opts: {
    where: [{
      field: "PrimaryEmailAddr",
      operator: "=",
      value: "lg@intuit.com"
    }],
    asc: "PrimaryEmailAddr" 
  }
});

const employees = await qboAPI.list({
  entity: "employee",
  opts: {
    where: [
      {
        field: "GivenName",
        operator: "LIKE",
        value: "son"
      },
      {
        field: "FamilyName",
        operator: "=",
        value: "Smith"
      },
      {
        field: "CostRate",
        operator: ">",
        value: 2200
      }
    ]
  }
});

report

Query report entities from QBO

arguments:
const transactions = await qboAPI.report({
  entity: "transactionList"
});
// transactions.Rows.Row[0].Rows.Row[0].ColData[0].value;


read

Return a single QBO entity for an ID

arguments

  • entity (string): the QBO entity
  • entity_id (string): the ID of the specific record for this entity you want to receive
const customer_25 = await qboAPI.read({
  entity: "customer",
  entity_id: "25"
});

upsert

Insert or Update a QBO record

arguments

  • entity (string): the QBO entity
  • record (object): the object properties of the record you want to update or create
// querying a customer record to update it
const customer_25 = await qboAPI.read({
  entity: "customer",
  entity_id: "25"
});

// updating the primary phone number property of the customer with id "25"
const updatedCustomer = await qboAPI.upsert({
  entity: "customer",
  record: {
    ...customer_25,
    PrimaryPhone:  {
      FreeFormNumber: "534-525-1234"
    }
  }
});

other methods and accessors

refreshAccessToken

Refreshes the current access token

await qboAPI.refreshAccessToken();

revokeAccess

Revokes access for a refresh or access token

await qboAPI.revokeAccess("REFRESH");
await qboAPI.revokeAccess("ACCESS");

get tokens

Gets the current refresh and access token. This throws an error if there is no access or refresh token

const { access_token, refresh_token } = qboAPI.tokens;

Limitations / Current status

There is no automatic way to create typescript types for Quickbooks Online entities (as far as I can tell), and because this repository was created in the interests of Client Powered, this API is only strongly typed for the limited subset of entities which are relevant to it so far.

Currently supported record entities are:

Currently supported report entities are:

This will likely be expanded in the near future as we integrate more entity types from Quickbooks Online into Client Powered. In the meantime, please feel free to create PRs to add additional types to the src/entity folder as needed!

0.2.19

4 months ago

0.2.18

4 months ago

0.2.17

4 months ago

0.2.16

4 months ago

0.2.15

4 months ago

0.2.14

4 months ago

0.2.13

4 months ago

0.2.12

4 months ago

0.2.191

4 months ago

0.2.1

4 months ago

0.2.0

4 months ago

0.1.21

7 months ago

0.1.11

7 months ago

0.1.12

7 months ago

0.1.13

7 months ago

0.1.14

7 months ago

0.1.15

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.16

7 months ago

0.1.17

7 months ago

0.1.18

7 months ago

0.1.0

10 months ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago