A Ruby interface to the Crunch Accounting API
Add this line to your application's Gemfile:
gem 'crunch-api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install crunch-api
Hurry up and show me how to call the service already...
First you need to register your application with Crunch Accounting using OAuth
Next require the gem:
require 'crunch-api'
Then, copy and paste your OAuth credentials into the configuration:
CrunchApi.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
And there you go, you're all set to access some Crunchy goodness
CrunchApi::Supplier.for_id(123)
For more examples of how to use this gem, see the Usage Examples below
All examples require OAuth configuration to be set in order to authenticate
Get all suppliers
CrunchApi::Supplier.all
Get a specific supplier
CrunchApi::Supplier.for_id(123)
Create a new supplier
CrunchApi::Supplier.create(name: 'Test Supplier')
Update an existing supplier
# using a hash of attributes
CrunchApi::Supplier.update(123, name: 'Test Supplier')
# using an existing supplier
supplier = CrunchApi::Supplier.for_id(123)
CrunchApi::Supplier.update(1, supplier)
Delete a supplier
CrunchApi::Supplier.delete(123)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request