We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Let's pretend we're writing a background job that's handling our initial customer import request. We'll need to process the response from QuickBooks and store the customers in our database.
class ImportQuickbooksCustomersJob < ApplicationJob
queue_as :default
def perform(webhook_data)
quickbooks_request = QuickbooksRequest.find_by(qube_id: webhook_data[:id])
connection = quickbooks_request.qube_connection
customers_data = parse_customers(webhook_data[:response_json])
# It's a good idea to scope QB records to a specific connection
# so we don't have to worry about conflicts when they share the same ListID,
# change QB company files, etc.
connection.quickbooks_customers.create!(customers)
end
private
def parse_customers(response_json)
# There can be multiple requests / responses per
# qbxml request with QuickBooks, so the response_json
# will be an array of hashes. In this case,
# we expect only one response.
response_json.first.fetch("data")
end
end
That's it! Maybe check out the demo application for further implementation ideas. If you have any questions or need help, feel free to reach out to support@qubesync.com.