npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reshuffle-quickbooks-connector

v0.0.3

Published

A Reshuffle Quickbooks connector

Downloads

5

Readme

reshuffle-quickbooks-connector

Code | npm | Code sample

npm install reshuffle-quickbooks-connector

Reshuffle Quickbooks Connector

This package contains a Reshuffle connector to connect QuickBooks Online app APIs. This connector requires to define a Reshuffle Datastore in order to maintain the Quickbooks access and refresh tokens, the Datastore can be in memory, file or Database. The connector takes care of refreshing the access token.

The following example exposes an endpoint to return the data of Bill after an Update action, the access and refresh tokens are stored in reshuffle DB and will be managed internally by the Reshuffle engine.

const { Reshuffle, SQLStoreAdapter } = require('reshuffle')
const { QuickbooksConnector } = require('reshuffle-quickbooks-connector')

const app = new Reshuffle()

const pool = new Pool({user: 'RESHUFFLE_DB_USER',
  host: 'RESHUFFLE_DB_HOST',
  database: 'RESHUFFLE_DB',
  password: 'RESHUFFLE_DB_PASS',
  port: RESHUFFLE_DB_PORT})
  const persistentStore = new SQLStoreAdapter(pool, 'reshuffledb')
  app.setPersistentStore(persistentStore)

const quickbooksConnector = new QuickbooksConnector(app, {
  realmId: 'REALM_ID',
  consumerKey: 'CONSUMER_KEY',
  consumerSecret: 'CONSUMER_SECRET',
  sandbox: true,
  debug: true,
  baseUrl: 'BASE_RUNTIME_URL',
  webhooksVerifier: 'WEBHOOK_VERIFIER'
})

quickbooksConnector.on({ type: 'Bill/Update' }, async (event, app) => {
  console.log('Bill/Update event ')
  console.log(event.id)
  console.log(event.name)
  console.log(event.operation)
})

app.start()

Table of Contents

Configuration Options

Connector Events

Listening to Quickbooks events

Connector Actions

SDK - Retrieve a full Quickbooks sdk object

Configuration options

const app = new Reshuffle()
const quickbooksConnector = new QuickbooksConnector(app, {
  realmId: 'YOUR_REALM_ID',
  consumerKey: 'CONSUMER_KEY',
  consumerSecret: 'CONSUMER_SECRET',
  sandbox: false, // Working environment, Sandbox or Production. Default false. Can be set in process.env.NODE_ENV
  debug: false, // Default false
  callback: 'CALLBACK_PATH', // Default '/callbacks/quickbooks', The path component of one of the redirect URIs listed for this project in the Quickbooks developer dashboard.
  webhookPath: 'WEBHOOK_PATH', // Default '/webhooks/quickbooks', The path component of the Webhook Endpoint URI for this project in the developer dashboard
  baseUrl: 'BASE_RUNTIME_URL',
  webhooksVerifier: 'WEBHOOK_VERIFIER' // Webhook Verifier Token for this project in the developer dashboard
})

sandbox, debug, callback and webhookPath are optional.

More details about the fields are described in node-quickbooks

You can use the webhookPath to configure the url that Quickbooks hits when it makes its calls to. For example - providing baseURL=https://my-reshuffle.com and webhookPath='/webhook will result in a complete webhook path of https://my-reshuffle.com/webhook. If you do not provide a webhookPath, Reshuffle will use the default webhook path for the connector which is /webhooks/quickbooks. You will need to register this webhook with Quickbooks. See instructions.

You can use the callback to configure the redirect URI that your app serves to users upon authentication. For example - providing baseURL=https://my-reshuffle.com and callback='/callback will result in a complete webhook path of https://my-reshuffle.com/callback. If you do not provide a callback, Reshuffle will use the default callback path for the connector which is /callbacks/quickbooks. You will need to register this callback with Quickbooks. See more details about authentication.

Events

Listening to Quickbooks events

To listen to events happening in Quickbooks, you'll need to capture them with the connector's on function, providing a QuickbooksConnectorEventOptions to it.

interface QuickbooksConnectorEventOptions {
  type: QBEventType // See bellow 
}

