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 console
to further demonstrate. - To create a
quickbooks-ruby
service takes only one line of code. - There is a
qr_model
method 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
show
method will return a "smart" array, customers in this example. -
"Smart" because the DESC
value returned adapts to which service is being shown. For example, if its the invoice service calling show, then thedoc_number
is 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-ruby
query method e.g.
![](https://d38ux1iykvusrb.cloudfront.net/articles/118/quickbooks-rails-base-gem-install.png)
bundle install
.![](https://d38ux1iykvusrb.cloudfront.net/articles/118/quickbooks-rails-base-gem-config.png)
config/initializers/quickbooks.rb
.![](https://d38ux1iykvusrb.cloudfront.net/articles/118/quickbooks-rails-base-gem-service.png)
service
method is available off the base object so you can quickly access query
, create
, and update
.![](https://d38ux1iykvusrb.cloudfront.net/articles/118/quickbooks-rails-base-gem-service-save.png)
![](https://d38ux1iykvusrb.cloudfront.net/articles/118/quickbooks-rails-base-gem-qr-model-before.png)
![](https://d38ux1iykvusrb.cloudfront.net/articles/118/quickbooks-rails-base-gem-qr-model-after.png)
![](https://d38ux1iykvusrb.cloudfront.net/articles/118/quickbooks-rails-base-gem-qr-model-args.png)
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