1.0.3 • Published 6 months ago

node-appsync v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

node-appsync

nodejs client for AppSync API

Installation

npm install node-appsync

Documentation

var AppSync = require("node-appsync");

var aps = new AppSync({
  token: "<app_token>",
  debug: true, // enable debugging?
  useSandbox: true, // use the sandbox?
});

aps.getPluginToken(function (err, data) {
  if (err) console.log(err);
  else console.log(data);
});

aps.getMappedCustomers(
  {
    per_page: 4,
    current_page: 1,
    filter: "error",
    from_date: "2/14/2023",
    to_date: "2/15/2023",
    order_by: "updated_at",
    sort: "desc",
  },
  function (err, accounts) {
    accounts.QueryResponse.Account.forEach(function (account) {
      console.log(account.Name);
    });
  }
);

aps.updateCustomer(
  {
    CustomerId: "Q48nBE8J",
    FullyQualifiedName: "Eric James",
    sparse: true,
    PrimaryEmailAddr: {
      Address: "eric@example.com",
    },
  },
  function (err, data) {
    if (err) console.log(err);
    else console.log(data);
  }
);
Sorting

Basic ordering is achieved via the optional first argument object as well. Include asc or desc in the object whose values are the columns you wish to order on. For example:

aps.getMappedCustomers(
  {
    sort: "desc",
    order_by: "updated_at",
  },
  function (e, data) {
    console.log(data);
  }
);
Pagination

Pagination is achieved via the optional first argument object as well. Include per_page and/or current_page keys in the object whose values are the number of rows you wish to limit the result set to or from respectively. For example:

aps.getMappedCustomers(
  {
    per_page: 40,
    current_page: 1,
  },
  function (e, data) {
    console.log(data);
  }
);

Public Api

AppSync(token, useSandbox, debug)

Arguments

  • token - The app token received from AppSync
  • useSandbox - boolean flag to indicate whether to use Sandbox (i.e. for testing)
  • debug - boolean flag to log http requests, headers, and response bodies to the console

Admin

Create

Read

Update

Merchant

Create

Read

Update

Batch

createPluginToken(callback)

Creates the plugin's temporary access token

Arguments

  • callback - Callback function which is called with any error and the response data.

onboardMerchant(object, callback)

Creates new Merchant in AppSync.

Arguments

  • object - The unsaved Merchants, to be persisted in AppSync.
  • callback - Callback function which is called with any error and the response data.

getHostedPage(object, callback)

Retrieves Admin hosted page url.

Arguments

  • object - configuration object passed for initialization.
  • callback - Callback function which is called with any error and the response data.

createCustomer(object, callback)

Creates new customer in QuickBooks through AppSync.

Arguments

  • object - The customer object, to be synced with AppSync,
  • callback - Callback function which is called with any error and the response data.

createProduct(object, callback)

Creates new product in QuickBooks through AppSync.

Arguments

  • object - The product object, to be synced with AppSync,
  • callback - Callback function which is called with any error and the response data.

createInvoice(object, callback)

Creates new invoice in QuickBooks through AppSync.

Arguments

  • object - The invoice object, to be synced with AppSync,
  • callback - Callback function which is called with any error and the response data.

createPayment(object, callback)

Creates new payment in QuickBooks through AppSync.

Arguments

  • object - The payment object, to be synced with AppSync,
  • callback - Callback function which is called with any error and the response data.

getUserInfo(callback)

Retrieves user information from the AppSync

Arguments

  • callback - Callback function which is called with any error and the response data.

getAuthStartUrl(callback)

Retrieves OAuth start url to initialize connection with QuickBooks.

Arguments

  • callback - Callback function which is called with any error and the response data.

getOnboardedMerchants(callback)

Retrieves list of onboarded merchant's from the AppSync

Arguments

  • callback - Callback function which is called with any error and the response data.

getAnalytics(callback)

Retrieves count and overview data from the AppSync

Arguments

  • callback - Callback function which is called with any error and the response data.

getRecentSync(object, callback)

Retrieves list of successfully synced entities from the AppSync.

Arguments

  • object - Pagination, filter, sort params object.
  • callback - Callback function which is called with any error and the response data.

getMappedCustomers(object, callback)

Retrieves list of successfully synced customers from the AppSync.

Arguments

  • object - Pagination, filter, sort params object.
  • callback - Callback function which is called with any error and the response data.

getMappedProducts(object, callback)

Retrieves list of successfully synced products from the AppSync.

Arguments

  • object - Pagination, filter, sort params object.
  • callback - Callback function which is called with any error and the response data.

getMappedInvoices(object, callback)

Retrieves list of successfully synced invoices from the AppSync.

Arguments

  • object - Pagination, filter, sort params object.
  • callback - Callback function which is called with any error and the response data.

getMappedPayments(object, callback)

Retrieves list of successfully synced payments from the AppSync.

Arguments

  • object - Pagination, filter, sort params object.
  • callback - Callback function which is called with any error and the response data.

updateUserInfo(object, callback)

Updates User's information in AppSync.

Arguments

  • object - The unsaved User's information, to be persisted in AppSync.
  • callback - Callback function which is called with any error and the response data.

updateCustomer(object, callback)

Updates Customer object in QuickBooks through AppSync.

Arguments

  • object - The unsaved Customer object, to be persisted.
  • callback - Callback function which is called with any error and the response data.

updateProduct(object, callback)

Updates product object in QuickBooks through AppSync.

Arguments

  • object - The unsaved Product object, to be persisted.
  • callback - Callback function which is called with any error and the response data.

voidInvoice(object, callback)

Void's the Synced Invoice in QuickBooks.

Arguments

  • object - The unsaved Invoice object, to be voided.
  • callback - Callback function which is called with any error and the response data.

deleteInvoice(object, callback)

Delete's the Synced Invoice in QuickBooks.

Arguments

  • object - The unsaved Invoice object, to be deleted.
  • callback - Callback function which is called with any error and the response data.

updateMerchant(object, callback)

Updates onboarded merchant information in AppSync.

Arguments

  • object - The unsaved information of Merchant, to be persisted in AppSync.
  • callback - Callback function which is called with any error and the response data.

initiateBatchSync(object, callback)

Creates Sync Queue for batch data received from your application.

Arguments

  • object - Batch Data object to sync.
  • callback - Callback function which is called with any error and the response data.

initiateReverseSync(callback)

Retrieves information from platform and Add Sync Queue in AppSync.

Arguments

  • callback - Callback function which is called with any error and the response data.

triggerSync(callback)

Starts the sync process to create Data in QB received from Your Application

Arguments

  • callback - Callback function which is called with any error and the response data.

triggerReverseSync(callback)

Starts the sync process in reverse mode to send Data in Sync To Your Application

Arguments

  • callback - Callback function which is called with any error and the response data.