// Where...
type QBEventType =
  | 'Account/Delete'
  | 'Account/Merge'
  | 'Account/Create'
  | 'Account/Update'
  | 'Bill/Delete'
  | 'Bill/Create'
  | 'Bill/Update'
  | 'BillPayment/Delete'
  | 'BillPayment/Void'
  | 'BillPayment/Create'
  | 'BillPayment/Update'
  | 'Budget/Create'
  | 'Budget/Update'
  | 'Class/Delete'
  | 'Class/Merge'
  | 'Class/Create'
  | 'Class/Update'
  | 'CreditMemo/Delete'
  | 'CreditMemo/Emailed'
  | 'CreditMemo/Void'
  | 'CreditMemo/Create'
  | 'CreditMemo/Update'
  | 'Currency/Create'
  | 'Currency/Update'
  | 'Customer/Delete'
  | 'Customer/Merge'
  | 'Customer/Create'
  | 'Customer/Update'
  | 'Department/Merge'
  | 'Department/Create'
  | 'Department/Update'
  | 'Deposit/Delete'
  | 'Deposit/Create'
  | 'Deposit/Update'
  | 'Employee/Delete'
  | 'Employee/Merge'
  | 'Employee/Create'
  | 'Employee/Update'
  | 'Estimate/Delete'
  | 'Estimate/Emailed'
  | 'Estimate/Create'
  | 'Estimate/Update'
  | 'Invoice/Delete'
  | 'Invoice/Emailed'
  | 'Invoice/Void'
  | 'Invoice/Create'
  | 'Invoice/Update'
  | 'Item/Delete'
  | 'Item/Merge'
  | 'Item/Create'
  | 'Item/Update'
  | 'JournalCode/Create'
  | 'JournalCode/Update'
  | 'JournalEntry/Delete'
  | 'JournalEntry/Create'
  | 'JournalEntry/Update'
  | 'Payment/Delete'
  | 'Payment/Emailed'
  | 'Payment/Void'
  | 'Payment/Create'
  | 'Payment/Update'
  | 'PaymentMethod/Merge'
  | 'PaymentMethod/Create'
  | 'PaymentMethod/Update'
  | 'Preferences/Update'
  | 'Purchase/Delete'
  | 'Purchase/Void'
  | 'Purchase/Create'
  | 'Purchase/Update'
  | 'PurchaseOrder/Delete'
  | 'PurchaseOrder/Emailed'
  | 'PurchaseOrder/Create'
  | 'PurchaseOrder/Update'
  | 'RefundReceipt/Delete'
  | 'RefundReceipt/Emailed'
  | 'RefundReceipt/Void'
  | 'RefundReceipt/Create'
  | 'RefundReceipt/Update'
  | 'SalesReceipt/Delete'
  | 'SalesReceipt/Emailed'
  | 'SalesReceipt/Void'
  | 'SalesReceipt/Create'
  | 'SalesReceipt/Update'
  | 'TaxAgency/Create'
  | 'TaxAgency/Update'
  | 'Term/Create'
  | 'Term/Update'
  | 'TimeActivity/Delete'
  | 'TimeActivity/Create'
  | 'TimeActivity/Update'
  | 'Transfer/Delete'
  | 'Transfer/Void'
  | 'Transfer/Create'
  | 'Transfer/Update'
  | 'Vendor/Delete'
  | 'Vendor/Merge'
  | 'Vendor/Create'
  | 'Vendor/Update'
  | 'VendorCredit/Delete'
  | 'VendorCredit/Create'
  | 'VendorCredit/Update'

Events require that an integration webhook is configured in Quickbooks.

The connector triggers events of the following type:

interface QBEvent {
  realmId: string
  name: string // Entity type name e.g. Customer, Account, Bill
  id: string   // Entity ID
  operation: string 
  lastUpdated: string
  action: string
}

Example:

quickbooksConnector.on({ type: 'Bill/Update' }, async (event, app) => {
  console.log('Bill/Update event ')
  console.log(event.id)
  console.log(event.name)
  console.log(event.operation)
})

The description of fields and events can be found here

Actions

The actions are provided via the sdk.

sdk

Returns an object providing full access to the Quickbooks APIs. Full list of available actions in node-quickbooks

const sdk = await connector.sdk()

Example:

const sdk = await quickbooksConnector.sdk()
sdk.getCompanyInfo('YOUR_REALM_ID', function(err, result) {
  console.log('Result: ', JSON.stringify(result))
}