App File Needed for QuickBooks Source

I’d like to create a source for Quickbooks webhooks and I don’t see an app file in the components directory. Is that something I can go ahead and create myself? If so, is there anything special I need to know before I get started?

Hi Celeste,
Correct, when creating a Pipedream component based off an app supporting webhooks you’d need to create a source.
I’d recommend following this thread:
Getting started creating a new event source (Reddit) - Dev - Pipedream
There, when you see referencing the Component API docs, the link won’t work – they were moved to [Component API reference]( Component API Reference (pipedream.com)
Now, the example treated in a said thread is for Reddit, which is not based on webhooks. So once you have a general understanding on the component model, you could look at [Airtable sources]( pipedream/components at master · PipedreamHQ/pipedream (github.com)), which are based on webhooks.
Essentially, when you develop a component, you’d create an app file, a file for the component (action or source), and common logic files shared through out them.

1 Like

Hi Sergio,

I created an app file, a common file and a file for the source. I’m successfully receiving webhooks and emitting events. Now I’m trying to add an API call to look up the record details since the QuickBooks webhook only provides the record id.

I’m trying to add an axios request to a method in my app file. I thought I could get the authentication details for the connected QB account using this.$auth but it is undefined and gives me errors when I try to get the company_id or the oauth_access_token.

Comparing with github.app.js, I can’t see what I’m doing differently that would stop it from working, but maybe I’m missing something. Do you see any issues in what I have below?

const axios = require('axios')

const WEBHOOK_OPERATIONS = [
  'Create',
  'Update',
  'Merge',
  'Delete',
  'Void',
  'Emailed',
]

module.exports = {
  type: "app",
  app: "quickbooks",
  propDefinitions: {
    webhook_names: {
      type: 'string[]',
      label: 'Entities',
      description: 'Select which QuickBooks entities to emit or just leave it blank to emit them all.',
      options: [
        'Account',
        'Bill',
        'BillPayment',
        'Budget',
        'Class',
        'CreditMemo',
        'Currency',
        'Customer',
        'Department',
        'Deposit',
        'Employee',
        'Estimate',
        'Invoice',
        'Item',
        'JournalCode',
        'JournalEntry',
        'Payment',
        'PaymentMethod',
        'Preferences',
        'Purchase',
        'PurchaseOrder',
        'RefundReceipt',
        'SalesReceipt',
        'TaxAgency',
        'Term',
        'TimeActivity',
        'Transfer',
        'Vendor',
        'VendorCredit',
      ],
      optional: true,
    },
    webhook_operations: {
      type: 'string[]',
      label: 'Operations',
      description: 'Select which operations to emit or just leave it blank to emit them all.',
      options: WEBHOOK_OPERATIONS,
      default: WEBHOOK_OPERATIONS,
      optional: true,
    },
  },
  methods: {
    async getRecordDetails({name, id}){
      console.log(this.$auth) // <- undefined
      const config = {
        url: `https://quickbooks.api.intuit.com/v3/company/${this.$auth.company_id}/${name}/${id}`,
        headers: {
          Authorization: `Bearer ${this.$auth.oauth_access_token}`,
          "accept": `application/json`,
          "content-type": `application/json`,
        },
      }
      const response = await axios(config)
      return response[name]
    },
  },
};

I’m not sure what changed, but it’s working for me now.