VtigerRuby
VtigerRuby is a Ruby SDK for the Vtiger CRM API.
Official documentation of the Vtiger API can be found here:
Installation
You can install this gem to your gemset.
gem install 'vtiger-ruby'
Or add it to your gemfile and run bundle install.
gem 'vtiger-ruby'
Getting Started
- Retrieve your
Accesskeytoken information from theMy Preferencespage in the CRM Web UI. -
usernameinformation used when signing into your instance of the CRM. -
endpointurl specific to your instance, eg: https://your_instance.odx.vtiger.com/restapi/v1/vtiger/default
Creating a Client
require 'vtiger-ruby'endpoint = ENV['VTIGER_ENDPOINT']
username = ENV['VTIGER_USERNAME']
accesskey = ENV['VTIGER_ACCESSS_KEY']client = VtigerRuby::Client.new(
endpoint: endpoint,
username: username,
accesskey: accesskey
)Authentication
Vtiger API Authentication happens in two steps:
- Request the challenge token
client.get_challenge- Login request
client.loginAlternatively, you can authenticate the client using the connect method.
This single method call negates the need to complete step 1 & step 2 listed above.
client.connectTo end the session on Vtiger and disconnect the client
client.logoutModels
The SDK arranges default Vtiger CRM Modules into model classes.
The model class can then be used to perform operations against the corresponding Vtiger module.
Account
client.account.all # Retrieves all Vtiger Account module recordsYou can also retrieve all Vtiger Account module records from the VtigerRuby::Account model.
VtigerRuby::Account.class_config(client) # Configures the class with client model
VtigerRuby::Account.all # Retrieves all Vtiger Account module recordsExample
require 'vtiger-ruby'
# Credential information specific to vtiger instance
endpoint = ENV['VTIGER_ENDPOINT']
username = ENV['VTIGER_USERNAME']
accesskey = ENV['VTIGER_ACCESSS_KEY']
# Initializes the VtigerRuby client
client = VtigerRuby::Client.new(
endpoint: endpoint,
username: username,
accesskey: accesskey
)
# Requests Vtiger challenge token and login
client.connect
# Retrieves all account records from the Account module
accounts = client.account.all