Giter VIP home page Giter VIP logo

zohoapi's Introduction

zohoapi

Gateway library for easy access to Zoho V2 api

Purpose

This is a utility package for handling token mechanism of Zoho crm APIv2 across several projects. The module utilizes s3 as the storage mechanism of the oauth token.

Note: This currently works with local install of the module and not global

  1. Register a client to use with Zoho.
  2. Generate a self-authorized grant and refresh token as explained in the above link.
  3. Create a fill zoho_token.json with the following content and add the result you get in step 2.
{
	"access_token": "########",
	"expires_in": #######,
	"refresh_token":"##########"
}
  1. Create an s3 bucket or use an existing one and upload the file.

The module currently supports four operations - getRecords, getRecord, updateRecord and insertRecord.

Upon installation of the module, a .env file and resources folder containing two files - configuration.properties and oauth_configuration.properties are created in your project. Fill them based your AWS and Zoho credentials.

Install

Navigate to the root of your project folder and

npm install https://github.com/eyzhub/zohoapi.git  --save

Complete .env and files under resources

Usage examples

Zoho = require("zohoapi");
zoho =  new Zoho(); // optional enable debug messages | new Zoho( { debug: true } );
					// optional parallel execution | new Zoho( { records_batch_size: 5 } );
					// optional cache repeating calls | new Zoho( { cache: {} } );
					// trigger garbage collector and compress cache | new Zoho( { cache: {}, compress: true, gc: true } );
  1. Fetch records
let params = { module: "Accounts", page: 1, per_page: 2, has_subform: true };
let result = await zoho.getRecords(params);

if (result.records) {
	let records = result.records;
	console.log(records.length);
	// loop records
}


  1. Get a record
let result =  await zoho.getRecord("Offers", "1972094000016989067");
console.log(result);

if (result.record) {
	let record = result.record;
}

  1. Update a record
let data = [{ isan: "fooo-bar-nouse" }];
let result = await zoho.updateRecord("Filmv1", "1972094000017015005", data);

// should be 200
console.log(result.statusCode);
console.log(result.body);
  1. Insert record
let data = [{ isan: "fooo-bar-nouse", Name: "New film"}];
let result = await zoho.insertRecord("FilmV1", data);
console.log(result.body);
  1. Search records
let criteria = "(Product_Name:starts_with:Filmin DE)"
let params1 = { module: "Products", page: 1, per_page: 1, criteria: criteria };
let result1 = await zoho.searchRecords(params1);		
console.log(result1);
  1. Get all records
let params = { module: "Products"};
let result = await zoho.getAllRecords(params);

if (result.statusCode == 200) {
	let records = result.records;
	let relatedModules = result.related_modules;
	conso.log(relatedModules.length);
	console.log(records.length);
	// loop records
	// loop records of a relatedModule - relatedModules[0]["records"]
}

Note

  1. Use api names for the modules and field names (Tested).
  2. getAllRecords and getRecordsModifiedAfter return related modules of type multiselectlookup. To turn this off, set params.fetch_related = false
  3. subforms: To fectch subforms for all the data, use has_subform: true. To selecitvly get subform pass an object like this: where_subform: {key1: value1, key2: value2 ...}. This will be translated into (key1 == value1) && (key2 == value2)

zohoapi's People

Contributors

phanisaripalli avatar dseeker avatar eyzhub avatar kianrad avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.