Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

jiblits/zoho_crm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zoho::Crm

Wrapping zoho crm resources with class

Installation

Add this line to your application's Gemfile:

gem 'zoho-crm'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zoho-crm

Configuration

Create a config/zoho-crm.yml with a url and authtoken for each environment.

development:
  url: 'https://crm.zoho.com/crm/private'
  authtoken: <%= ENV["ZOHO_AUTH_TOKEN"] %>

How to use

Model

Your model should include ZohoCrm::Model to represent the resource, use the method custom_module_name to define the resource name listed on Zoho CRM and the method property to define the resource fields.

class MyLead
  include ZohoCrm::Model

  custom_module_name 'Leads'

  property :first_name, as: 'First Name'
  property :last_name, as: 'Last Name'
end

The as: option on property should be used to map the field name on Zoho CRM resource.

Record Repository

So far, the record repository represents the following api methods:

The repository should include ZohoCrm::Repositories::Records and associate your model using model method.

class MyLeadRepository
  include ZohoCrm::Repositories::Records

  model MyLead
end

Find record

lead_repo = MyLeadRepository.new

lead = lead_repo.find(1)

Create record

lead = MyLead.new(first_name: 'Rocky', last_name: 'Balboa')

lead_repo = MyLeadRepository.new
lead_repo.create(lead)

Update record

lead_repo = MyLeadRepository.new

lead = lead_repo.find(1)

lead.first_name = "Sylvester"
lead.last_name = "Stallone"

lead_repo.update(lead)

Save record

lead = MyLead.new(first_name: 'Rocky', last_name: 'Balboa')

lead_repo = MyLeadRepository.new
lead_repo.save(lead)

lead.first_name = 'Sylvester'
lead.last_name = 'Stallone'

lead_repo.save(lead)

Query record

lead_repo = MyLeadRepository.new

leads = lead_repo.select(:first_name).order(:last_name, :desc).from(0).to(10).where(first_name: 'Rocky')

Note that Zoho has a limit by 200 records for request, so it's necessary to control the result range using those methods #from and #to.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/zoho-crm/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages