Java SDKのサンプルコード - RESTクライアント操作

組織詳細の取得

import java.util.List;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Rest{
  public Rest() throws Exception{
    ZCRMRestClient.initialize(configurations_map);
  }
  public void  getOrganizationDetails()  throws Exception{
    ZCRMRestClient client = ZCRMRestClient.getInstance();
    APIResponse response = client.getOrganizationDetails();
    ZCRMOrganization org = (ZCRMOrganization) response.getData();
    System.out.println(org.getCompanyName());//to get the company name of the organization
        System.out.println(org.getOrgId());//to get the organization id of the organization
        System.out.println(org.getCountryCode());//to get the country code of the organization
        System.out.println(org.getCountry());//to get the the country of the organization
        System.out.println(org.getCurrencyLocale());//to get the country locale of the organization
        System.out.println(org.getFax());//to get the fax number of the organization
        System.out.println(org.getAlias());//to get the alias  of the organization
        System.out.println(org.getDescription());//to get the description of the organization
        System.out.println(org.getStreet());//to get the street name of the organization
        System.out.println(org.getCity());//to get the city name  of the organization
        System.out.println(org.getState());//to get the state  of the organization
        System.out.println(org.getZgid());//to get the zoho group id of the organization
        System.out.println(org.getWebsite());//to get the website  of the organization
        System.out.println(org.getPrimaryEmail());//to get the primary email of the organization
        System.out.println(org.getPrimaryZuid());//to get the primary zoho user id of the organization
        System.out.println(org.getIsoCode());//to get the iso code of the organization
        System.out.println(org.getPhone());//to get the phone number of the organization
        System.out.println(org.getMobile());//to get the mobile number of the organization
        System.out.println(org.getEmployeeCount());//to get the employee count of the organization
        System.out.println(org.getCurrencySymbol());//to get the currency symbol of the organization
        System.out.println(org.getTimeZone());//to get the time zone of the organization
        System.out.println(org.getMcStatus());//to get the multicurrency status of the organization
        System.out.println(org.isGappsEnabled());//to check whether the google apps is enabled
        System.out.println(org.getZipCode());//to get the zip code of the organization
        System.out.println(org.isPrivacySettingsEnabled());
  }
  public static void main(String[] args) throws Exception {
    Rest obj=new Rest();
    obj.getOrganizationDetails();
  }
}
 
現在のユーザーデータ取得

import java.util.List;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Rest{
  public Rest() throws Exception{
    ZCRMRestClient.initialize(configurations_map);
  }
  public void  getCurrentUser()  throws Exception{
    ZCRMRestClient client = ZCRMRestClient.getInstance();
    ZCRMUser user=(ZCRMUser)client.getCurrentUser().getData();
    System.out.println(user.getId());
    System.out.println(user.getZUId());
    System.out.println(user.getFirstName());
    System.out.println(user.getFirstName());
    System.out.println(user.getLastName());
    System.out.println(user.getFullName());
    System.out.println(user.getEmailId());
    System.out.println(user.getMobile());
    System.out.println(user.getLanguage());
    System.out.println(user.getAlias());
    System.out.println(user.getZip());
    System.out.println(user.getCity());
    System.out.println(user.getCountry());
    System.out.println(user.getCountryLocale());
    System.out.println(user.getFax());
    System.out.println(user.getDateFormat());
    System.out.println(user.getTimeFormat());
    System.out.println(user.getDateOfBirth());
    System.out.println(user.getLocale());
    System.out.println(user.getNameFormat());
    System.out.println(user.getPhone());
    System.out.println(user.getState());
    System.out.println(user.isConfirmed());
    System.out.println(user.getStreet());
    System.out.println(user.getTimeZone());
    System.out.println(user.getWebsite());
    System.out.println(user.getStatus());
    ZCRMProfile profile=(ZCRMProfile)user.getProfile();
    if(profile!=null){
      System.out.println(profile.getName());
      System.out.println(profile.getId());
    }
    ZCRMRole role=(ZCRMRole)user.getRole();
    if(role!=null){
      System.out.println(role.getName());
      System.out.println(role.getId());
    }
    ZCRMUser user1=(ZCRMUser)user.getCreatedBy();
    if(user1!=null){
      System.out.println(user1.getId());
      System.out.println(user1.getFirstName());
    }
    System.out.println(user.getCreatedTime());
    ZCRMUser user2=(ZCRMUser)user.getModifiedBy();
    if(user2!=null){
      System.out.println(user2.getId());
      System.out.println(user2.getFirstName());
    }
    System.out.println(user.getModifiedTime());
    ZCRMUser user3=(ZCRMUser)user.getReportingTo();
    if(user3!=null){
      System.out.println(user3.getId());
      System.out.println(user3.getFirstName());
    }
    
  }
  public static void main(String[] args) throws Exception {
    Rest obj=new Rest();
    obj.getCurrentUser();
  }
}
 
