Improve your QuickBooks/Ruby integration experience with the quickbooks-ruby-base gem
Code from screencast and tutorial is available on Github.
Real-world to gem
I was recently able to wrap up a pattern from my QuickBooks/Ruby consulting into a gem. The gem complements and extends the quickbooks-ruby gem. Let's see how.
- First, install the gem along with
quickbooks-ruby. - Now you need to configure the persistent locations of the Intuit OAuth connection.
- For example, if you are storing the token, secret, and company_id like this:
-
account = Account.find(1) account.qb_token account.qb_secret account.company_id
- Your config file might look like this.
- Next, I am going fire up the
rails consoleto further demonstrate. - To create a
quickbooks-rubyservice takes only one line of code. - There is a
qr_modelmethod that generates and initializes a quickbooks-ruby model, which are long to type out by hand. - You can pass as many arguments to the model as it takes.
- Lastly, the
showmethod will return a "smart" array, customers in this example. -
"Smart" because the DESCvalue returned adapts to which service is being shown. For example, if its the invoice service calling show, then thedoc_numberis displayed forDESC(for customer service itsdisplay_name). - The show method saves you from having type the following below and it is most useful for console usage.
- You can also pass the same options you would to the
quickbooks-rubyquery method e.g.
bundle install.
config/initializers/quickbooks.rb.
service method is available off the base object so you can quickly access query, create, and update.
email_address model.
$ base.service.query.entities.map{ |e| "ID: #{e.id} DESC: #{e.display_name}" }
$ base.show(page: 1, per_page: 150)
The
show alone method is worth installing the gem.
Contributing
I want to keep the gem light weight but I would love to see pull requests coming from your QuickBooks/Ruby integration experiences. You can see the making of this gem in this 4 part series.
- Pushed on 04/21/2014 by Christian
- QuickBooks Integration Consulting
