Scala SDK Samples - Profile Operations
Get All Profiles
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