現在のユーザーのメールアドレス取得

import java.util.List;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Rest{
  public Rest() throws Exception{
    ZCRMRestClient.initialize(configurations_map);
  }
  public void  getCurrentUserEmail()  throws Exception{
    ZCRMRestClient client = ZCRMRestClient.getInstance();
    System.out.println(client.getCurrentUserEmail());
  }
  public static void main(String[] args) throws Exception {
    Rest obj=new Rest();
    obj.getCurrentUserEmail();
  }
}
 
タブリストの取得

import java.util.List;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Rest{
  public Rest() throws Exception{
    ZCRMRestClient.initialize(configurations_map);
  }
  public void getAllModules() throws Exception{
    ZCRMRestClient client = ZCRMRestClient.getInstance();
    BulkAPIResponse response = client.getAllModules();
    List<ZCRMModule> modules = (List<ZCRMModule>) response.getData();
    for(ZCRMModule module : modules){
      System.out.println(module.getApiName());
      System.out.println(module.getId());
      System.out.println(module.getSystemName());
      System.out.println(module.getApiName());
      System.out.println(module.getSingularLabel());
      System.out.println(module.getPluralLabel());
      System.out.println(module.isConvertible());
      System.out.println(module.isCreatable());
      System.out.println(module.isDeletable());
      System.out.println(module.isEditable());
      System.out.println(module.isViewable());
      System.out.println(module.getGeneratedType());
      System.out.println(module.getVisibility());
      ZCRMUser user=module.getModifiedBy();
      if(user!=null){
        System.out.println(user.getId());
        System.out.println(user.getFullName());
      }
      List <String> BusinessCards=(module.getBusinessCardFields());
      for (String BsuinessCard  : BusinessCards) {
              System.out.println(BsuinessCard);
          }
      List <ZCRMProfile> profiles=(module.getAccessibleProfiles());
      for(ZCRMProfile profile : profiles){
        System.out.println(profile.getId());
        System.out.println(profile.getName());
      }
    }
  }
  public static void main(String[] args) throws Exception {
    Rest obj=new Rest();
    obj.getAllModules();
  }
}
 
タブのメタデータ

import java.util.List;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;

public class Rest{
  public Rest() throws Exception{
    ZCRMRestClient.initialize(configurations_map);
  }
  public void getModule() throws Exception{
    ZCRMRestClient client = ZCRMRestClient.getInstance();
    APIResponse response = client.getModule("Leads");//leads is a module api name
    ZCRMModule module = (ZCRMModule)response.getData();
    System.out.println(module.getApiName());
    System.out.println(module.getId());
    System.out.println(module.getSystemName());
    System.out.println(module.getApiName());
    System.out.println(module.getSingularLabel());
    System.out.println(module.getPluralLabel());
    System.out.println(module.isConvertible());
    System.out.println(module.isCreatable());
    System.out.println(module.isDeletable());
    System.out.println(module.isEditable());
    System.out.println(module.isViewable());
    System.out.println(module.getGeneratedType());
    System.out.println(module.getVisibility());
    ZCRMUser user=module.getModifiedBy();
    if(user!=null){
      System.out.println(user.getId());
      System.out.println(user.getFullName());
    }
    List <String> BusinessCards=(module.getBusinessCardFields());
    for (String BsuinessCard  : BusinessCards) {
            System.out.println(BsuinessCard);
        }
    List <ZCRMProfile> profiles=(module.getAccessibleProfiles());
    for(ZCRMProfile profile : profiles){
      System.out.println(profile.getId());
      System.out.println(profile.getName());
    }
  }
  public static void main(String[] args) throws Exception {
    Rest obj=new Rest();
    obj.getModule();
  }
}