Run your entire business on Zoho with our unified cloud software, designed to help you break down silos between departments and increase organizational efficiency.
package com.zoho.crm.sample.profiles
import java.util
import com.zoho.crm.api.profiles.APIException
import com.zoho.crm.api.profiles.Category
import com.zoho.crm.api.profiles.PermissionDetail
import com.zoho.crm.api.profiles.ProfilesOperations
import com.zoho.crm.api.profiles.ResponseHandler
import com.zoho.crm.api.profiles.ResponseWrapper
import com.zoho.crm.api.profiles.Section
import com.zoho.crm.api.util.APIResponse
import com.zoho.crm.api.util.Model
object Profiles {
/**
* Get Profiles
* This method is used to retrieve the data of profiles through an API request and print the response.
*
* @throws Exception
*/
@throws[Exception]
def getProfiles(): Unit = { //Get instance of ProfilesOperations Class
val profilesOperations = new ProfilesOperations
//Call getProfiles method
val responseOption = profilesOperations.getProfiles
if (responseOption.isDefined) { //check response
var response= responseOption.get
println("Status Code: " + response.getStatusCode)
if (util.Arrays.asList(204, 304).contains(response.getStatusCode)) {
println(if (response.getStatusCode == 204) "No Content"
else "Not Modified")
return
}
//Check if expected response is received
if (response.isExpected) { //Get object from response
val responseHandler = response.getObject
if (responseHandler.isInstanceOf[ResponseWrapper]) { //Get the received ResponseWrapper instance
val responseWrapper = responseHandler.asInstanceOf[ResponseWrapper]
//Get the list of obtained Profile instances
val profiles = responseWrapper.getProfiles
for (profile {
println(entry._1 + ": " + entry._2)
})
//Get the Message
println("Message: " + exception.getMessage.getValue)
}
}
}
else { //If response is not as expected
//Get model object from response
val responseObject = response.getModel
//Get the response object's class
val clas = responseObject.getClass
//Get all declared fields of the response class
val fields = clas.getDeclaredFields
for (field
Get Specific Profile
package com.zoho.crm.sample.profiles
import java.util
import com.zoho.crm.api.profiles.APIException
import com.zoho.crm.api.profiles.Category
import com.zoho.crm.api.profiles.PermissionDetail
import com.zoho.crm.api.profiles.ProfilesOperations
import com.zoho.crm.api.profiles.ResponseHandler
import com.zoho.crm.api.profiles.ResponseWrapper
import com.zoho.crm.api.profiles.Section
import com.zoho.crm.api.util.APIResponse
import com.zoho.crm.api.util.Model
object Profiles {
/**
* Get Profile
* This method is used to get the details of any specific profile.
* Specify the unique id of the profile in your API request to get the data for that particular profile.
*
* @param profileId - The ID of the Profile to be obtained
* @throws Exception
*/
@throws[Exception]
def getProfile(profileId: Long): Unit = { //example
//Long profileId = 347706126011l
val profilesOperations = new ProfilesOperations
//Call getProfile method that takes profileId as parameter
val responseOption = profilesOperations.getProfile(profileId)
if (responseOption.isDefined) { //check response
var response= responseOption.get
println("Status Code: " + response.getStatusCode)
if (util.Arrays.asList(204, 304).contains(response.getStatusCode)) {
println(if (response.getStatusCode == 204) "No Content"
else "Not Modified")
return
}
if (response.isExpected) {
val responseHandler = response.getObject
if (responseHandler.isInstanceOf[ResponseWrapper]) {
val responseWrapper = responseHandler.asInstanceOf[ResponseWrapper]
val profiles = responseWrapper.getProfiles
for (profile {
println(entry._1 + ": " + entry._2)
})
println("Message: " + exception.getMessage.getValue)
}
}
else {
val responseObject = response.getModel
val clas = responseObject.getClass
val fields = clas.getDeclaredFields
for (field