Node JS SDKのサンプルコード - 組織とユーザーの操作
var crmclient = require('zcrmsdk');
crmclient.initialize();
var params = {};
crmclient.API.ORG.get(params).then(function(response) {
// Response of the API call is returned in the 'body'
// The organization details are obtained from the first JSON object of the JSON Array corresponding
// to the 'org' key of the response
response = JSON.parse(response.body).org;
response = response[0];
// For obtaining all the fields of the organization details, use the value of 'response' as such
console.log(response);
// For obtaining a particular field, use response.<api-name of field>
// Sample API names: country, city
console.log(response.country);
});
//GET MULTIPLE USERS DATA
var crmclient = require('zcrmsdk');
crmclient.initialize();
input = {};
var params = {};
// See the list of possible parameters in the 'Parameters' section of the API help page
params.type = "AllUsers";
input.params = params;
crmclient.API.USERS.get(input).then(function(response) {
// Response of the API call is returned in the 'body'
// Users data value available as JSON Array of the 'users' key of the JSON response
// Each JSON object of the array corresponds to a user
// By iterating the JSON objects of the array, individual user details can be obtained
response = JSON.parse(response.body);
response = response.users;
// Iterating the JSON array
for(user in response) {
var user_data = response[user];
// For obtaining all the fields of the user details, use the value of 'user_data' as such
console.log(user_data);
// For obtaining a particular field, use user_data.<api-name of field>
// Sample API names: state, email
console.log(user_data.language);
}
});
//GET A PARTICULAR USER DATA
var crmclient = require('zcrmsdk');
crmclient.initialize();
input = {};
input.id = '3519112000000177021'; // id: user-id
crmclient.API.USERS.get(input).then(function(response) {
// Response of the API call is returned in the 'body'
// The user details are obtained from the first JSON object of the JSON Array corresponding
// to the 'users' key of the response
response = JSON.parse(response.body);
response = response.users[0];
// For obtaining all the fields of the user details, use the value of 'response' as such
console.log(response);
// For obtaining a particular field, use response.<api-name of field>
// Sample API names: state, email
console.log(response.language);
});