Wraps the raw HTTP based API of Zoho Reports with easy to use methods for the ruby platform. This enables ruby and Rails developers to easily use Zoho Reports API.
Add this line to your application's Gemfile:
gem 'zoho_reports'
And then execute:
$ bundle
Or install it yourself as:
$ gem install zoho_reports
# (usually in /config/intializers/zoho_reports.rb)
ZohoReports.configure do |config|
config.auth_token = 'token'
config.login_email = '[email protected]'
config.database_name = 'test_database'
end
client = ZohoReports::Client.new
This example shows how to import the "Widget" model records, including creating a table if it doesn't already exist.
# Clean up the dates prior to json-ing the attributes
Widget.all.each do |model|
zoho_all = ZohoReports::Client.zoho_attributes(model)
end
client.import_data(
"test_database",
"widgets",
'UPDATEADD',
zoho_all.to_json,
'ZOHO_MATCHING_COLUMNS' => 'id',
'ZOHO_CREATE_TABLE' => 'true',
)
When importing through the API and generating a new table, string and datetime date types import correctly with format. However, here are the steps provided through the Zoho Reports wiki comments in case you have an issue with the column format:
- Login into Zoho Reports, Open the import wizard ( "Import Excel, CSV, HTML, Google docs,.." ), upload your file.
- Click "Next" button to go to the next screen of import wizard (i.e step 2 of 2), there you can see the preview table.
- In that table, the first row will be header row ( i.e., Column names ) and the second row will be the datatype which is auto identified by our Zoho Reports system. There you can change the column datatype to "Text" for the column you want to change. Then, continue the import process.
ZohoReports includes a module specific to ActiveReports that may be used as follows:
# /app/models/widget.rb
class Widget < ActiveRecord::Base
zoho_reportify
...
end
This adds two things to your Rails app.
- Widget.intialize_zoho_table will create the database table based on Widget.table_name and load all of the current data into it
- Adds an after_save callback that stores the instance attributes into the Zoho Reports table keeping your data in sync
- Fork it ( http://github.com//zoho_reports/fork )
- 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