diff --git a/samples/main/Test.php b/samples/main/Test.php
new file mode 100644
index 0000000..c27a0cf
--- /dev/null
+++ b/samples/main/Test.php
@@ -0,0 +1,614 @@
+
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/attachments/Attachment.php b/samples/src/com/zoho/crm/api/attachments/Attachment.php
new file mode 100644
index 0000000..db8d021
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/attachments/Attachment.php
@@ -0,0 +1,821 @@
+ Get Attachments
+ * This method is used to get a single record's attachments' details with ID and print the response.
+ * @throws Exception
+ * @param moduleAPIName The API Name of the record's module
+ * @param recordId The ID of the record to get attachments
+ */
+ public static function getAttachments(string $moduleAPIName, string $recordId)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
+ $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ //Possible parameters of Get Attachments Operation
+ $paramInstance->add(GetAttachmentsParam::fields(), "id,Modified_Time");
+
+ $paramInstance->add(GetAttachmentsParam::page(), 1);
+
+ $paramInstance->add(GetAttachmentsParam::perPage(), 100);
+
+ //Call getAttachments method that takes ParameterMap instance as parameter
+ $response = $attachmentOperations->getAttachments($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Attachment instances
+ $attachments = $responseWrapper->getData();
+
+ foreach ($attachments as $attachment)
+ {
+ //Get the owner User instance of each attachment
+ $owner = $attachment->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the Name of the Owner
+ echo("Attachment Owner User-Name: " . $owner->getName() . "\n");
+
+ //Get the ID of the Owner
+ echo("Attachment Owner User-ID: " . $owner->getId() . "\n");
+
+ //Get the Email of the Owner
+ echo("Attachment Owner User-Email: " . $owner->getEmail() . "\n");
+ }
+
+ //Get the modified time of each attachment
+ echo("Attachment Modified Time: ");
+
+ print_r($attachment->getModifiedTime());
+
+ echo("\n");
+
+ //Get the name of the File
+ echo("Attachment File Name: " . $attachment->getFileName() . "\n");
+
+ //Get the created time of each attachment
+ echo("Attachment Created Time: " );
+
+ print_r($attachment->getCreatedTime());
+
+ echo("\n");
+
+ //Get the Attachment file size
+ echo("Attachment File Size: " . $attachment->getSize() . "\n");
+
+ //Get the parentId Record instance of each attachment
+ $parentId = $attachment->getParentId();
+
+ //Check if parentId is not null
+ if($parentId != null)
+ {
+ //Get the parent record Name of each attachment
+ echo("Attachment parent record Name: " . $parentId->getKeyValue("name") . "\n");
+
+ //Get the parent record ID of each attachment
+ echo("Attachment parent record ID: " . $parentId->getId() . "\n");
+ }
+
+ //Get the attachment is Editable
+ echo("Attachment is Editable: " . $attachment->getEditable() . "\n");
+
+ //Get the file ID of each attachment
+ echo("Attachment File ID: " . $attachment->getFileId() . "\n");
+
+ //Get the type of each attachment
+ echo("Attachment File Type: " . $attachment->getType() . "\n");
+
+ //Get the seModule of each attachment
+ echo("Attachment seModule: " . $attachment->getSeModule() . "\n");
+
+ //Get the modifiedBy User instance of each attachment
+ $modifiedBy = $attachment->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Attachment Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Attachment Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Attachment Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the state of each attachment
+ echo("Attachment State: " . $attachment->getState() . "\n");
+
+ //Get the ID of each attachment
+ echo("Attachment ID: " . $attachment->getId() . "\n");
+
+ //Get the createdBy User instance of each attachment
+ $createdBy = $attachment->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the name of the createdBy User
+ echo("Attachment Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Attachment Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Attachment Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the linkUrl of each attachment
+ echo("Attachment LinkUrl: " . $attachment->getLinkUrl() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ *
Upload Attachments
+ * This method is used to upload an attachment to a single record of a module with ID and print the response.
+ * @throws Exception
+ * @param moduleAPIName The API Name of the record's module
+ * @param recordId The ID of the record to upload attachment
+ * @param absoluteFilePath The absolute file path of the file to be attached
+ */
+ public static function uploadAttachments(string $moduleAPIName, string $recordId, string $absoluteFilePath)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$absoluteFilePath = "/Users/use_name/Desktop/image.png"
+
+ //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
+ $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
+
+ //Get instance of FileBodyWrapper class that will contain the request file
+ $fileBodyWrapper = new FileBodyWrapper();
+
+ //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
+ $streamWrapper = new StreamWrapper(null, null, $absoluteFilePath);
+
+ //Set file to the FileBodyWrapper instance
+ $fileBodyWrapper->setFile($streamWrapper);
+
+ //Call uploadAttachment method that takes FileBodyWrapper instance as parameter
+ $response = $attachmentOperations->uploadAttachment($fileBodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Attachments
+ * This method is used to Delete attachments to a single record of a module with ID and print the response.
+ * @param moduleAPIName The API Name of the record's module
+ * @param recordId The ID of the record to delete attachment
+ * @param attachmentIds The List of attachment IDs to be deleted
+ */
+ public static function deleteAttachments(string $moduleAPIName, string $recordId, array $attachmentIds)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$attachmentIds = array("3477061000005177001","3477061000005177003");
+
+ //Get instance of RecordOperations Class that takes recordId and moduleAPIName as parameter
+ $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($attachmentIds as $attachmentId)
+ {
+ $paramInstance->add(DeleteAttachmentsParam::ids(), $attachmentId);
+ }
+
+ //Call deleteAttachments method that takes paramInstance as parameter
+ $response = $attachmentOperations->deleteAttachments($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Download Attachment
+ * This method is used to download an attachment of a single record of a module with ID and attachment ID and write the file in the specified destination.
+ * @throws Exception
+ * @param moduleAPIName The API Name of the record's module
+ * @param recordId The ID of the record to download attachment
+ * @param attachmentId The ID of the attachment to be downloaded
+ * @param destinationFolder The absolute path of the destination folder to store the attachment
+ */
+ public static function downloadAttachment(string $moduleAPIName, string $recordId, string $attachmentId, string $destinationFolder)
+ {
+ //example
+ //moduleAPIName = "Leads";
+ //recordId = "3477061000005177002";
+ //attachmentId = "3477061000005177023";
+ //destinationFolder = "/Users/user_name/Desktop"
+
+ //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
+ $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
+
+ //Call downloadAttachment method that takes attachmentId as parameters
+ $response = $attachmentOperations->downloadAttachment($attachmentId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if($response->getStatusCode() == 204)
+ {
+ echo("No Content\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof FileBodyWrapper)
+ {
+ //Get the received FileBodyWrapper instance
+ $fileBodyWrapper = $responseHandler;
+
+ //Get StreamWrapper instance from the returned FileBodyWrapper instance
+ $streamWrapper = $fileBodyWrapper->getFile();
+
+ //Create a file instance with the absolute_file_path
+ $fp = fopen($destinationFolder."/".$streamWrapper->getName(), "w");
+
+ //Get stream from the response
+ $stream = $streamWrapper->getStream();
+
+ fputs($fp, $stream);
+
+ fclose($fp);
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Attachment
+ * This method is used to delete an attachment to a single record of a module with ID and print the response.
+ * @param moduleAPIName The API Name of the record's module
+ * @param recordId The ID of the record to delete attachment
+ * @param attachmentId The ID of the attachment to be deleted
+ */
+ public static function deleteAttachment(string $moduleAPIName, string $recordId, string $attachmentId)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$attachmentIds = array("3477061000005177001","3477061000005177003");
+
+ //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
+ $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
+
+ //Call deleteAttachment method that takes attachmentId as parameter
+ $response = $attachmentOperations->deleteAttachment($attachmentId);
+
+ if($response != null)
+ {
+
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Upload Link Attachments
+ * This method is used to upload link attachment to a single record of a module with ID and print the response.
+ * @param moduleAPIName The API Name of the record's module
+ * @param recordId The ID of the record to upload Link attachment
+ * @param attachmentURL The attachmentURL of the doc or image link to be attached
+ */
+ public static function uploadLinkAttachments(string $moduleAPIName, string $recordId, string $attachmentURL)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$attachmentURL = "https://5.imimg.com/data5/KJ/UP/MY-8655440/zoho-crm-500x500.png";
+
+ //Get instance of AttachmentsOperations Class that takes recordId and moduleAPIName as parameter
+ $attachmentOperations = new AttachmentsOperations($moduleAPIName, $recordId);
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(UploadLinkAttachmentParam::attachmentUrl(), $attachmentURL);
+
+ //Call uploadAttachment method that takes paramInstance as parameter
+ $response = $attachmentOperations->uploadLinkAttachment($paramInstance);
+
+ if($response != null)
+ {
+
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/blueprint/BluePrint.php b/samples/src/com/zoho/crm/api/blueprint/BluePrint.php
new file mode 100644
index 0000000..c566628
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/blueprint/BluePrint.php
@@ -0,0 +1,579 @@
+ Get Blueprint
+ * This method is used to get a single record's Blueprint details with ID and print the response.
+ * @param moduleAPIName The API Name of the record's module
+ * @param recordId The ID of the record to get Blueprint
+ * @throws Exception
+ */
+ public static function getBlueprint(string $moduleAPIName, string $recordId)
+ {
+ //Get instance of BluePrintOperations Class that takes recordId and moduleAPIName as parameter
+ $bluePrintOperations = new BluePrintOperations($recordId,$moduleAPIName);
+
+ //Call getBlueprint method
+ $response = $bluePrintOperations->getBlueprint();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained BluePrint instance
+ $bluePrint = $responseWrapper->getBlueprint();
+
+ //Get the ProcessInfo instance of the obtained BluePrint
+ $processInfo = $bluePrint->getProcessInfo();
+
+ //Check if ProcessInfo is not null
+ if($processInfo != null)
+ {
+ //Get the Field ID of the ProcessInfo
+ echo("ProcessInfo Field-ID: " . $processInfo->getFieldId() . "\n");
+
+ //Get the isContinuous of the ProcessInfo
+ echo("ProcessInfo isContinuous: " . $processInfo->getIsContinuous() . "\n");
+
+ //Get the API Name of the ProcessInfo
+ echo("ProcessInfo API Name: " . $processInfo->getAPIName() . "\n");
+
+ //Get the Continuous of the ProcessInfo
+ echo("ProcessInfo Continuous: " . $processInfo->getContinuous() . "\n");
+
+ //Get the FieldLabel of the ProcessInfo
+ echo("ProcessInfo FieldLabel: " . $processInfo->getFieldLabel() . "\n");
+
+ //Get the Name of the ProcessInfo
+ echo("ProcessInfo Name: " . $processInfo->getName() . "\n");
+
+ //Get the ColumnName of the ProcessInfo
+ echo("ProcessInfo ColumnName: " . $processInfo->getColumnName() . "\n");
+
+ //Get the FieldValue of the ProcessInfo
+ echo("ProcessInfo FieldValue: " . $processInfo->getFieldValue() . "\n");
+
+ //Get the ID of the ProcessInfo
+ echo("ProcessInfo ID: " . $processInfo->getId() . "\n");
+
+ //Get the FieldName of the ProcessInfo
+ echo("ProcessInfo FieldName: " . $processInfo->getFieldName() . "\n");
+ }
+
+ //Get the list of transitions from BluePrint instance
+ $transitions = $bluePrint->getTransitions();
+
+ foreach($transitions as $transition)
+ {
+ $nextTransitions = $transition->getNextTransitions();
+
+ foreach($nextTransitions as $nextTransition)
+ {
+ //Get the ID of the NextTransition
+ echo("NextTransition ID: " . $nextTransition->getId() . "\n");
+
+ //Get the Name of the NextTransition
+ echo("NextTransition Name: " . $nextTransition->getName() . "\n");
+ }
+
+ //Get the PercentPartialSave of each Transition
+ echo("Transition PercentPartialSave: " . $transition->getPercentPartialSave() . "\n");
+
+ $data = $transition->getData();
+
+ if($data != null)
+ {
+ //Get the ID of each record
+ echo("Record ID: " . $data->getId() . "\n");
+
+ //Get the createdBy User instance of each record
+ $createdBy = $data->getCreatedBy();
+
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("Record Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("Record Created By User-Name: " . $createdBy->getName() . "\n");
+ }
+
+ //Check if the created time is not null
+ if($data->getCreatedTime() != null)
+ {
+ //Get the created time of each record
+ echo("Record Created Time: " . $data->getCreatedTime() . "\n");
+ }
+
+ //Check if the modified time is not null
+ if($data->getModifiedTime() != null)
+ {
+ //Get the modified time of each record
+ echo("Record Modified Time: " . $data->getModifiedTime() . "\n");
+ }
+
+ //Get the modifiedBy User instance of each record
+ $modifiedBy = $data->getModifiedBy();
+
+ //Check if modifiedByUser is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("Record Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("Record Modified By user-Name: " . $modifiedBy->getName() . "\n");
+ }
+
+ //Get all entries from the keyValues map
+ foreach($data->getKeyValues() as $key => $value)
+ {
+ //Get each value from the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the NextFieldValue of the Transition
+ echo("Transition NextFieldValue: " . $transition->getNextFieldValue() . "\n");
+
+ //Get the Name of each Transition
+ echo("Transition Name: " . $transition->getName() . "\n");
+
+ //Get the CriteriaMatched of the Transition
+ echo("Transition CriteriaMatched: " . $transition->getCriteriaMatched() . "\n");
+
+ //Get the ID of the Transition
+ echo("Transition ID: " . $transition->getId() . "\n");
+
+ $fields = $transition->getFields();
+
+ foreach($fields as $field)
+ {
+ //Get the webhook of each Field
+ echo("Webhook" . $field->getWebhook() . "\n");
+
+ //Get the JsonType of each Field
+ echo("JsonType: " . $field->getJsonType() . "\n");
+
+ //Get the DisplayLabel of each Field
+ echo("DisplayLabel: " . $field->getDisplayLabel() . "\n");
+
+ //Get the DataType of each Field
+ echo("DataType: " . $field->getDataType() . "\n");
+
+ //Get the ColumnName of each Field
+ echo("ColumnName: " . $field->getColumnName() . "\n");
+
+ //Get the PersonalityName of each Field
+ echo("PersonalityName: " . $field->getPersonalityName() . "\n");
+
+ //Get the ID of each Field
+ echo("ID: " . $field->getId() . "\n");
+
+ //Get the TransitionSequence of each Field
+ echo("TransitionSequence: " . $field->getTransitionSequence() . "\n");
+
+ if($field->getMandatory() != null)
+ {
+ //Get the Mandatory of each Field
+ echo("Mandatory: " . $field->getMandatory() . "\n");
+ }
+
+ $layout = $field->getLayouts();
+
+ if($layout != null)
+ {
+ //Get the ID of the Layout
+ echo("Layout ID: " . $layout->getId() . "\n");
+
+ //Get the name of the Layout
+ echo("Layout Name: " . $layout->getName() . "\n");
+ }
+
+ //Get the APIName of each Field
+ echo("APIName: " . $field->getAPIName() . "\n");
+
+ //Get the Content of each Field
+ echo("Content: " . $field->getContent() . "\n");
+
+ if($field->getSystemMandatory() != null)
+ {
+ //Get the SystemMandatory of each Field
+ echo("SystemMandatory: " . $field->getSystemMandatory() . "\n");
+ }
+
+ //Get the Crypt of each Field
+ echo("Crypt: " . $field->getCrypt() . "\n");
+
+ //Get the FieldLabel of each Field
+ echo("FieldLabel: " . $field->getFieldLabel() . "\n");
+
+ //Get the Tooltip of each Field
+ $toolTip = $field->getTooltip();
+
+ if($toolTip != null)
+ {
+ //Get the Tooltip Name
+ echo("Tooltip Name: " . $toolTip->getName() . "\n");
+
+ //Get the Tooltip Value
+ echo("Tooltip Value: " . $toolTip->getValue() . "\n");
+ }
+
+ //Get the CreatedSource of each Field
+ echo("CreatedSource: " . $field->getCreatedSource() . "\n");
+
+ if($field->getFieldReadOnly() != null)
+ {
+ //Get the FieldReadOnly of each Field
+ echo("FieldReadOnly: " . $field->getFieldReadOnly() . "\n");
+ }
+
+ if($field->getReadOnly() != null)
+ {
+ //Get the ReadOnly of each Field
+ echo("ReadOnly: " . $field->getReadOnly() . "\n");
+ }
+
+ //Get the AssociationDetails of each Field
+ echo("AssociationDetails: " . $field->getAssociationDetails() . "\n");
+
+ //Get the DisplayLabel of each Field
+ echo("DisplayLabel: " . $field->getDisplayLabel() . "\n");
+
+ //Get the DisplayLabel of each Field
+ echo("DisplayLabel: " . $field->getDisplayLabel() . "\n");
+
+ if($field->getQuickSequenceNumber() != null)
+ {
+ //Get the QuickSequenceNumber of each Field
+ echo("QuickSequenceNumber: " . $field->getQuickSequenceNumber() . "\n");
+ }
+
+ if($field->getCustomField() != null)
+ {
+ //Get the CustomField of each Field
+ echo("CustomField: " . $field->getCustomField() . "\n");
+ }
+
+ if($field->getVisible() != null)
+ {
+ //Get the Visible of each Field
+ echo("Visible: " . $field->getVisible() . "\n");
+ }
+
+ if($field->getLength() != null)
+ {
+ //Get the Length of each Field
+ echo("Length: " . $field->getLength() . "\n");
+ }
+
+ //Get the DecimalPlace of each Field
+ echo("DecimalPlace: " . $field->getDecimalPlace() . "\n");
+
+ $viewType = $field->getViewType();
+
+ if($viewType != null)
+ {
+ //Get the View of the ViewType
+ echo("View: " . $viewType->getView() . "\n");
+
+ //Get the Edit of the ViewType
+ echo("Edit: " . $viewType->getEdit() . "\n");
+
+ //Get the Create of the ViewType
+ echo("Create: " . $viewType->getCreate() . "\n");
+
+ //Get the View of the ViewType
+ echo("QuickCreate: " . $viewType->getQuickCreate() . "\n");
+ }
+
+ $pickListValues = $field->getPickListValues();
+
+ if($pickListValues != null)
+ {
+ foreach($pickListValues as $pickListValue)
+ {
+ //Get the DisplayValue of each PickListValues
+ echo("DisplayValue: " . $pickListValue->getDisplayValue() . "\n");
+
+ //Get the SequenceNumber of each PickListValues
+ echo("SequenceNumber: " . $pickListValue->getSequenceNumber() . "\n");
+
+ //Get the ExpectedDataType of each PickListValues
+ echo("ExpectedDataType: " . $pickListValue->getExpectedDataType() . "\n");
+
+ //Get the ActualValue of each PickListValues
+ echo("ActualValue: " . $pickListValue->getActualValue() . "\n");
+
+ foreach($pickListValue->getMaps() as $map)
+ {
+ //Get each value from the map
+ echo($map . "\n");
+ }
+ }
+ }
+
+ //Get all entries from the MultiSelectLookup instance
+ $multiSelectLookup = $field->getMultiselectlookup();
+
+ if($multiSelectLookup != null)
+ {
+ //Get the DisplayValue of the MultiSelectLookup
+ echo("DisplayLabel: " . $multiSelectLookup->getDisplayLabel() . "\n");
+
+ //Get the LinkingModule of the MultiSelectLookup
+ echo("LinkingModule: " . $multiSelectLookup->getLinkingModule() . "\n");
+
+ //Get the LookupApiname of the MultiSelectLookup
+ echo("LookupApiname: " . $multiSelectLookup->getLookupApiname() . "\n");
+
+ //Get the APIName of the MultiSelectLookup
+ echo("APIName: " . $multiSelectLookup->getAPIName() . "\n");
+
+ //Get the ConnectedlookupApiname of the MultiSelectLookup
+ echo("ConnectedlookupApiname: " . $multiSelectLookup->getConnectedlookupApiname() . "\n");
+
+ //Get the ID of the MultiSelectLookup
+ echo("ID: " . $multiSelectLookup->getId() . "\n");
+ }
+
+ //Get the AutoNumber of each Field
+ $autoNumber = $field->getAutoNumber();
+
+ if($autoNumber != null)
+ {
+ //Get the Prefix of the AutoNumber
+ echo("Prefix: " . $autoNumber->getPrefix() . "\n");
+
+ //Get the Suffix of the AutoNumber
+ echo("Suffix: " . $autoNumber->getSuffix() . "\n");
+
+ if($autoNumber->getStartNumber() != null)
+ {
+ //Get the StartNumber of the AutoNumber
+ echo("StartNumber: " . $autoNumber->getStartNumber() . "\n");
+ }
+ }
+ }
+
+ //Get the CriteriaMessage of each Transition
+ echo("Transition CriteriaMessage: " . $transition->getCriteriaMessage() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Blueprint
+ * This method is used to update a single record's Blueprint details with ID and print the response.
+ * @param moduleAPIName The API Name of the record's module
+ * @param recordId The ID of the record to get Blueprint
+ * @param transitionId The ID of the Blueprint transition Id
+ * @throws Exception
+ */
+ public static function updateBlueprint(string $moduleAPIName, string $recordId, string $transitionId)
+ {
+ //ID of the BluePrint to be updated
+ //$transitionId = "3477061000000173096";
+
+ //Get instance of BluePrintOperations Class that takes moduleAPIName and recordId as parameter
+ $bluePrintOperations = new BluePrintOperations($recordId,$moduleAPIName);
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of BluePrint instances
+ $bluePrintList = array();
+
+ $bluePrintClass = 'com\zoho\crm\api\blueprint\BluePrint';
+
+ //Get instance of BluePrint Class
+ $bluePrint = new $bluePrintClass();
+
+ //Set transition_id to the BluePrint instance
+ $bluePrint->setTransitionId($transitionId);
+
+ //Get instance of Record Class
+ $data = new Record();
+
+ $lookup = array();
+
+ $lookup["Phone"] = "8940372937";
+
+ $lookup["id"] = "8940372937";
+
+ // $data->addKeyValue("Lookup_2", (object)$lookup);
+
+ $data->addKeyValue("Phone", "8940372937");
+
+ $data->addKeyValue("Notes", "Updated via blueprint");
+
+ $attachments = array();
+
+ $fileIds = array();
+
+ array_push($fileIds, "blojtd2d13b5f044e4041a3315e0793fb21ef");
+
+ $attachments['$file_id'] = $fileIds;
+
+ $data->addKeyValue("Attachments", $attachments);
+
+ $checkLists = array();
+
+ $list = array();
+
+ $list["list 1"] = true;
+
+ array_push($checkLists, $list);
+
+ $list = array();
+
+ $list["list 2"] = true;
+
+ array_push($checkLists, $list);
+
+ $list = array();
+
+ $list["list 3"] = true;
+
+ array_push($checkLists, $list);
+
+ $data->addKeyValue("CheckLists", $checkLists);
+
+ //Set data to the BluePrint instance
+ $bluePrint->setData($data);
+
+ //Add BluePrint instance to the list
+ array_push($bluePrintList, $bluePrint);
+
+ //Set the list to bluePrint in BodyWrapper instance
+ $bodyWrapper->setBlueprint($bluePrintList);
+
+ // var_dump($bodyWrapper);
+
+ //Call updateBluePrint method that takes BodyWrapper instance
+ $response = $bluePrintOperations->updateBlueprint($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionResponse = $response->getObject();
+
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
diff --git a/samples/src/com/zoho/crm/api/bulkread/BulkRead.php b/samples/src/com/zoho/crm/api/bulkread/BulkRead.php
new file mode 100644
index 0000000..d08c834
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/bulkread/BulkRead.php
@@ -0,0 +1,479 @@
+ Create BulkRead Job
+ * This method is used to create a Bulkread job to export records.
+ * @param moduleAPIName The API Name of the record's module
+ * @throws Exception
+ */
+ public static function createBulkReadJob(string $moduleAPIName)
+ {
+ //Get instance of BulkReadOperations Class
+ $bulkReadOperations = new BulkReadOperations();
+
+ //Get instance of RequestWrapper Class that will contain the request body
+ $requestWrapper = new RequestWrapper();
+
+ //Get instance of CallBack Class
+ $callback = new CallBack();
+
+ // To set valid callback URL.
+ $callback->setUrl("https://www.example.com/callback");
+
+ //To set the HTTP method of the callback URL. The allowed value is post.
+ $callback->setMethod(new Choice("post"));
+
+ //The Bulkread Job's details is posted to this URL on successful completion / failure of job.
+ $requestWrapper->setCallback($callback);
+
+ //Get instance of Query Class
+ $query = new Query();
+
+ //Specifies the API Name of the module to be read.
+ $query->setModule($moduleAPIName);
+
+ //Specifies the unique ID of the custom view whose records you want to export.
+ $query->setCvid("3477061000000087501");
+
+ // List of Field API Names
+ $fieldAPINames = array();
+
+ array_push($fieldAPINames, "Last_Name");
+
+ //Specifies the API Name of the fields to be fetched.
+ $query->setFields($fieldAPINames);
+
+ //To set page value, By default value is 1.
+ $query->setPage(1);
+
+ //Get instance of Criteria Class
+ $criteria = new Criteria();
+
+ // To set API name of a field.
+ $criteria->setAPIName("Created_Time");
+
+ // To set comparator(eg: equal, greater_than.).
+ $criteria->setComparator(new Choice("between"));
+
+ $createdTime = array("2020-06-03T17:31:48+05:30", "2020-06-03T17:31:48+05:30");
+
+ // To set the value to be compare.
+ $criteria->setValue($createdTime);
+
+ //To filter the records to be exported.
+ $query->setCriteria($criteria);
+
+ //To set query JSON object.
+ $requestWrapper->setQuery($query);
+
+ //Specify the value for this key as "ics" to export all records in the Events module as an ICS file.
+ // $requestWrapper->setFileType(new Choice("ics"));
+
+ //Call createBulkReadJob method that takes RequestWrapper instance as parameter
+ $response = $bulkReadOperations->createBulkReadJob($requestWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code : " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue(). "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue(). "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " );
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue(). "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue(). "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue(). "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue(). "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue(). "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue(). "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue(). "\n");
+ }
+ }
+ }
+
+ /**
+ * Get BulkRead Job Details
+ * This method is used to get the details of a Bulkread job performed previously.
+ * @param jobId The unique ID of the Bulkread job.
+ * @throws Exception
+ */
+ public static function getBulkReadJobDetails(string $jobId)
+ {
+ //example
+ //String jobId = "3477061000005177002";
+
+ //Get instance of BulkReadOperations Class
+ $bulkReadOperations = new BulkReadOperations();
+
+ //Call getBulkReadJobDetails method that takes jobId as parameter
+ $response = $bulkReadOperations->getBulkReadJobDetails($jobId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained jobDetail instances
+ $jobDetails = $responseWrapper->getData();
+
+ foreach($jobDetails as $jobDetail)
+ {
+ //Get the Job ID of each jobDetail
+ echo("Bulkread Job ID: " . $jobDetail->getId(). "\n");
+
+ //Get the Operation of each jobDetail
+ echo("Bulkread Operation: " . $jobDetail->getOperation(). "\n");
+
+ //Get the Operation of each jobDetail
+ echo("Bulkread State: " . $jobDetail->getState()->getValue(). "\n");
+
+ //Get the Result instance of each jobDetail
+ $result = $jobDetail->getResult();
+
+ //Check if Result is not null
+ if($result != null)
+ {
+ //Get the Page of the Result
+ echo("Bulkread Result Page: " . $result->getPage(). "\n");
+
+ //Get the Count of the Result
+ echo("Bulkread Result Count: " . $result->getCount(). "\n");
+
+ //Get the Download URL of the Result
+ echo("Bulkread Result Download URL: " . $result->getDownloadUrl(). "\n");
+
+ //Get the Per_Page of the Result
+ echo("Bulkread Result Per_Page: " . $result->getPerPage(). "\n");
+
+ //Get the MoreRecords of the Result
+ echo("Bulkread Result MoreRecords: " . $result->getMoreRecords(). "\n");
+ }
+
+ // Get the Query instance of each jobDetail
+ $query = $jobDetail->getQuery();
+
+ if($query != null)
+ {
+ //Get the Module Name of the Query
+ echo("Bulkread Query Module: " . $query->getModule(). "\n");
+
+ //Get the Page of the Query
+ echo("Bulkread Query Page: " . $query->getPage(). "\n");
+
+ //Get the cvid of the Query
+ echo("Bulkread Query cvid: " . $query->getCvid(). "\n");
+
+ //Get the fields List of each Query
+ $fields = $query->getFields();
+
+ //Check if fields is not null
+ if($fields != null)
+ {
+ foreach($fields as $fieldName)
+ {
+ //Get the Field Name of the Query
+ echo("Bulkread Query Fields: " . $fieldName. "\n");
+ }
+ }
+
+ // Get the Criteria instance of each Query
+ $criteria = $query->getCriteria();
+
+ //Check if criteria is not null
+ if($criteria != null)
+ {
+ BulkRead::printCriteria($criteria);
+ }
+ }
+
+ //Get the CreatedBy User instance of each jobDetail
+ $createdBy = $jobDetail->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the CreatedBy User
+ echo("Bulkread Created By User-ID: " . $createdBy->getId(). "\n");
+
+ //Get the Name of the CreatedBy User
+ echo("Bulkread Created By user-Name: " . $createdBy->getName(). "\n");
+ }
+
+ //Get the CreatedTime of each jobDetail
+ echo("Bulkread CreatedTime: " );
+
+ print_r($jobDetail->getCreatedTime());
+
+ echo("\n");
+
+ //Get the ID of each jobDetail
+ echo("Bulkread File Type: " . $jobDetail->getFileType(). "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue(). "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue(). "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue(). "\n");
+ }
+ }
+ }
+
+ private static function printCriteria(Criteria $criteria)
+ {
+ //Get the APIName of the Criteria
+ echo("Bulkread Query Criteria APIName: " . $criteria->getAPIName(). "\n");
+
+ if($criteria->getComparator()!= null)
+ {
+ //Get the Comparator of the Criteria
+ echo("Bulkread Query Criteria Comparator: " . $criteria->getComparator()->getValue(). "\n");
+ }
+
+ if($criteria->getValue() != null)
+ {
+ //Get the Value of the Query
+ echo("Bulkread Query Criteria Value: ");
+
+ print_r($criteria->getValue());
+
+ echo("\n");
+ }
+
+ //Get the List of Criteria instance of each Criteria
+ $criteriaGroup = $criteria->getGroup();
+
+ if($criteriaGroup != null)
+ {
+ foreach($criteriaGroup as $criteria1)
+ {
+ BulkRead::printCriteria($criteria1);
+ }
+ }
+
+ if($criteria->getGroupOperator() != null)
+ {
+ //Get the Group Operator of the Criteria
+ echo("Bulkread Query Criteria Group Operator: " . $criteria->getGroupOperator()->getValue(). "\n");
+ }
+ }
+
+ /**
+ * Download Result
+ * This method is used to download the Bulkread job as a CSV or an ICS file (only for the Events module).
+ * @param jobId The unique ID of the Bulkread job.
+ * @param destinationFolder The absolute path where downloaded file has to be stored.
+ * @throws Exception
+ */
+ public static function downloadResult(string $jobId, string $destinationFolder)
+ {
+ //example
+ //String jobId = "3477061000005177002";
+
+ //Get instance of BulkReadOperations Class
+ $bulkReadOperations = new BulkReadOperations();
+
+ //Call downloadResult method that takes jobId as parameters
+ $response = $bulkReadOperations->downloadResult($jobId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof FileBodyWrapper)
+ {
+ //Get the received FileBodyWrapper instance
+ $fileBodyWrapper = $responseHandler;
+
+ //Get StreamWrapper instance from the returned FileBodyWrapper instance
+ $streamWrapper = $fileBodyWrapper->getFile();
+
+ //Create a file instance with the absolute_file_path
+ $fp = fopen($destinationFolder."/".$streamWrapper->getName(), "w");
+
+ //Get stream from the response
+ $stream = $streamWrapper->getStream();
+
+ fputs($fp, $stream);
+
+ fclose($fp);
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
diff --git a/samples/src/com/zoho/crm/api/bulkwrite/BulkWrite.php b/samples/src/com/zoho/crm/api/bulkwrite/BulkWrite.php
new file mode 100644
index 0000000..e8562f0
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/bulkwrite/BulkWrite.php
@@ -0,0 +1,616 @@
+ Upload File
+ * This method is used to upload a CSV file in ZIP format for bulk write API. The response contains the file_id.
+ * Use this ID while making the bulk write request.
+ * @param orgID The unique ID (zgid) of your organization obtained through the Organization API.
+ * @param absoluteFilePath To give the zip file path you want to upload.
+ * @throws Exception
+ */
+ public static function uploadFile(string $orgID, string $absoluteFilePath)
+ {
+ //Get instance of BulkWriteOperations Class
+ $bulkWriteOperations = new BulkWriteOperations();
+
+ //Get instance of FileBodyWrapper class that will contain the request file
+ $fileBodyWrapper = new FileBodyWrapper();
+
+ //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
+ $streamWrapper = new StreamWrapper(null, null, $absoluteFilePath);
+
+ // $file = fopen($absoluteFilePath, "rb");
+
+ // $stream = fread($file, filesize($absoluteFilePath));
+
+ // fclose($file);
+
+ //Get instance of StreamWrapper class that takes file name and stream of the file to be attached as parameter
+ // $streamWrapper = new StreamWrapper(basename($absoluteFilePath), $stream);
+
+ //Set file to the FileBodyWrapper instance
+ $fileBodyWrapper->setFile($streamWrapper);
+
+ //Get instance of HeaderMap Class
+ $headerInstance = new HeaderMap();
+
+ //To indicate that this a bulk write operation
+ $headerInstance->add(UploadFileHeader::feature(), "bulk-write");
+
+ $headerInstance->add(UploadFileHeader::XCRMORG(), $orgID);
+
+ //Call uploadFile method that takes FileBodyWrapper instance and headerInstance as parameter
+ $response = $bulkWriteOperations->uploadFile($fileBodyWrapper, $headerInstance);
+
+ if($response != null)
+ {
+
+ //Get the status code from response
+ echo("Status code : " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionResponse = $response->getObject();
+
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo( $key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Create BulkWrite Job
+ * This method is used to create a bulk write job.
+ * @param moduleAPIName The API Name of the record's module.
+ * @param fileId The ID of the uploaded file to create BulkWrite Job.
+ */
+ public static function createBulkWriteJob(string $moduleAPIName, string $fileId)
+ {
+ //Get instance of BulkWriteOperations Class
+ $bulkWriteOperations = new BulkWriteOperations();
+
+ //Get instance of RequestWrapper Class that will contain the request body
+ $requestWrapper = new RequestWrapper();
+
+ //Get instance of CallBack Class
+ $callback = new CallBack();
+
+ // To set valid callback URL.
+ $callback->setUrl("https://www.example.com/callback");
+
+ //To set the HTTP method of the callback URL. The allowed value is post.
+ $callback->setMethod(new Choice("post"));
+
+ //The Bulk Write Job's details are posted to this URL on successful completion of job or on failure of job.
+ $requestWrapper->setCallback($callback);
+
+ //To set the charset of the uploaded file
+ $requestWrapper->setCharacterEncoding("UTF-8");
+
+ //To set the type of operation you want to perform on the bulk write job.
+ $requestWrapper->setOperation(new Choice("insert"));
+
+ $resource = array();
+
+ //Get instance of Resource Class
+ $resourceIns = new Resource();
+
+ // To set the type of module that you want to import. The value is data.
+ $resourceIns->setType(new Choice("data"));
+
+ //To set API name of the module that you select for bulk write job.
+ $resourceIns->setModule($moduleAPIName);
+
+ //To set the file_id obtained from file upload API.
+ $resourceIns->setFileId($fileId);
+
+ //True - Ignores the empty values.The default value is false.
+ $resourceIns->setIgnoreEmpty(true);
+
+ // To set a field as a unique field or ID of a record.
+ //resourceIns.setFindBy("");
+
+ $fieldMappings = array();
+
+ //Get instance of FieldMapping Class
+ $fieldMapping = new FieldMapping();
+
+ //To set API name of the field present in Zoho module object that you want to import.
+ $fieldMapping->setAPIName("Last_Name");
+
+ //To set the column index of the field you want to map to the CRM field.
+ $fieldMapping->setIndex(0);
+
+ array_push($fieldMappings, $fieldMapping);
+
+ $fieldMapping = new FieldMapping();
+
+ $fieldMapping->setAPIName("Email");
+
+ $fieldMapping->setIndex(1);
+
+ array_push($fieldMappings, $fieldMapping);
+
+ $fieldMapping = new FieldMapping();
+
+ $fieldMapping->setAPIName("Company");
+
+ $fieldMapping->setIndex(2);
+
+ array_push($fieldMappings, $fieldMapping);
+
+ $fieldMapping = new FieldMapping();
+
+ $fieldMapping->setAPIName("Phone");
+
+ $fieldMapping->setIndex(3);
+
+ array_push($fieldMappings, $fieldMapping);
+
+ $fieldMapping = new FieldMapping();
+
+ $fieldMapping->setAPIName("Website");
+
+ //$fieldMapping->setFormat("");
+
+ //$fieldMapping->setFindBy("");
+
+ $defaultValue = array();
+
+ $defaultValue["value"] = "https://www.zohoapis.com";
+
+ //To set the default value for an empty column in the uploaded file.
+ $fieldMapping->setDefaultValue($defaultValue);
+
+ array_push($fieldMappings, $fieldMapping);
+
+ $resourceIns->setFieldMappings($fieldMappings);
+
+ array_push($resource, $resourceIns);
+
+ $requestWrapper->setResource($resource);
+
+ //Call createBulkWriteJob method that takes RequestWrapper instance as parameter
+ $response = $bulkWriteOperations->createBulkWriteJob($requestWrapper);
+
+ if($response != null)
+ {
+
+ //Get the status code from response
+ echo("Status code : " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionResponse = $response->getObject();
+
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo( $key . ": ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get BulkWriteJob Details
+ * This method is used to get the details of a bulk write job performed previously.
+ * @param jobId The unique ID of the bulk write job.
+ * @throws Exception
+ */
+ public static function getBulkWriteJobDetails(string $jobId)
+ {
+ //example
+ //String jobId = "3477061000005615003";
+
+ //Get instance of BulkWriteOperations Class
+ $bulkWriteOperations = new BulkWriteOperations();
+
+ //Call getBulkWriteJobDetails method that takes jobId as parameter
+ $response = $bulkWriteOperations->getBulkWriteJobDetails($jobId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseWrapper = $response->getObject();
+
+ if($responseWrapper instanceof BulkWriteResponse)
+ {
+ //Get the received BulkWriteResponse instance
+ $bulkWriteResponse = $responseWrapper;
+
+ //Get the Job Status of each bulkWriteResponse
+ echo("Bulkwrite Job Status: " . $bulkWriteResponse->getStatus() . "\n");
+
+ //Get the CharacterEncoding of each bulkWriteResponse
+ echo("Bulkwrite CharacterEncoding: " . $bulkWriteResponse->getCharacterEncoding() . "\n");
+
+ $resources = $bulkWriteResponse->getResource();
+
+ if($resources != null)
+ {
+ foreach($resources as $resource)
+ {
+ //Get the Status of each Resource
+ echo("Bulkwrite Resource Status: " . $resource->getStatus()->getValue() . "\n");
+
+ //Get the Type of each Resource
+ echo("Bulkwrite Resource Type: " . $resource->getType()->getValue() . "\n");
+
+ //Get the Module of each Resource
+ echo("Bulkwrite Resource Module: " . $resource->getModule() . "\n");
+
+ $fieldMappings = $resource->getFieldMappings();
+
+ if($fieldMappings != null)
+ {
+ foreach($fieldMappings as $fieldMapping)
+ {
+ //Get the APIName of each FieldMapping
+ echo("Bulkwrite Resource FieldMapping Module: " . $fieldMapping->getAPIName() . "\n");
+
+ if($fieldMapping->getIndex() != null)
+ {
+ //Get the Index of each FieldMapping
+ echo("Bulkwrite Resource FieldMapping Index: " . $fieldMapping->getIndex() . "\n");
+ }
+
+ if($fieldMapping->getFormat() != null)
+ {
+ //Get the Format of each FieldMapping
+ echo("Bulkwrite Resource FieldMapping Format: " . $fieldMapping->getFormat() . "\n");
+ }
+
+ if($fieldMapping->getFindBy() != null)
+ {
+ //Get the FindBy of each FieldMapping
+ echo("Bulkwrite Resource FieldMapping FindBy: " . $fieldMapping->getFindBy() . "\n");
+ }
+
+ if($fieldMapping->getDefaultValue() != null)
+ {
+ //Get all entries from the keyValues map
+ foreach($fieldMapping->getDefaultValue() as $key => $value)
+ {
+ //Get each value from the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+ }
+ }
+
+ $file = $resource->getFile();
+
+ if($file != null)
+ {
+ //Get the Status of each File
+ echo("Bulkwrite Resource File Status: " . $file->getStatus()->getValue() . "\n");
+
+ //Get the Name of each File
+ echo("Bulkwrite Resource File Name: " . $file->getName() . "\n");
+
+ //Get the AddedCount of each File
+ echo("Bulkwrite Resource File AddedCount: " . $file->getAddedCount() . "\n");
+
+ //Get the SkippedCount of each File
+ echo("Bulkwrite Resource File SkippedCount: " . $file->getSkippedCount() . "\n");
+
+ //Get the UpdatedCount of each File
+ echo("Bulkwrite Resource File UpdatedCount: " . $file->getUpdatedCount() . "\n");
+
+ //Get the TotalCount of each File
+ echo("Bulkwrite Resource File TotalCount: " . $file->getTotalCount() . "\n");
+ }
+ }
+ }
+
+ //Get the ID of each BulkWriteResponse
+ echo("Bulkwrite ID: " . $bulkWriteResponse->getId() . "\n");
+
+ $result = $bulkWriteResponse->getResult();
+
+ if($result != null)
+ {
+ //Get the DownloadUrl of the Result
+ echo("Bulkwrite DownloadUrl: " . $result->getDownloadUrl() . "\n");
+ }
+
+ //Get the CreatedBy User instance of each BulkWriteResponse
+ $createdBy = $bulkWriteResponse->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the CreatedBy User
+ echo("Bulkread Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Name of the CreatedBy User
+ echo("Bulkread Created By user-Name: " . $createdBy->getName() . "\n");
+ }
+
+ //Get the Operation of each BulkWriteResponse
+ echo("Bulkwrite Operation: " . $bulkWriteResponse->getOperation() . "\n");
+
+ //Get the CreatedTime of each BulkWriteResponse
+ echo("Bulkwrite File CreatedTime: ");
+
+ print_r($bulkWriteResponse->getCreatedTime());
+
+ echo("\n");
+ }
+ //Check if the request returned an exception
+ else if($responseWrapper instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseWrapper;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value);
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Download BulkWrite Result
+ * This method is used to download the result of the bulk write job as a CSV file.
+ * @param downloadUrl The URL present in the download_url parameter in the response of Get Bulk Write Job Details.
+ * @param destinationFolder The absolute path where downloaded file has to be stored.
+ * @throws Exception
+ */
+ public static function downloadBulkWriteResult(string $downloadUrl, string $destinationFolder)
+ {
+ //example
+ //String downloadUrl = "https://download-accl.zoho.com/v2/crm/6735/bulk-write/347706122009/347706122009.zip";
+
+ //Get instance of BulkWriteOperations Class
+ $bulkWriteOperations = new BulkWriteOperations();
+
+ //Call downloadBulkWriteResult method that takes downloadUrl as parameters
+ $response = $bulkWriteOperations->downloadBulkWriteResult($downloadUrl);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof FileBodyWrapper)
+ {
+ //Get the received FileBodyWrapper instance
+ $fileBodyWrapper = $responseHandler;
+
+ //Get StreamWrapper instance from the returned FileBodyWrapper instance
+ $streamWrapper = $fileBodyWrapper->getFile();
+
+ //Create a file instance with the absolute_file_path
+ $fp = fopen($destinationFolder."/".$streamWrapper->getName(), "w");
+
+ //Get stream from the response
+ $stream = $streamWrapper->getStream();
+
+ fputs($fp, $stream);
+
+ fclose($fp);
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ if($exception->getStatus() != null)
+ {
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue());
+ }
+
+ if($exception->getCode() != null)
+ {
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue());
+ }
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value);
+ }
+ }
+
+ if($exception->getMessage() != null)
+ {
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue());
+ }
+
+ if($exception->getXError() != null)
+ {
+ //Get the Message
+ echo("XError: " . $exception->getXError()->getValue());
+ }
+
+ if($exception->getXInfo() != null)
+ {
+ //Get the Message
+ echo("XInfo: " . $exception->getXInfo()->getValue());
+ }
+
+ if($exception->getHttpStatus() != null)
+ {
+ //Get the Message
+ echo("Message: " . $exception->getHttpStatus());
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/contactroles/ContactRoles.php b/samples/src/com/zoho/crm/api/contactroles/ContactRoles.php
new file mode 100644
index 0000000..4c2a243
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/contactroles/ContactRoles.php
@@ -0,0 +1,852 @@
+ Get Contact Roles
+ * This method is used to get all the Contact Roles and print the response.
+ * @throws Exception
+ */
+ public static function getContactRoles()
+ {
+ //Get instance of ContactRolesOperations Class
+ $contactRolesOperations = new ContactRolesOperations();
+
+ //Call getContactRoles method
+ $response = $contactRolesOperations->getContactRoles();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained ContactRole instances
+ $contactRoles = $responseWrapper->getContactRoles();
+
+ foreach($contactRoles as $contactRole)
+ {
+ //Get the ID of each ContactRole
+ echo("ContactRole ID: " . $contactRole->getId() . "\n");
+
+ //Get the name of each ContactRole
+ echo("ContactRole Name: " . $contactRole->getName() . "\n");
+
+ //Get the sequence number each ContactRole
+ echo("ContactRole SequenceNumber: " . $contactRole->getSequenceNumber() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue());
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue());
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value);
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue());
+ }
+ }
+ }
+
+ /**
+ * Create Contact Roles
+ * This method is used to create Contact Roles and print the response.
+ * @throws Exception
+ */
+ public static function createContactRoles()
+ {
+ //Get instance of ContactRolesOperations Class
+ $contactRolesOperations = new ContactRolesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of ContactRole instances
+ $contactRoles = array();
+
+ for($i = 1; $i <= 5; $i++)
+ {
+ //Get instance of ContactRole Class
+ $contactRole = new ContactRole();
+
+ //Set name of the Contact Role
+ $contactRole->setName("contactRole" . strval($i));
+
+ //Set sequence number of the Contact Role
+ $contactRole->setSequenceNumber($i);
+
+ //Add ContactRole instance to the list
+ array_push($contactRoles, $contactRole);
+ }
+
+ //Set the list to contactRoles in BodyWrapper instance
+ $bodyWrapper->setContactRoles($contactRoles);
+
+ //Call createContactRoles method that takes BodyWrapper instance as parameter
+ $response = $contactRolesOperations->createContactRoles($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getContactRoles();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Contact Roles
+ * This method is used to update Contact Roles and print the response.
+ * @throws Exception
+ */
+ public static function updateContactRoles()
+ {
+ //Get instance of ContactRolesOperations Class
+ $contactRolesOperations = new ContactRolesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of ContactRole instances
+ $contactRolesList = array();
+
+ //Get instance of ContactRole Class
+ $cr1 = new ContactRole();
+
+ //Set ID to the ContactRole instance
+ $cr1->setId("3477061000007231007");
+
+ //Set name to the ContactRole instance
+ $cr1->setName("Edited1");
+
+ //Add ContactRole instance to the list
+ array_push($contactRolesList, $cr1);
+
+ //Get instance of ContactRole Class
+ $cr2 = new ContactRole();
+
+ //Set ID to the ContactRole instance
+ $cr2->setId("3477061000007230011");
+
+ //Set name to the ContactRole instance
+ $cr2->setName("Edited2");
+
+ //Add ContactRole instance to the list
+ array_push($contactRolesList, $cr2);
+
+ //Set the list to contactRoles in BodyWrapper instance
+ $bodyWrapper->setContactRoles($contactRolesList);
+
+ //Call updateContactRoles method that takes BodyWrapper instance as parameter
+ $response = $contactRolesOperations->updateContactRoles($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getContactRoles();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Contact Roles
+ * This method is used to delete Contact Roles and print the response.
+ * @param contactRoleIds - The ID of the ContactRole to be obtainted
+ * @throws Exception
+ */
+ public static function deleteContactRoles(array $contactRoleIds)
+ {
+ //Get instance of ContactRolesOperations Class
+ $contactRolesOperations = new ContactRolesOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($contactRoleIds as $id)
+ {
+ $paramInstance->add(DeleteContactRolesParam::ids(), $id);
+ }
+
+ //Call deleteContactRoles method that takes paramInstance as parameter
+ $response = $contactRolesOperations->deleteContactRoles($paramInstance);
+
+ if($response != null)
+ {
+
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getContactRoles();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Contact Role
+ * This method is used to get single Contact Role with ID and print the response.
+ * @param contactRoleId - The ID of the ContactRole to be obtainted
+ * @throws Exception
+ */
+ public static function getContactRole(string $contactRoleId)
+ {
+ //Get instance of ContactRolesOperations Class
+ $contactRolesOperations = new ContactRolesOperations();
+
+ //Call getContactRole method that takes contactRoleId as parameter
+ $response = $contactRolesOperations->getContactRole($contactRoleId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained ContactRole instances
+ $contactRoles = $responseWrapper->getContactRoles();
+
+ foreach($contactRoles as $contactRole)
+ {
+ //Get the ID of each ContactRole
+ echo("ContactRole ID: " . $contactRole->getId() . "\n");
+
+ //Get the name of each ContactRole
+ echo("ContactRole Name: " . $contactRole->getName() . "\n");
+
+ //Get the sequence number each ContactRole
+ echo("ContactRole SequenceNumber: " . $contactRole->getSequenceNumber() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue());
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue());
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value);
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue());
+ }
+ }
+ }
+
+ /**
+ * Update Contact Role
+ * This method is used to update single Contact Role with ID and print the response.
+ * @param contactRoleId The ID of the ContactRole to be obtainted
+ * @throws Exception
+ */
+ public static function updateContactRole(string $contactRoleId)
+ {
+ //ID of the ContactRole to be updated
+ //$contactRoleId = 525508000005067923L;
+
+ //Get instance of ContactRolesOperations Class
+ $contactRolesOperations = new ContactRolesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of ContactRole instances
+ $contactRolesList = array();
+
+ //Get instance of ContactRole Class
+ $cr1 = new ContactRole();
+
+ //Set name to the ContactRole instance
+ $cr1->setName("contactRole4");
+
+ //Set sequence number to the ContactRole instance
+ $cr1->setSequenceNumber(2);
+
+ //Add ContactRole instance to the list
+ array_push($contactRolesList, $cr1);
+
+ //Set the list to contactRoles in BodyWrapper instance
+ $bodyWrapper->setContactRoles($contactRolesList);
+
+ //Call updateContactRole method that takes BodyWrapper instance and contactRoleId as parameters
+ $response = $contactRolesOperations->updateContactRole($contactRoleId,$bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getContactRoles();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Contact Role
+ * This method is used to delete single Contact Role with ID and print the response.
+ * @param contactRoleId ID of the ContactRole to be deleted
+ * @throws Exception
+ */
+ public static function deleteContactRole(string $contactRoleId)
+ {
+ //Get instance of ContactRolesOperations Class
+ $contactRolesOperations = new ContactRolesOperations();
+
+ //Call deleteContactRole which takes contactRoleId as parameter
+ $response = $contactRolesOperations->deleteContactRole($contactRoleId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getContactRoles();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/currencies/Currency.php b/samples/src/com/zoho/crm/api/currencies/Currency.php
new file mode 100644
index 0000000..a57405a
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/currencies/Currency.php
@@ -0,0 +1,1118 @@
+ Get Currencies
+ * This method is used to get all the available currencies in your organization.
+ * @throws Exception
+ */
+ public static function getCurrencies()
+ {
+ //Get instance of CurrenciesOperations Class
+ $currenciesOperations = new CurrenciesOperations();
+
+ //Call getCurrencies method
+ $response = $currenciesOperations->getCurrencies();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Currency instance
+ $currenciesList = $responseWrapper->getCurrencies();
+
+ foreach($currenciesList as $currency)
+ {
+ //Get the Symbol of each currency
+ echo("Currency Symbol: " . $currency->getSymbol() . "\n");
+
+ //Get the CreatedTime of each currency
+ echo("Currency CreatedTime: ");
+
+ print_r($currency->getCreatedTime());
+
+ echo("\n");
+
+ //Get the currency is IsActive
+ echo("Currency IsActive: " . $currency->getIsActive() . "\n");
+
+ //Get the ExchangeRate of each currency
+ echo("Currency ExchangeRate: " . $currency->getExchangeRate() . "\n");
+
+ //Get the format Format instance of each currency
+ $format = $currency->getFormat();
+
+ //Check if format is not null
+ if($format != null)
+ {
+ //Get the DecimalSeparator of the Format
+ echo("Currency Format DecimalSeparator: " . $format->getDecimalSeparator()->getValue() . "\n");
+
+ //Get the ThousandSeparator of the Format
+ echo("Currency Format ThousandSeparator: " . $format->getThousandSeparator()->getValue() . "\n");
+
+ //Get the DecimalPlaces of the Format
+ echo("Currency Format DecimalPlaces: " . $format->getDecimalPlaces()->getValue() . "\n");
+ }
+
+ //Get the createdBy User instance of each currency
+ $createdBy = $currency->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("Currency CreatedBy User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Currency CreatedBy User-ID: " . $createdBy->getId() . "\n");
+ }
+
+ //Get the PrefixSymbol of each currency
+ echo("Currency PrefixSymbol: " . $currency->getPrefixSymbol() . "\n");
+
+ //Get the IsBase of each currency
+ echo("Currency IsBase: " . $currency->getIsBase() . "\n");
+
+ //Get the ModifiedTime of each currency
+ echo("Currency ModifiedTime: ");
+
+ print_r($currency->getModifiedTime());
+
+ echo("\n");
+
+ //Get the Name of each currency
+ echo("Currency Name: " . $currency->getName() . "\n");
+
+ //Get the modifiedBy User instance of each currency
+ $modifiedBy = $currency->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Currency ModifiedBy User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Currency ModifiedBy User-ID: " . $modifiedBy->getId() . "\n");
+ }
+
+ //Get the Id of each currency
+ echo("Currency Id: " . $currency->getId() . "\n");
+
+ //Get the IsoCode of each currency
+ echo("Currency IsoCode: " . $currency->getIsoCode() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Add Currencies
+ * This method is used to add new currencies to your organization.
+ * @throws Exception
+ */
+ public static function addCurrencies()
+ {
+ //Get instance of CurrenciesOperations Class
+ $currenciesOperations = new CurrenciesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Currency instances
+ $currencies = array();
+
+ $currencyClass = "com\zoho\crm\api\currencies\Currency";
+
+ //Get instance of Currency Class
+ $currency = new $currencyClass();
+
+ //To set the position of the ISO code in the currency.
+ //true: Display ISO code before the currency value.
+ //false: Display ISO code after the currency value.
+ $currency->setPrefixSymbol(true);
+
+ //To set the name of the currency.
+ $currency->setName("USD");
+
+ //To set the ISO code of the currency.
+ $currency->setIsoCode("USD");
+
+ //To set the symbol of the currency.
+ $currency->setSymbol("$");
+
+ //To set the rate at which the currency has to be exchanged for home currency.
+ $currency->setExchangeRate("20.000000000");
+
+ //To set the status of the currency.
+ //true: The currency is active.
+ //false: The currency is inactive.
+ $currency->setIsActive(true);
+
+ $format = new Format();
+
+ //It can be a Period or Comma, depending on the currency.
+ $format->setDecimalSeparator(new Choice("Period"));
+
+ //It can be a Period, Comma, or Space, depending on the currency.
+ $format->setThousandSeparator(new Choice("Comma"));
+
+ //To set the number of decimal places allowed for the currency. It can be 0, 2, or 3.
+ $format->setDecimalPlaces(new Choice("2"));
+
+ //To set the format of the base currency
+ $currency->setFormat($format);
+
+ array_push($currencies, $currency);
+
+ //Set the list to Currency in BodyWrapper instance
+ $bodyWrapper->setCurrencies($currencies);
+
+ //Call addCurrencies method that takes BodyWrapper instance as parameter
+ $response = $currenciesOperations->addCurrencies($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getCurrencies();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Currencies
+ * This method is used to update currency details.
+ * @throws Exception
+ */
+ public static function updateCurrencies()
+ {
+ //Get instance of CurrenciesOperations Class
+ $currenciesOperations = new CurrenciesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Currency instances
+ $currencies = array();
+
+ $currencyClass = "com\zoho\crm\api\currencies\Currency";
+
+ //Get instance of Currency Class
+ $currency = new $currencyClass();
+
+ //To set the position of the ISO code in the currency.
+ //true: Display ISO code before the currency value.
+ //false: Display ISO code after the currency value.
+ $currency->setPrefixSymbol(true);
+
+ //To set currency Id
+ $currency->setId("3477061000006040001");
+
+ //To set the rate at which the currency has to be exchanged for home currency.
+ $currency->setExchangeRate("5.0000000");
+
+ //To set the status of the currency.
+ //true: The currency is active.
+ //false: The currency is inactive.
+ $currency->setIsActive(true);
+
+ $format = new Format();
+
+ //It can be a Period or Comma, depending on the currency.
+ $format->setDecimalSeparator(new Choice("Period"));
+
+ //It can be a Period, Comma, or Space, depending on the currency.
+ $format->setThousandSeparator(new Choice("Comma"));
+
+ //To set the number of decimal places allowed for the currency. It can be 0, 2, or 3.
+ $format->setDecimalPlaces(new Choice("2"));
+
+ //To set the format of the currency
+ $currency->setFormat($format);
+
+ array_push($currencies, $currency);
+
+ //Set the list to Currency in BodyWrapper instance
+ $bodyWrapper->setCurrencies($currencies);
+
+ //Call updateCurrencies method that takes BodyWrapper instance as parameter
+ $response = $currenciesOperations->updateCurrencies($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getCurrencies();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Enable Multiple Currencies
+ * This method is used to enable multiple currencies for your organization.
+ * @throws Exception
+ */
+ public static function enableMultipleCurrencies()
+ {
+ //Get instance of CurrenciesOperations Class
+ $currenciesOperations = new CurrenciesOperations();
+
+ //Get instance of BaseCurrencyWrapper Class that will contain the request body
+ $bodyWrapper = new BaseCurrencyWrapper();
+
+ $currencyClass = "com\zoho\crm\api\currencies\Currency";
+
+ //Get instance of Currency Class
+ $currency = new $currencyClass();
+
+ //To set the position of the ISO code in the base currency.
+ //true: Display ISO code before the currency value.
+ //false: Display ISO code after the currency value.
+ $currency->setPrefixSymbol(true);
+
+ //To set the name of the base currency.
+ $currency->setName("Angolan Kwanza - AOA");
+
+ //To set the ISO code of the base currency.
+ $currency->setIsoCode("AOA");
+
+ //To set the symbol of the base currency.
+ $currency->setSymbol("Kz");
+
+ //To set the rate at which the currency has to be exchanged for home base currency.
+ $currency->setExchangeRate("1.0000000");
+
+ //To set the status of the base currency.
+ //true: The currency is active.
+ //false: The currency is inactive.
+ $currency->setIsActive(true);
+
+ $format = new Format();
+
+ //It can be a Period or Comma, depending on the base currency.
+ $format->setDecimalSeparator(new Choice("Period"));
+
+ //It can be a Period, Comma, or Space, depending on the base currency.
+ $format->setThousandSeparator(new Choice("Comma"));
+
+ //To set the number of decimal places allowed for the base currency. It can be 0, 2, or 3.
+ $format->setDecimalPlaces(new Choice("2"));
+
+ //To set the format of the base currency
+ $currency->setFormat($format);
+
+ //Set the Currency in BodyWrapper instance
+ $bodyWrapper->setBaseCurrency($currency);
+
+ //Call enableMultipleCurrencies method that takes BodyWrapper instance as parameter
+ $response = $currenciesOperations->enableMultipleCurrencies($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $baseCurrencyActionHandler = $response->getObject();
+
+ if($baseCurrencyActionHandler instanceof BaseCurrencyActionWrapper)
+ {
+ //Get the received BaseCurrencyActionWrapper instance
+ $baseCurrencyActionWrapper = $baseCurrencyActionHandler;
+
+ //Get the received obtained ActionResponse instances
+ $actionResponse = $baseCurrencyActionWrapper->getBaseCurrency();
+
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value);
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value);
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($baseCurrencyActionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $baseCurrencyActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Currency
+ * This method is used to update base currency details.
+ * @throws Exception
+ */
+ public static function updateBaseCurrency()
+ {
+ //Get instance of CurrenciesOperations Class
+ $currenciesOperations = new CurrenciesOperations();
+
+ //Get instance of BaseCurrencyWrapper Class that will contain the request body
+ $bodyWrapper = new BaseCurrencyWrapper();
+
+ $currencyClass = "com\zoho\crm\api\currencies\Currency";
+
+ //Get instance of Currency Class
+ $currency = new $currencyClass();
+
+ //To set the position of the ISO code in the base currency.
+ //true: Display ISO code before the currency value.
+ //false: Display ISO code after the currency value.
+ $currency->setPrefixSymbol(true);
+
+ //To set the symbol of the base currency.
+ $currency->setSymbol("Af");
+
+ //To set the rate at which the currency has to be exchanged for home base currency.
+ $currency->setExchangeRate("1.0000000");
+
+ //To set currency Id
+ $currency->setId("3477061000006008002");
+
+ $format = new Format();
+
+ //It can be a Period or Comma, depending on the base currency.
+ $format->setDecimalSeparator(new Choice("Period"));
+
+ //It can be a Period, Comma, or Space, depending on the base currency.
+ $format->setThousandSeparator(new Choice("Comma"));
+
+ //To set the number of decimal places allowed for the base currency. It can be 0, 2, or 3.
+ $format->setDecimalPlaces(new Choice("2"));
+
+ //To set the format of the base currency
+ $currency->setFormat($format);
+
+ //Set the Currency in BodyWrapper instance
+ $bodyWrapper->setBaseCurrency($currency);
+
+ //Call enableMultipleCurrencies method that takes BodyWrapper instance as parameter
+ $response = $currenciesOperations->updateBaseCurrency($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $baseCurrencyActionHandler = $response->getObject();
+
+ if($baseCurrencyActionHandler instanceof BaseCurrencyActionWrapper)
+ {
+ //Get the received BaseCurrencyActionWrapper instance
+ $baseCurrencyActionWrapper = $baseCurrencyActionHandler;
+
+ //Get the ActionResponse instance
+ $actionResponse = $baseCurrencyActionWrapper->getBaseCurrency();
+
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($baseCurrencyActionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $baseCurrencyActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Currency
+ * This method is used to get the details of a specific currency.
+ * @param currencyId - Specify the unique ID of the currency.
+ * @throws Exception
+ */
+ public static function getCurrency(string $currencyId)
+ {
+ //Get instance of CurrenciesOperations Class
+ $currenciesOperations = new CurrenciesOperations();
+
+ //Call getCurrency method
+ $response = $currenciesOperations->getCurrency($currencyId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Currency instance
+ $currenciesList = $responseWrapper->getCurrencies();
+
+ foreach($currenciesList as $currency)
+ {
+ //Get the Symbol of each currency
+ echo("Currency Symbol: " . $currency->getSymbol() . "\n");
+
+ //Get the CreatedTime of each currency
+ echo("Currency CreatedTime: ");
+
+ print_r($currency->getCreatedTime());
+
+ echo("\n");
+
+ //Get the currency is IsActive
+ echo("Currency IsActive: " . $currency->getIsActive() . "\n");
+
+ //Get the ExchangeRate of each currency
+ echo("Currency ExchangeRate: " . $currency->getExchangeRate() . "\n");
+
+ //Get the format Format instance of each currency
+ $format = $currency->getFormat();
+
+ //Check if format is not null
+ if($format != null)
+ {
+ //Get the DecimalSeparator of the Format
+ echo("Currency Format DecimalSeparator: " . $format->getDecimalSeparator()->getValue() . "\n");
+
+ //Get the ThousandSeparator of the Format
+ echo("Currency Format ThousandSeparator: " . $format->getThousandSeparator()->getValue() . "\n");
+
+ //Get the DecimalPlaces of the Format
+ echo("Currency Format DecimalPlaces: " . $format->getDecimalPlaces()->getValue() . "\n");
+ }
+
+ //Get the createdBy User instance of each currency
+ $createdBy = $currency->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("Currency CreatedBy User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Currency CreatedBy User-ID: " . $createdBy->getId() . "\n");
+ }
+
+ //Get the PrefixSymbol of each currency
+ echo("Currency PrefixSymbol: " . $currency->getPrefixSymbol() . "\n");
+
+ //Get the IsBase of each currency
+ echo("Currency IsBase: " . $currency->getIsBase() . "\n");
+
+ //Get the ModifiedTime of each currency
+ echo("Currency ModifiedTime: ");
+
+ print_r($currency->getModifiedTime());
+
+ echo("\n");
+
+ //Get the Name of each currency
+ echo("Currency Name: " . $currency->getName() . "\n");
+
+ //Get the modifiedBy User instance of each currency
+ $modifiedBy = $currency->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Currency ModifiedBy User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Currency ModifiedBy User-ID: " . $modifiedBy->getId() . "\n");
+ }
+
+ //Get the Id of each currency
+ echo("Currency Id: " . $currency->getId() . "\n");
+
+ //Get the IsoCode of each currency
+ echo("Currency IsoCode: " . $currency->getIsoCode() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Currency
+ * This method is used to update currency details.
+ * @param currencyId - Specify the unique ID of the currency.
+ * @throws Exception
+ */
+ public static function updateCurrency(string $currencyId)
+ {
+ //Get instance of CurrenciesOperations Class
+ $currenciesOperations = new CurrenciesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Currency instances
+ $currencies = array();
+
+ $currencyClass = "com\zoho\crm\api\currencies\Currency";
+
+ //Get instance of Currency Class
+ $currency = new $currencyClass();
+
+ //To set the position of the ISO code in the currency.
+ //true: Display ISO code before the currency value.
+ //false: Display ISO code after the currency value.
+ $currency->setPrefixSymbol(true);
+
+ //To set the rate at which the currency has to be exchanged for home currency.
+ $currency->setExchangeRate("5.0000000");
+
+ //To set the status of the currency.
+ //true: The currency is active.
+ //false: The currency is inactive.
+ $currency->setIsActive(true);
+
+ $format = new Format();
+
+ //It can be a Period or Comma, depending on the currency.
+ $format->setDecimalSeparator(new Choice("Period"));
+
+ //It can be a Period, Comma, or Space, depending on the currency.
+ $format->setThousandSeparator(new Choice("Comma"));
+
+ //To set the number of decimal places allowed for the currency. It can be 0, 2, or 3.
+ $format->setDecimalPlaces(new Choice("2"));
+
+ //To set the format of the currency
+ $currency->setFormat($format);
+
+ array_push($currencies, $currency);
+
+ //Set the list to Currency in BodyWrapper instance
+ $bodyWrapper->setCurrencies($currencies);
+
+ //Call addCurrencies method that takes BodyWrapper instance as parameter
+ $response = $currenciesOperations->updateCurrency($currencyId,$bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code" . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getCurrencies();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/customview/CustomView.php b/samples/src/com/zoho/crm/api/customview/CustomView.php
new file mode 100644
index 0000000..c5b9326
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/customview/CustomView.php
@@ -0,0 +1,381 @@
+ Get CustomViews
+ * This method is used to get the custom views data of a particular module.
+ * Specify the module name in your API request whose custom view data you want to retrieve.
+ * @param moduleAPIName - Specify the API name of the required module.
+ * @throws Exception
+ */
+ public static function getCustomViews(string $moduleAPIName)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+
+ //Get instance of CustomViewOperations Class that takes moduleAPIName as parameter
+ $customViewsOperations = new CustomViewsOperations($moduleAPIName);
+
+ //Call getCustomViews method
+ $response = $customViewsOperations->getCustomViews();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained CustomView instances
+ $customViews = $responseWrapper->getCustomViews();
+
+ foreach($customViews as $customView)
+ {
+ //Get the DisplayValue of each CustomView
+ echo("CustomView DisplayValue: " . $customView->getDisplayValue() . "\n");
+
+ //Get the Offline of the each CustomView
+ echo("CustomView Offline: " . $customView->getOffline() . "\n");
+
+ //Get the Default of each CustomView
+ echo("CustomView Default: " . $customView->getDefault() . "\n");
+
+ //Get the SystemName of each CustomView
+ echo("CustomView SystemName: " . $customView->getSystemName() . "\n");
+
+ //Get the SystemDefined of each CustomView
+ echo("CustomView SystemDefined: " . $customView->getSystemDefined() . "\n");
+
+ //Get the Name of each CustomView
+ echo("CustomView Name: " . $customView->getName() . "\n");
+
+ //Get the ID of each CustomView
+ echo("CustomView ID: " . $customView->getId() . "\n");
+
+ //Get the Category of each CustomView
+ echo("CustomView Category: " . $customView->getCategory() . "\n");
+
+ if($customView->getFavorite() != null)
+ {
+ //Get the Favorite of each CustomView
+ echo("CustomView Favorite: " . $customView->getFavorite() . "\n");
+ }
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getPerPage() != null)
+ {
+ //Get the PerPage of the Info
+ echo("CustomView Info PerPage: " . $info->getPerPage() . "\n");
+ }
+
+ if($info->getDefault() != null)
+ {
+ //Get the Default of the Info
+ echo("CustomView Info Default: " . $info->getDefault() . "\n");
+ }
+
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("CustomView Info Count: " . $info->getCount() . "\n");
+ }
+
+ //Get the Translation instance of CustomView
+ $translation = $info->getTranslation();
+
+ if($translation != null)
+ {
+ //Get the PublicViews of the Translation
+ echo("CustomView Info Translation PublicViews: " . $translation->getPublicViews() . "\n");
+
+ //Get the OtherUsersViews of the Translation
+ echo("CustomView Info Translation OtherUsersViews: " . $translation->getOtherUsersViews() . "\n");
+
+ //Get the SharedWithMe of the Translation
+ echo("CustomView Info Translation SharedWithMe: " . $translation->getSharedWithMe() . "\n");
+
+ //Get the CreatedByMe of the Translation
+ echo("CustomView Info Translation CreatedByMe: " . $translation->getCreatedByMe() . "\n");
+ }
+
+ if($info->getPage() != null)
+ {
+ //Get the Page of the Info
+ echo("CustomView Info Page: " . $info->getPage() . "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the MoreRecords of the Info
+ echo("CustomView Info MoreRecords: " . $info->getMoreRecords() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * This method is used to get the data of any specific custom view of the module.
+ * Specify the custom view ID of the module in your API request whose custom view data you want to retrieve.
+ * @param moduleAPIName - Specify the API name of the required module.
+ * @param customID - ID of the CustomView to be obtainted.
+ * @throws Exception
+ */
+ public static function getCustomView(string $moduleAPIName, string $customViewId)
+ {
+ //example
+ //String moduleAPIName = "Leads";
+ //$customViewId = "3477061000005629003";
+
+ //Get instance of CustomViewOperations Class that takes moduleAPIName as parameter
+ $customViewsOperations = new CustomViewsOperations($moduleAPIName);
+
+ //Call getCustomView method that takes customViewId as parameter
+ $response = $customViewsOperations->getCustomView($customViewId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained CustomView instances
+ $customViews = $responseWrapper->getCustomViews();
+
+ foreach($customViews as $customView)
+ {
+ //Get the DisplayValue of each CustomView
+ echo("CustomView DisplayValue: " . $customView->getDisplayValue() . "\n");
+
+ //Get the SharedType of each CustomView
+ echo("CustomView SharedType: " . $customView->getSharedType() . "\n");
+
+ //Get the SystemName of each CustomView
+ echo("CustomView SystemName: " . $customView->getSystemName() . "\n");
+
+ // Get the Criteria instance of each Query
+ $criteria = $customView->getCriteria();
+
+ //Check if criteria is not null
+ if($criteria != null)
+ {
+ self::printCriteria($criteria);
+ }
+
+ $sharedDetails = $customView->getSharedDetails();
+
+ if($sharedDetails != null)
+ {
+ foreach($sharedDetails as $sharedDetail)
+ {
+ //Get the Name of the each SharedDetails
+ echo("SharedDetails Name: " . $sharedDetail->getName() . "\n");
+
+ //Get the ID of the each SharedDetails
+ echo("SharedDetails ID: " . $sharedDetail->getId() . "\n");
+
+ //Get the Type of the each SharedDetails
+ echo("SharedDetails Type: " . $sharedDetail->getType() . "\n");
+
+ //Get the Subordinates of the each SharedDetails
+ echo("SharedDetails Subordinates: " . $sharedDetail->getSubordinates() . "\n");
+ }
+ }
+
+ //Get the SortBy of the each CustomView
+ echo("CustomView SortBy: " . $customView->getSortBy() . "\n");
+
+ //Get the Offline of the each CustomView
+ echo("CustomView Offline: " . $customView->getOffline() . "\n");
+
+ //Get the Default of each CustomView
+ echo("CustomView Default: " . $customView->getDefault() . "\n");
+
+ //Get the SystemDefined of each CustomView
+ echo("CustomView SystemDefined: " . $customView->getSystemDefined() . "\n");
+
+ //Get the Name of each CustomView
+ echo("CustomView Name: " . $customView->getName() . "\n");
+
+ //Get the ID of each CustomView
+ echo("CustomView ID: " . $customView->getId() . "\n");
+
+ //Get the Category of each CustomView
+ echo("CustomView Category: " . $customView->getCategory() . "\n");
+
+ //Get the list of string each CustomView
+ $fields = $customView->getFields();
+
+ if($fields != null)
+ {
+ foreach($fields as $field)
+ {
+ echo($field . "\n");
+ }
+ }
+
+ if($customView->getFavorite() != null)
+ {
+ //Get the Favorite of each CustomView
+ echo("CustomView Favorite: " . $customView->getFavorite() . "\n");
+ }
+
+ if($customView->getSortOrder() != null)
+ {
+ //Get the SortOrder of each CustomView
+ echo("CustomView SortOrder: " . $customView->getSortOrder() . "\n");
+ }
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ //Get the Translation instance of CustomView
+ $translation = $info->getTranslation();
+
+ if($translation != null)
+ {
+ //Get the PublicViews of the Translation
+ echo("CustomView Info Translation PublicViews: " . $translation->getPublicViews() . "\n");
+
+ //Get the OtherUsersViews of the Translation
+ echo("CustomView Info Translation OtherUsersViews: " . $translation->getOtherUsersViews() . "\n");
+
+ //Get the SharedWithMe of the Translation
+ echo("CustomView Info Translation SharedWithMe: " . $translation->getSharedWithMe() . "\n");
+
+ //Get the CreatedByMe of the Translation
+ echo("CustomView Info Translation CreatedByMe: " . $translation->getCreatedByMe() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ private static function printCriteria($criteria)
+ {
+ if( $criteria->getComparator() != null)
+ {
+ //Get the Comparator of the Criteria
+ echo("CustomView Criteria Comparator: " . $criteria->getComparator()->getValue() . "\n");
+ }
+
+ //Get the Field of the Criteria
+ echo("CustomView Criteria Field: " . $criteria->getField() . "\n");
+
+ if($criteria->getValue() != null)
+ {
+ //Get the Value of the Criteria
+ echo("CustomView Criteria Value: " . $criteria->getValue() . "\n");
+ }
+
+ // Get the List of Criteria instance of each Criteria
+ $criteriaGroup = $criteria->getGroup();
+
+ if($criteriaGroup != null)
+ {
+ foreach($criteriaGroup as $criteria1)
+ {
+ self::printCriteria($criteria1);
+ }
+ }
+
+ if($criteria->getGroupOperator() != null)
+ {
+ //Get the Group Operator of the Criteria
+ echo("CustomView Criteria Group Operator: " . $criteria->getGroupOperator()->getValue() . "\n");
+ }
+ }
+}
diff --git a/samples/src/com/zoho/crm/api/fields/Fields.php b/samples/src/com/zoho/crm/api/fields/Fields.php
new file mode 100644
index 0000000..a8b604f
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/fields/Fields.php
@@ -0,0 +1,1023 @@
+ Get Fields
+ * This method is used to get metadata about all the fields of a module and print the response.
+ * @throws Exception
+ * @param moduleAPIName The API Name of the module to get fields
+ */
+ public static function getFields(string $moduleAPIName)
+ {
+ //example, moduleAPIName = "Leads";
+
+ //Get instance of FieldsOperations Class that takes moduleAPIName as parameter
+ $fieldOperations = new FieldsOperations($moduleAPIName);
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ // $paramInstance->add(GetFieldsParam::type(), "Unused");
+
+ //Call getFields method that takes paramInstance as parameter
+ $response = $fieldOperations->getFields($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Field instances
+ $fields = $responseWrapper->getFields();
+
+ if($fields != null)
+ {
+ foreach($fields as $field)
+ {
+ //Get the SystemMandatory of each Field
+ echo("Field SystemMandatory: " );
+
+ print_r($field->getSystemMandatory());
+
+ echo("\n");
+
+ //Get the Webhook of each Field
+ echo("Field Webhook: " . $field->getWebhook() . "\n");
+
+ //Get the JsonType of each Field
+ echo("Field JsonType: " . $field->getJsonType() . "\n");
+
+ //Get the private info of each field
+ $privateInfo = $field->getPrivate();
+
+ //Check if privateInfo is not null
+ if($privateInfo != null)
+ {
+ echo("Private Details\n");
+
+ //Get the type
+ echo("Field Private Type: " . $privateInfo->getType() . "\n");
+
+ //Get the Export
+ echo("Field Private Export: " . $privateInfo->getExport() . "\n");
+
+ //Get the Restricted
+ echo("Field Private Restricted: " . $privateInfo->getRestricted() . "\n");
+ }
+
+ //Get the obtained Crypt instance
+ $crypt = $field->getCrypt();
+
+ //Check if crypt is not null
+ if($crypt != null)
+ {
+ //Get the Mode of the Crypt
+ echo("Field Crypt Mode: " . $crypt->getMode() . "\n");
+
+ //Get the Column of the Crypt
+ echo("Field Crypt Column: " . $crypt->getColumn() . "\n");
+
+ //Get the Table of the Crypt
+ echo("Field Crypt Table: " . $crypt->getTable() . "\n");
+
+ //Get the Status of the Crypt
+ echo("Field Crypt Status: " . $crypt->getStatus() . "\n");
+ }
+
+ //Get the FieldLabel of each Field
+ echo("Field FieldLabel: " . $field->getFieldLabel() . "\n");
+
+ //Get the Object obtained ToolTip instance
+ $tooltip = $field->getTooltip();
+
+ //Check if tooltip is not null
+ if($tooltip != null)
+ {
+ //Get the Name of the ToolTip
+ echo("Field ToolTip Name: " . $tooltip->getName() . "\n");
+
+ //Get the Value of the ToolTip
+ echo("Field ToolTip Value: " . $tooltip->getValue() . "\n");
+ }
+
+ //Get the CreatedSource of each Field
+ echo("Field CreatedSource: " . $field->getCreatedSource() . "\n");
+
+ //Get the FieldReadOnly of each Field
+ echo("Field FieldReadOnly: " . $field->getFieldReadOnly() . "\n");
+
+ //Get the DisplayLabel of each Field
+ echo("Field DisplayLabel: " . $field->getDisplayLabel() . "\n");
+
+ //Get the ReadOnly of each Field
+ echo("Field ReadOnly: " . $field->getReadOnly() . "\n");
+
+ //Get the Object obtained AssociationDetails instance
+ $associationDetails = $field->getAssociationDetails();
+
+ //Check if associationDetails is not null
+ if($associationDetails != null)
+ {
+ //Get the Object obtained LookupField instance
+ $lookupField = $associationDetails->getLookupField();
+
+ //Check if lookupField is not null
+ if($lookupField != null)
+ {
+ //Get the ID of the LookupField
+ echo("Field AssociationDetails LookupField ID: " . $lookupField->getId() . "\n");
+
+ //Get the Name of the LookupField
+ echo("Field AssociationDetails LookupField Name: " . $lookupField->getName() . "\n");
+ }
+
+ //Get the Object obtained LookupField instance
+ $relatedField = $associationDetails->getRelatedField();
+
+ //Check if relatedField is not null
+ if($relatedField != null)
+ {
+ //Get the ID of the LookupField
+ echo("Field AssociationDetails RelatedField ID: " . $relatedField->getId() . "\n");
+
+ //Get the Name of the LookupField
+ echo("Field AssociationDetails RelatedField Name: " . $relatedField->getName() . "\n");
+ }
+ }
+
+ if($field->getQuickSequenceNumber() != null)
+ {
+ //Get the QuickSequenceNumber of each Field
+ echo("Field QuickSequenceNumber: " . $field->getQuickSequenceNumber() . "\n");
+ }
+
+ //Get the BusinesscardSupported of each Field
+ echo("Field BusinesscardSupported: " . $field->getBusinesscardSupported() . "\n");
+
+ //Check if MultiModuleLookup is not null
+ if($field->getMultiModuleLookup() != null)
+ {
+ //Get the MultiModuleLookup map
+ foreach($field->getMultiModuleLookup() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Object obtained Currency instance
+ $currency = $field->getCurrency();
+
+ //Check if currency is not null
+ if($currency != null)
+ {
+ //Get the RoundingOption of the Currency
+ echo("Field Currency RoundingOption: " . $currency->getRoundingOption() . "\n");
+
+ if($currency->getPrecision() != null)
+ {
+ //Get the Precision of the Currency
+ echo("Field Currency Precision: " . $currency->getPrecision() . "\n");
+ }
+ }
+
+ //Get the ID of each Field
+ echo("Field ID: " . $field->getId() . "\n");
+
+ if($field->getCustomField() != null)
+ {
+ //Get the CustomField of each Field
+ echo("Field CustomField: " . $field->getCustomField() . "\n");
+ }
+
+ //Get the Object obtained Module instance
+ $lookup = $field->getLookup();
+
+ //Check if lookup is not null
+ if($lookup != null)
+ {
+ //Get the Object obtained Layout instance
+ $layout = $lookup->getLayout();
+
+ //Check if layout is not null
+ if($layout != null)
+ {
+ //Get the ID of the Layout
+ echo("Field ModuleLookup Layout ID: " . $layout->getId() . "\n");
+
+ //Get the Name of the Layout
+ echo("Field ModuleLookup Layout Name: " . $layout->getName() . "\n");
+ }
+
+ //Get the DisplayLabel of the Module
+ echo("Field ModuleLookup DisplayLabel: " . $lookup->getDisplayLabel() . "\n");
+
+ //Get the APIName of the Module
+ echo("Field ModuleLookup APIName: " . $lookup->getAPIName() . "\n");
+
+ //Get the Module of the Module
+ echo("Field ModuleLookup Module: " . $lookup->getModule() . "\n");
+
+ if($lookup->getId() != null)
+ {
+ //Get the ID of the Module
+ echo("Field ModuleLookup ID: " . $lookup->getId() . "\n");
+ }
+ }
+
+ if($field->getVisible() != null)
+ {
+ //Get the Visible of each Field
+ echo("Field Visible: " . $field->getVisible() . "\n");
+ }
+
+ if($field->getLength() != null)
+ {
+ //Get the Length of each Field
+ echo("Field Length: " . $field->getLength() . "\n");
+ }
+
+ //Get the Object obtained ViewType instance
+ $viewType = $field->getViewType();
+
+ //Check if viewType is not null
+ if($viewType != null)
+ {
+ //Get the View of the ViewType
+ echo("Field ViewType View: " . $viewType->getView() . "\n");
+
+ //Get the Edit of the ViewType
+ echo("Field ViewType Edit: " . $viewType->getEdit() . "\n");
+
+ //Get the Create of the ViewType
+ echo("Field ViewType Create: " . $viewType->getCreate() . "\n");
+
+ //Get the View of the ViewType
+ echo("Field ViewType QuickCreate: " . $viewType->getQuickCreate() . "\n");
+ }
+
+ //Get the Object obtained Module instance
+ $subform = $field->getSubform();
+
+ //Check if subform is not null
+ if($subform != null)
+ {
+ //Get the Object obtained Layout instance
+ $layout = $subform->getLayout();
+
+ //Check if layout is not null
+ if($layout != null)
+ {
+ //Get the ID of the Layout
+ echo("Field Subform Layout ID: " . $layout->getId() . "\n");
+
+ //Get the Name of the Layout
+ echo("Field Subform Layout Name: " . $layout->getName() . "\n");
+ }
+
+ if($subform->getDisplayLabel() != null)
+ {
+ //Get the DisplayLabel of the Module
+ echo("Field Subform DisplayLabel: " . $subform->getDisplayLabel() . "\n");
+ }
+
+ //Get the APIName of the Module
+ echo("Field Subform APIName: " . $subform->getAPIName() . "\n");
+
+ //Get the Module of the Module
+ echo("Field Subform Module: " . $subform->getModule() . "\n");
+
+ if($subform->getId() != null)
+ {
+ //Get the ID of the Module
+ echo("Field Subform ID: " . $subform->getId() . "\n");
+ }
+ }
+
+ //Get the APIName of each Field
+ echo("Field APIName: " . $field->getAPIName() . "\n");
+
+ //Get the Object obtained Unique instance
+ $unique = $field->getUnique();
+
+ //Check if unique is not null
+ if($unique != null)
+ {
+ //Get the Casesensitive of the Unique
+ echo("Field Unique Casesensitive : " . $unique->getCasesensitive() . "\n");
+ }
+
+ if($field->getHistoryTracking() != null)
+ {
+ //Get the HistoryTracking of each Field
+ echo("Field HistoryTracking: " . $field->getHistoryTracking() . "\n");
+ }
+
+ //Get the DataType of each Field
+ echo("Field DataType: " . $field->getDataType() . "\n");
+
+ //Get the Object obtained Formula instance
+ $formula = $field->getFormula();
+
+ //Check if formula is not null
+ if($formula != null)
+ {
+ //Get the ReturnType of the Formula
+ echo("Field Formula ReturnType : " . $formula->getReturnType() . "\n");
+
+ if($formula->getExpression() != null)
+ {
+ //Get the Expression of the Formula
+ echo("Field Formula Expression : " . $formula->getExpression() . "\n");
+ }
+ }
+
+ if($field->getDecimalPlace() != null)
+ {
+ //Get the DecimalPlace of each Field
+ echo("Field DecimalPlace: " . $field->getDecimalPlace() . "\n");
+ }
+
+ //Get the MassUpdate of each Field
+ echo("Field MassUpdate: " . $field->getMassUpdate() . "\n");
+
+ if($field->getBlueprintSupported() != null)
+ {
+ //Get the BlueprintSupported of each Field
+ echo("Field BlueprintSupported: " . $field->getBlueprintSupported() . "\n");
+ }
+
+ //Get all entries from the MultiSelectLookup instance
+ $multiSelectLookup = $field->getMultiselectlookup();
+
+ //Check if formula is not null
+ if($multiSelectLookup != null)
+ {
+ //Get the DisplayValue of the MultiSelectLookup
+ echo("Field MultiSelectLookup DisplayLabel: " . $multiSelectLookup->getDisplayLabel() . "\n");
+
+ //Get the LinkingModule of the MultiSelectLookup
+ echo("Field MultiSelectLookup LinkingModule: " . $multiSelectLookup->getLinkingModule() . "\n");
+
+ //Get the LookupApiname of the MultiSelectLookup
+ echo("Field MultiSelectLookup LookupApiname: " . $multiSelectLookup->getLookupApiname() . "\n");
+
+ //Get the APIName of the MultiSelectLookup
+ echo("Field MultiSelectLookup APIName: " . $multiSelectLookup->getAPIName() . "\n");
+
+ //Get the ConnectedlookupApiname of the MultiSelectLookup
+ echo("Field MultiSelectLookup ConnectedlookupApiname: " . $multiSelectLookup->getConnectedlookupApiname() . "\n");
+
+ //Get the ID of the MultiSelectLookup
+ echo("Field MultiSelectLookup ID: " . $multiSelectLookup->getId() . "\n");
+ }
+
+ //Get the PickListValue of each Field
+ $pickListValues = $field->getPickListValues();
+
+ //Check if formula is not null
+ if($pickListValues != null)
+ {
+ foreach($pickListValues as $pickListValue)
+ {
+ //Get the DisplayValue of each PickListValues
+ echo("Field PickListValue DisplayValue: " . $pickListValue->getDisplayValue() . "\n");
+
+ if($pickListValue->getSequenceNumber() != null)
+ {
+ //Get the SequenceNumber of each PickListValues
+ echo(" Field PickListValue SequenceNumber: " . $pickListValue->getSequenceNumber() . "\n");
+ }
+
+ //Get the ExpectedDataType of each PickListValues
+ echo("Field PickListValue ExpectedDataType: " . $pickListValue->getExpectedDataType() . "\n");
+
+ //Get the ActualValue of each PickListValues
+ echo("Field PickListValue ActualValue: " . $pickListValue->getActualValue() . "\n");
+
+ if($pickListValue->getMaps() != null)
+ {
+ foreach($pickListValue->getMaps() as $map)
+ {
+ //Get each value from the map
+ echo($map . "\n");
+ }
+ }
+
+ //Get the SysRefName of each PickListValues
+ echo("Field PickListValue SysRefName: " . $pickListValue->getSysRefName() . "\n");
+
+ //Get the Type of each PickListValues
+ echo("Field PickListValue Type: " . $pickListValue->getType() . "\n");
+ }
+ }
+
+ //Get the AutoNumber of each Field
+ $autoNumber = $field->getAutoNumber();
+
+ //Check if formula is not null
+ if($autoNumber != null)
+ {
+ //Get the Prefix of the AutoNumber
+ echo("Field AutoNumber Prefix: " . $autoNumber->getPrefix() . "\n");
+
+ //Get the Suffix of the AutoNumber
+ echo("Field AutoNumber Suffix: " . $autoNumber->getSuffix() . "\n");
+
+ if($autoNumber->getStartNumber() != null)
+ {
+ //Get the StartNumber of the AutoNumber
+ echo("Field AutoNumber StartNumber: " . $autoNumber->getStartNumber() . "\n");
+ }
+ }
+
+ if($field->getDefaultValue() != null)
+ {
+ //Get the DefaultValue of each Field
+ echo("Field DefaultValue: " . $field->getDefaultValue() . "\n");
+ }
+
+ if($field->getSectionId() != null)
+ {
+ //Get the SectionId of each Field
+ echo("Field SectionId: " . $field->getSectionId() . "\n");
+ }
+
+ //Check if ValidationRule is not null
+ if($field->getValidationRule() != null)
+ {
+ //Get the details map
+ foreach($field->getValidationRule() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Check if ConvertMapping is not null
+ if($field->getConvertMapping() != null)
+ {
+ //Get the details map
+ foreach($field->getConvertMapping() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ }
+
+ /**
+ * Get Field
+ * This method is used to get metadata about a single field of a module with fieldID and print the response.
+ * @param moduleAPIName The API Name of the field's module
+ * @param fieldId The ID of the field to be obtained
+ * @throws Exception
+ */
+ public static function getField(string $moduleAPIName, string $fieldId)
+ {
+ //example,
+ //moduleAPIName = "Leads";
+ //fieldId = "525508000005067912";
+
+ //Get instance of FieldsOperations Class that takes moduleAPIName as parameter
+ $fieldOperations = new FieldsOperations($moduleAPIName);
+
+ //Call getField method which takes fieldId as parameter
+ $response = $fieldOperations->getField($fieldId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Field instances
+ $fields = $responseWrapper->getFields();
+
+ foreach($fields as $field)
+ {
+ //Get the SystemMandatory of each Field
+ echo("Field SystemMandatory: " );
+
+ print_r($field->getSystemMandatory());
+
+ echo("\n");
+
+ //Get the Webhook of each Field
+ echo("Field Webhook: " . $field->getWebhook() . "\n");
+
+ //Get the JsonType of each Field
+ echo("Field JsonType: " . $field->getJsonType() . "\n");
+
+ //Get the private info of each field
+ $privateInfo = $field->getPrivate();
+
+ //Check if privateInfo is not null
+ if($privateInfo != null)
+ {
+ echo("Private Details\n");
+
+ //Get the type
+ echo("Field Private Type: " . $privateInfo->getType() . "\n");
+
+ //Get the Export
+ echo("Field Private Export: " . $privateInfo->getExport() . "\n");
+
+ //Get the Restricted
+ echo("Field Private Restricted: " . $privateInfo->getRestricted() . "\n");
+ }
+
+ //Get the Object obtained Crypt instance
+ $crypt = $field->getCrypt();
+
+ //Check if crypt is not null
+ if($crypt != null)
+ {
+ //Get the Mode of the Crypt
+ echo("Field Crypt Mode: " . $crypt->getMode() . "\n");
+
+ //Get the Column of the Crypt
+ echo("Field Crypt Column: " . $crypt->getColumn() . "\n");
+
+ //Get the Table of the Crypt
+ echo("Field Crypt Table: " . $crypt->getTable() . "\n");
+
+ //Get the Status of the Crypt
+ echo("Field Crypt Status: " . $crypt->getStatus() . "\n");
+ }
+
+ //Get the FieldLabel of each Field
+ echo("Field FieldLabel: " . $field->getFieldLabel() . "\n");
+
+ //Get the Object obtained ToolTip instance
+ $tooltip = $field->getTooltip();
+
+ //Check if tooltip is not null
+ if($tooltip != null)
+ {
+ //Get the Name of the ToolTip
+ echo("Field ToolTip Name: " . $tooltip->getName() . "\n");
+
+ //Get the Value of the ToolTip
+ echo("Field ToolTip Value: " . $tooltip->getValue() . "\n");
+ }
+
+ //Get the CreatedSource of each Field
+ echo("Field CreatedSource: " . $field->getCreatedSource() . "\n");
+
+ //Get the FieldReadOnly of each Field
+ echo("Field FieldReadOnly: " . $field->getFieldReadOnly() . "\n");
+
+ //Get the DisplayLabel of each Field
+ echo("Field DisplayLabel: " . $field->getDisplayLabel() . "\n");
+
+ //Get the ReadOnly of each Field
+ echo("Field ReadOnly: " . $field->getReadOnly() . "\n");
+
+ //Get the Object obtained AssociationDetails instance
+ $associationDetails = $field->getAssociationDetails();
+
+ //Check if associationDetails is not null
+ if($associationDetails != null)
+ {
+ //Get the Object obtained LookupField instance
+ $lookupField = $associationDetails->getLookupField();
+
+ //Check if lookupField is not null
+ if($lookupField != null)
+ {
+ //Get the ID of the LookupField
+ echo("Field AssociationDetails LookupField ID: " . $lookupField->getId() . "\n");
+
+ //Get the Name of the LookupField
+ echo("Field AssociationDetails LookupField Name: " . $lookupField->getName() . "\n");
+ }
+
+ //Get the Object obtained LookupField instance
+ $relatedField = $associationDetails->getRelatedField();
+
+ //Check if relatedField is not null
+ if($relatedField != null)
+ {
+ //Get the ID of the LookupField
+ echo("Field AssociationDetails RelatedField ID: " . $relatedField->getId() . "\n");
+
+ //Get the Name of the LookupField
+ echo("Field AssociationDetails RelatedField Name: " . $relatedField->getName() . "\n");
+ }
+ }
+
+ if($field->getQuickSequenceNumber() != null)
+ {
+ //Get the QuickSequenceNumber of each Field
+ echo("Field QuickSequenceNumber: " . $field->getQuickSequenceNumber() . "\n");
+ }
+
+ //Get the BusinesscardSupported of each Field
+ echo("Field BusinesscardSupported: " . $field->getBusinesscardSupported() . "\n");
+
+ //Check if MultiModuleLookup is not null
+ if($field->getMultiModuleLookup() != null)
+ {
+ //Get the MultiModuleLookup map
+ foreach($field->getMultiModuleLookup() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Object obtained Currency instance
+ $currency = $field->getCurrency();
+
+ //Check if currency is not null
+ if($currency != null)
+ {
+ //Get the RoundingOption of the Currency
+ echo("Field Currency RoundingOption: " . $currency->getRoundingOption() . "\n");
+
+ if($currency->getPrecision() != null)
+ {
+ //Get the Precision of the Currency
+ echo("Field Currency Precision: " . $currency->getPrecision() . "\n");
+ }
+ }
+
+ //Get the ID of each Field
+ echo("Field ID: " . $field->getId() . "\n");
+
+ if($field->getCustomField() != null)
+ {
+ //Get the CustomField of each Field
+ echo("Field CustomField: " . $field->getCustomField() . "\n");
+ }
+
+ //Get the Object obtained Module instance
+ $lookup = $field->getLookup();
+
+ //Check if lookup is not null
+ if($lookup != null)
+ {
+ //Get the Object obtained Layout instance
+ $layout = $lookup->getLayout();
+
+ //Check if layout is not null
+ if($layout != null)
+ {
+ //Get the ID of the Layout
+ echo("Field ModuleLookup Layout ID: " . $layout->getId() . "\n");
+
+ //Get the Name of the Layout
+ echo("Field ModuleLookup Layout Name: " . $layout->getName() . "\n");
+ }
+
+ //Get the DisplayLabel of the Module
+ echo("Field ModuleLookup DisplayLabel: " . $lookup->getDisplayLabel() . "\n");
+
+ //Get the APIName of the Module
+ echo("Field ModuleLookup APIName: " . $lookup->getAPIName() . "\n");
+
+ //Get the Module of the Module
+ echo("Field ModuleLookup Module: " . $lookup->getModule() . "\n");
+
+ if($lookup->getId() != null)
+ {
+ //Get the ID of the Module
+ echo("Field ModuleLookup ID: " . $lookup->getId() . "\n");
+ }
+ }
+
+ if($field->getVisible() != null)
+ {
+ //Get the Visible of each Field
+ echo("Field Visible: " . $field->getVisible() . "\n");
+ }
+
+ if($field->getLength() != null)
+ {
+ //Get the Length of each Field
+ echo("Field Length: " . $field->getLength() . "\n");
+ }
+
+ //Get the Object obtained ViewType instance
+ $viewType = $field->getViewType();
+
+ //Check if viewType is not null
+ if($viewType != null)
+ {
+ //Get the View of the ViewType
+ echo("Field ViewType View: " . $viewType->getView() . "\n");
+
+ //Get the Edit of the ViewType
+ echo("Field ViewType Edit: " . $viewType->getEdit() . "\n");
+
+ //Get the Create of the ViewType
+ echo("Field ViewType Create: " . $viewType->getCreate() . "\n");
+
+ //Get the View of the ViewType
+ echo("Field ViewType QuickCreate: " . $viewType->getQuickCreate() . "\n");
+ }
+
+ //Get the Object obtained Module instance
+ $subform = $field->getSubform();
+
+ //Check if subform is not null
+ if($subform != null)
+ {
+ //Get the Object obtained Layout instance
+ $layout = $subform->getLayout();
+
+ //Check if layout is not null
+ if($layout != null)
+ {
+ //Get the ID of the Layout
+ echo("Field Subform Layout ID: " . $layout->getId() . "\n");
+
+ //Get the Name of the Layout
+ echo("Field Subform Layout Name: " . $layout->getName() . "\n");
+ }
+
+ //Get the DisplayLabel of the Module
+ echo("Field Subform DisplayLabel: " . $subform->getDisplayLabel() . "\n");
+
+ //Get the APIName of the Module
+ echo("Field Subform APIName: " . $subform->getAPIName() . "\n");
+
+ //Get the Module of the Module
+ echo("Field Subform Module: " . $subform->getModule() . "\n");
+
+ if($subform->getId() != null)
+ {
+ //Get the ID of the Module
+ echo("Field Subform ID: " . $subform->getId() . "\n");
+ }
+ }
+
+ //Get the APIName of each Field
+ echo("Field APIName: " . $field->getAPIName() . "\n");
+
+ //Get the Object obtained Unique instance
+ $unique = $field->getUnique();
+
+ //Check if unique is not null
+ if($unique != null)
+ {
+ //Get the Casesensitive of the Unique
+ echo("Field Unique Casesensitive : " . $unique->getCasesensitive() . "\n");
+ }
+
+ if($field->getHistoryTracking() != null)
+ {
+ //Get the HistoryTracking of each Field
+ echo("Field HistoryTracking: " . $field->getHistoryTracking() . "\n");
+ }
+
+ //Get the DataType of each Field
+ echo("Field DataType: " . $field->getDataType() . "\n");
+
+ //Get the Object obtained Formula instance
+ $formula = $field->getFormula();
+
+ //Check if formula is not null
+ if($formula != null)
+ {
+ //Get the ReturnType of the Formula
+ echo("Field Formula ReturnType : " . $formula->getReturnType() . "\n");
+
+ if($formula->getExpression() != null)
+ {
+ //Get the Expression of the Formula
+ echo("Field Formula Expression : " . $formula->getExpression() . "\n");
+ }
+ }
+
+ if($field->getDecimalPlace() != null)
+ {
+ //Get the DecimalPlace of each Field
+ echo("Field DecimalPlace: " . $field->getDecimalPlace() . "\n");
+ }
+
+ //Get the MassUpdate of each Field
+ echo("Field MassUpdate: " . $field->getMassUpdate() . "\n");
+
+ if($field->getBlueprintSupported() != null)
+ {
+ //Get the BlueprintSupported of each Field
+ echo("Field BlueprintSupported: " . $field->getBlueprintSupported() . "\n");
+ }
+
+ //Get all entries from the MultiSelectLookup instance
+ $multiSelectLookup = $field->getMultiselectlookup();
+
+ //Check if formula is not null
+ if($multiSelectLookup != null)
+ {
+ //Get the DisplayValue of the MultiSelectLookup
+ echo("Field MultiSelectLookup DisplayLabel: " . $multiSelectLookup->getDisplayLabel() . "\n");
+
+ //Get the LinkingModule of the MultiSelectLookup
+ echo("Field MultiSelectLookup LinkingModule: " . $multiSelectLookup->getLinkingModule() . "\n");
+
+ //Get the LookupApiname of the MultiSelectLookup
+ echo("Field MultiSelectLookup LookupApiname: " . $multiSelectLookup->getLookupApiname() . "\n");
+
+ //Get the APIName of the MultiSelectLookup
+ echo("Field MultiSelectLookup APIName: " . $multiSelectLookup->getAPIName() . "\n");
+
+ //Get the ConnectedlookupApiname of the MultiSelectLookup
+ echo("Field MultiSelectLookup ConnectedlookupApiname: " . $multiSelectLookup->getConnectedlookupApiname() . "\n");
+
+ //Get the ID of the MultiSelectLookup
+ echo("Field MultiSelectLookup ID: " . $multiSelectLookup->getId() . "\n");
+ }
+
+ //Get the PickListValue of each Field
+ $pickListValues = $field->getPickListValues();
+
+ //Check if formula is not null
+ if($pickListValues != null)
+ {
+ foreach($pickListValues as $pickListValue)
+ {
+ //Get the DisplayValue of each PickListValues
+ echo("Field PickListValue DisplayValue: " . $pickListValue->getDisplayValue() . "\n");
+
+ if($pickListValue->getSequenceNumber() != null)
+ {
+ //Get the SequenceNumber of each PickListValues
+ echo(" Field PickListValue SequenceNumber: " . $pickListValue->getSequenceNumber() . "\n");
+ }
+
+ //Get the ExpectedDataType of each PickListValues
+ echo("Field PickListValue ExpectedDataType: " . $pickListValue->getExpectedDataType() . "\n");
+
+ //Get the ActualValue of each PickListValues
+ echo("Field PickListValue ActualValue: " . $pickListValue->getActualValue() . "\n");
+
+ if($pickListValue->getMaps() != null)
+ {
+ foreach($pickListValue->getMaps() as $map)
+ {
+ //Get each value from the map
+ echo($map . "\n");
+ }
+ }
+
+ //Get the SysRefName of each PickListValues
+ echo("Field PickListValue SysRefName: " . $pickListValue->getSysRefName() . "\n");
+
+ //Get the Type of each PickListValues
+ echo("Field PickListValue Type: " . $pickListValue->getType() . "\n");
+ }
+ }
+
+ //Get the AutoNumber of each Field
+ $autoNumber = $field->getAutoNumber();
+
+ //Check if formula is not null
+ if($autoNumber != null)
+ {
+ //Get the Prefix of the AutoNumber
+ echo("Field AutoNumber Prefix: " . $autoNumber->getPrefix() . "\n");
+
+ //Get the Suffix of the AutoNumber
+ echo("Field AutoNumber Suffix: " . $autoNumber->getSuffix() . "\n");
+
+ if($autoNumber->getStartNumber() != null)
+ {
+ //Get the StartNumber of the AutoNumber
+ echo("Field AutoNumber StartNumber: " . $autoNumber->getStartNumber() . "\n");
+ }
+ }
+
+ if($field->getDefaultValue() != null)
+ {
+ //Get the DefaultValue of each Field
+ echo("Field DefaultValue: " . $field->getDefaultValue() . "\n");
+ }
+
+ if($field->getSectionId() != null)
+ {
+ //Get the SectionId of each Field
+ echo("Field SectionId: " . $field->getSectionId() . "\n");
+ }
+
+ //Check if ValidationRule is not null
+ if($field->getValidationRule() != null)
+ {
+ //Get the details map
+ foreach($field->getValidationRule() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Check if ConvertMapping is not null
+ if($field->getConvertMapping() != null)
+ {
+ //Get the details map
+ foreach($field->getConvertMapping() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
diff --git a/samples/src/com/zoho/crm/api/file/File.php b/samples/src/com/zoho/crm/api/file/File.php
new file mode 100644
index 0000000..e488bfe
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/file/File.php
@@ -0,0 +1,244 @@
+ Upload File
+ * This method is used to upload a file and print the response.
+ * @throws Exception
+ */
+ public static function uploadFiles()
+ {
+ //Get instance of RecordOperations Class
+ $fileOperations = new FileOperations();
+
+ //Get instance of FileBodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
+ $streamWrapper = new StreamWrapper(null, null, "/Users/abc-XXX/Desktop/py.html");
+
+ //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
+ $streamWrapper1 = new StreamWrapper(null, null, "/Users/abc-XXX/Desktop/one.txt");
+
+ //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
+ $streamWrapper2 = new StreamWrapper(null, null, "/Users/abc-XXX/Desktop/pic.jpg");
+
+ //Set file to the FileBodyWrapper instance
+ $bodyWrapper->setFile([$streamWrapper, $streamWrapper1, $streamWrapper2 ]);
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ //Call uploadFiles method that takes BodyWrapper instance as parameter.
+ $response = $fileOperations->uploadFiles($bodyWrapper, $paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get File
+ * @param id - The ID of the uploaded File.
+ * @param destinationFolder - The absolute path of the destination folder to store the File
+ * @throws Exception
+ */
+ public static function getFile(string $id, string $destinationFolder)
+ {
+ //example
+ //id = "3477061000005177002";
+ //destinationFolder = "/Users/user_name/Desktop"
+
+ //Get instance of FileOperations Class
+ $fileOperations = new FileOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetFileParam::id(), $id);
+
+ //Call getFile method that takes paramInstance as parameters
+ $response = $fileOperations->getFile($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof FileBodyWrapper)
+ {
+ //Get object from response
+ $fileBodyWrapper = $responseHandler;
+
+ //Get StreamWrapper instance from the returned FileBodyWrapper instance
+ $streamWrapper = $fileBodyWrapper->getFile();
+
+ //Create a file instance with the absolute_file_path
+ $fp = fopen($destinationFolder."/".$streamWrapper->getName(), "w");
+
+ //Get stream from the response
+ $stream = $streamWrapper->getStream();
+
+ fputs($fp, $stream);
+
+ fclose($fp);
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
diff --git a/samples/src/com/zoho/crm/api/initializer/Initialize.php b/samples/src/com/zoho/crm/api/initializer/Initialize.php
new file mode 100644
index 0000000..ba735ad
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/initializer/Initialize.php
@@ -0,0 +1,85 @@
+ Level of the log messages to be logged. Can be configured by typing Levels "." and choose any level from the list displayed.
+ * 2 -> Absolute file path, where messages need to be logged.
+ */
+ $logger = Logger::getInstance(Levels::INFO, "/Users/user_name/Documents/php_sdk_log.log");
+
+ //Create an UserSignature instance that takes user Email as parameter
+ $user = new UserSignature("abc@zoho.com");
+
+ /*
+ * Configure the environment
+ * which is of the pattern Domain.Environment
+ * Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter
+ * Available Environments: PRODUCTION, DEVELOPER, SANDBOX
+ */
+ $environment = USDataCenter::PRODUCTION();
+
+ //Create a Token instance
+ $token = new OAuthToken("clientId", "clientSecret", "REFRESH/GRANT token", TokenType::REFRESH/GRANT, "redirectURL");
+
+ //Create an instance of TokenStore
+
+ $tokenstore = new DBStore("hostName", "dataBaseName", "userName", "password", "portNumber");
+
+ // $tokenstore = new FileStore("absolute_file_path");
+
+ $resourcePath = "/Users/user_name/Documents/phpsdk-application";
+
+ $autoRefreshFields = true;
+
+ $pickListValidation = false;
+
+ $builderInstance = new SDKConfigBuilder();
+
+ //Create an instance of SDKConfig
+ $configInstance = $builderInstance->setPickListValidation($pickListValidation)->setAutoRefreshFields($autoRefreshFields)->build();
+
+ //Create an instance of RequestProxy
+ $requestProxy = new RequestProxy("proxyHost", "proxyPort", "proxyUser", "password");
+
+ /*
+ * Call static initialize method of Initializer class that takes the arguments
+ * 1 -> UserSignature instance
+ * 2 -> Environment instance
+ * 3 -> Token instance
+ * 4 -> TokenStore instance
+ * 5 -> SDKConfig instance
+ * 6 -> The path containing the absolute directory path to store user specific JSON files containing module fields information.
+ * 7 -> Logger instance (Optional)
+ * 8 -> RequestProxy instance (Optional)
+ */
+ Initializer::initialize($user, $environment, $token, $tokenstore, $configInstance, $resourcePath, $logger, $requestProxy);
+ }
+}
+?>
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/layouts/Layout.php b/samples/src/com/zoho/crm/api/layouts/Layout.php
new file mode 100644
index 0000000..bf331aa
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/layouts/Layout.php
@@ -0,0 +1,929 @@
+ Get Layouts
+ * This method is used to get metadata about all the layouts of a module and print the response.
+ * @param moduleAPIName The API Name of the module to get layouts.
+ * @throws Exception
+ */
+ public static function getLayouts(string $moduleAPIName)
+ {
+ //example, moduleAPIName = "Leads";
+
+ //Get instance of LayoutsOperations Class that takes moduleAPIName as parameter
+ $layoutsOperations = new LayoutsOperations($moduleAPIName);
+
+ //Call getLayouts method
+ $response = $layoutsOperations->getLayouts();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Layout instances
+ $layouts = $responseWrapper->getLayouts();
+
+ foreach($layouts as $layout)
+ {
+ if($layout->getCreatedTime() != null)
+ {
+ //Get the CreatedTime of each Layout
+ echo("Layout CreatedTime: ");
+
+ print_r($layout->getCreatedTime());
+
+ echo("\n");
+ }
+
+ //Check if ConvertMapping is not null
+ if($layout->getConvertMapping() != null)
+ {
+ //Get the MultiModuleLookup map
+ foreach($layout->getConvertMapping() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the ModifiedTime of each Layout
+ echo("Layout ModifiedTime: " );
+
+ print_r($layout->getModifiedTime());
+
+ echo("\n");
+
+ //Get the Visible of each Layout
+ echo("Layout Visible: " . $layout->getVisible() . "\n");
+
+ //Get the createdFor User instance of each Layout
+ $createdFor = $layout->getCreatedFor();
+
+ //Check if createdFor is not null
+ if($createdFor != null)
+ {
+ //Get the Name of the createdFor User
+ echo("Layout CreatedFor User-Name: " . $createdFor->getName() . "\n");
+
+ //Get the ID of the createdFor User
+ echo("Layout CreatedFor User-ID: " . $createdFor->getId() . "\n");
+
+ //Get the Email of the createdFor User
+ echo("Layout CreatedFor User-Email: " . $createdFor->getEmail() . "\n");
+ }
+
+ //Get the Name of each Layout
+ echo("Layout Name: " . $layout->getName() . "\n");
+
+ //Get the modifiedBy User instance of each Layout
+ $modifiedBy = $layout->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Layout ModifiedBy User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Layout ModifiedBy User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Layout ModifiedBy User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the profiles of each Layout
+ $profiles = $layout->getProfiles();
+
+ //Check if profiles is not null
+ if($profiles != null)
+ {
+ foreach($profiles as $profile)
+ {
+ //Get the Default of each Profile
+ echo("Layout Profile Default: " . $profile->getDefault() . "\n");
+
+ //Get the Name of each Profile
+ echo("Layout Profile Name: " . $profile->getName() . "\n");
+
+ //Get the ID of each Profile
+ echo("Layout Profile ID: " . $profile->getId() . "\n");
+ }
+ }
+
+ //Get the ID of each Layout
+ echo("Layout ID: " . $layout->getId() . "\n");
+
+ //Get the createdBy User instance of each Layout
+ $createdBy = $layout->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("Layout CreatedBy User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Layout CreatedBy User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Layout CreatedBy User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the sections of each Layout
+ $sections = $layout->getSections();
+
+ //Check if sections is not null
+ if($sections != null)
+ {
+ foreach($sections as $section)
+ {
+ //Get the DisplayLabel of each Section
+ echo("Layout Section DisplayLabel: " . $section->getDisplayLabel() . "\n");
+
+ //Get the SequenceNumber of each Section
+ echo("Layout Section SequenceNumber: " . $section->getSequenceNumber() . "\n");
+
+ //Get the Issubformsection of each Section
+ echo("Layout Section Issubformsection: " . $section->getIssubformsection() . "\n");
+
+ //Get the TabTraversal of each Section
+ echo("Layout Section TabTraversal: " . $section->getTabTraversal() . "\n");
+
+ //Get the APIName of each Section
+ echo("Layout Section APIName: " . $section->getAPIName() . "\n");
+
+ //Get the ColumnCount of each Section
+ echo("Layout Section ColumnCount: " . $section->getColumnCount() . "\n");
+
+ //Get the Name of each Section
+ echo("Layout Section Name: " . $section->getName() . "\n");
+
+ //Get the GeneratedType of each Section
+ echo("Layout Section GeneratedType: " . $section->getGeneratedType() . "\n");
+
+ //Get the fields of each Section
+ $fields = $section->getFields();
+
+ //Check if sections is not null
+ if($fields != null)
+ {
+ foreach($fields as $field)
+ {
+ self::printField($field);
+ }
+ }
+
+ //Get the properties User instance of each Section
+ $properties = $section->getProperties();
+
+ //Check if properties is not null
+ if($properties != null)
+ {
+ //Get the ReorderRows of each Properties
+ echo("Layout Section Properties ReorderRows: " . $properties->getReorderRows() . "\n");
+
+ //Get the tooltip User instance of the Properties
+ $tooltip = $properties->getTooltip();
+
+ //Check if tooltip is not null
+ if($tooltip != null)
+ {
+ //Get the Name of the ToolTip
+ echo("Layout Section Properties ToolTip Name: " . $tooltip->getName() . "\n");
+
+ //Get the Value of the ToolTip
+ echo("Layout Section Properties ToolTip Value: " . $tooltip->getValue() . "\n");
+ }
+
+ //Get the MaximumRows of each Properties
+ echo("Layout Section Properties MaximumRows: " . $properties->getMaximumRows() . "\n");
+ }
+ }
+ }
+
+ //Get the Status of each Layout
+ echo("Layout Status: " . $layout->getStatus() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Layout
+ * This method is used to get metadata about a single layout of a module with layoutID and print the response.
+ * @param moduleAPIName The API Name of the layout's module
+ * @param layoutId The ID of the field to be obtained
+ * @throws Exception
+ */
+ public static function getLayout(string $moduleAPIName, string $layoutId)
+ {
+ //example, moduleAPIName = "Leads";
+ //layoutId = "3477061000000091055"
+
+ //Get instance of LayoutsOperations Class that takes moduleAPIName as parameter
+ $layoutsOperations = new LayoutsOperations($moduleAPIName);
+
+ //Call getLayouts method
+ $response = $layoutsOperations->getLayout($layoutId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Layout instances
+ $layouts = $responseWrapper->getLayouts();
+
+ foreach($layouts as $layout)
+ {
+ if($layout->getCreatedTime() != null)
+ {
+ //Get the CreatedTime of each Layout
+ echo("Layout CreatedTime: " . $layout->getCreatedTime() . "\n");
+ }
+
+ //Check if ConvertMapping is not null
+ if($layout->getConvertMapping() != null)
+ {
+ //Get the MultiModuleLookup map
+ foreach($layout->getConvertMapping() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the ModifiedTime of each Layout
+ echo("Layout ModifiedTime: " );
+
+ print_r($layout->getModifiedTime());
+
+ echo("\n");
+
+ //Get the Visible of each Layout
+ echo("Layout Visible: " . $layout->getVisible() . "\n");
+
+ //Get the createdFor User instance of each Layout
+ $createdFor = $layout->getCreatedFor();
+
+ //Check if createdFor is not null
+ if($createdFor != null)
+ {
+ //Get the Name of the createdFor User
+ echo("Layout CreatedFor User-Name: " . $createdFor->getName() . "\n");
+
+ //Get the ID of the createdFor User
+ echo("Layout CreatedFor User-ID: " . $createdFor->getId() . "\n");
+
+ //Get the Email of the createdFor User
+ echo("Layout CreatedFor User-Email: " . $createdFor->getEmail() . "\n");
+ }
+
+ //Get the Name of each Layout
+ echo("Layout Name: " . $layout->getName() . "\n");
+
+ //Get the modifiedBy User instance of each Layout
+ $modifiedBy = $layout->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Layout ModifiedBy User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Layout ModifiedBy User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Layout ModifiedBy User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the profiles of each Layout
+ $profiles = $layout->getProfiles();
+
+ //Check if profiles is not null
+ if($profiles != null)
+ {
+ foreach($profiles as $profile)
+ {
+ //Get the Default of each Profile
+ echo("Layout Profile Default: " . $profile->getDefault() . "\n");
+
+ //Get the Name of each Profile
+ echo("Layout Profile Name: " . $profile->getName() . "\n");
+
+ //Get the ID of each Profile
+ echo("Layout Profile ID: " . $profile->getId() . "\n");
+ }
+ }
+
+ //Get the ID of each Layout
+ echo("Layout ID: " . $layout->getId() . "\n");
+
+ //Get the createdBy User instance of each Layout
+ $createdBy = $layout->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("Layout CreatedBy User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Layout CreatedBy User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Layout CreatedBy User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the sections of each Layout
+ $sections = $layout->getSections();
+
+ //Check if sections is not null
+ if($sections != null)
+ {
+ foreach($sections as $section)
+ {
+ //Get the DisplayLabel of each Section
+ echo("Layout Section DisplayLabel: " . $section->getDisplayLabel() . "\n");
+
+ //Get the SequenceNumber of each Section
+ echo("Layout Section SequenceNumber: " . $section->getSequenceNumber() . "\n");
+
+ //Get the Issubformsection of each Section
+ echo("Layout Section Issubformsection: " . $section->getIssubformsection() . "\n");
+
+ //Get the TabTraversal of each Section
+ echo("Layout Section TabTraversal: " . $section->getTabTraversal() . "\n");
+
+ //Get the APIName of each Section
+ echo("Layout Section APIName: " . $section->getAPIName() . "\n");
+
+ //Get the ColumnCount of each Section
+ echo("Layout Section ColumnCount: " . $section->getColumnCount() . "\n");
+
+ //Get the Name of each Section
+ echo("Layout Section Name: " . $section->getName() . "\n");
+
+ //Get the GeneratedType of each Section
+ echo("Layout Section GeneratedType: " . $section->getGeneratedType() . "\n");
+
+ //Get the fields of each Section
+ $fields = $section->getFields();
+
+ //Check if sections is not null
+ if($fields != null)
+ {
+ foreach($fields as $field)
+ {
+ self::printField($field);
+ }
+ }
+
+ //Get the properties User instance of each Section
+ $properties = $section->getProperties();
+
+ //Check if properties is not null
+ if($properties != null)
+ {
+ //Get the ReorderRows of each Properties
+ echo("Layout Section Properties ReorderRows: " . $properties->getReorderRows() . "\n");
+
+ //Get the tooltip User instance of the Properties
+ $tooltip = $properties->getTooltip();
+
+ //Check if tooltip is not null
+ if($tooltip != null)
+ {
+ //Get the Name of the ToolTip
+ echo("Layout Section Properties ToolTip Name: " . $tooltip->getName() . "\n");
+
+ //Get the Value of the ToolTip
+ echo("Layout Section Properties ToolTip Value: " . $tooltip->getValue() . "\n");
+ }
+
+ //Get the MaximumRows of each Properties
+ echo("Layout Section Properties MaximumRows: " . $properties->getMaximumRows() . "\n");
+ }
+ }
+ }
+
+ //Get the Status of each Layout
+ echo("Layout Status: " . $layout->getStatus() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ private static function printField($field)
+ {
+ //Get the SystemMandatory of each Field
+ echo("Field SystemMandatory: " . $field->getSystemMandatory() . "\n");
+
+ //Get the Webhook of each Field
+ echo("Field Webhook: " . $field->getWebhook() . "\n");
+
+ //Get the JsonType of each Field
+ echo("Field JsonType: " . $field->getJsonType() . "\n");
+
+ //Get the Object obtained Crypt instance
+ $crypt = $field->getCrypt();
+
+ //Check if crypt is not null
+ if($crypt != null)
+ {
+ //Get the Mode of the Crypt
+ echo("Field Crypt Mode: " . $crypt->getMode() . "\n");
+
+ //Get the Column of the Crypt
+ echo("Field Crypt Column: " . $crypt->getColumn() . "\n");
+
+ //Get the Table of the Crypt
+ echo("Field Crypt Table: " . $crypt->getTable() . "\n");
+
+ //Get the Status of the Crypt
+ echo("Field Crypt Status: " . $crypt->getStatus() . "\n");
+ }
+
+ //Get the FieldLabel of each Field
+ echo("Field FieldLabel: " . $field->getFieldLabel() . "\n");
+
+ //Get the Object obtained ToolTip instance
+ $tooltip = $field->getTooltip();
+
+ //Check if tooltip is not null
+ if($tooltip != null)
+ {
+ //Get the Name of the ToolTip
+ echo("Field ToolTip Name: " . $tooltip->getName() . "\n");
+
+ //Get the Value of the ToolTip
+ echo("Field ToolTip Value: " . $tooltip->getValue() . "\n");
+ }
+
+ //Get the CreatedSource of each Field
+ echo("Field CreatedSource: " . $field->getCreatedSource() . "\n");
+
+ //Get the FieldReadOnly of each Field
+ echo("Field FieldReadOnly: " . $field->getFieldReadOnly() . "\n");
+
+ //Get the DisplayLabel of each Field
+ echo("Field DisplayLabel: " . $field->getDisplayLabel() . "\n");
+
+ //Get the ReadOnly of each Field
+ echo("Field ReadOnly: " . $field->getReadOnly() . "\n");
+
+ //Get the Object obtained AssociationDetails instance
+ $associationDetails = $field->getAssociationDetails();
+
+ //Check if associationDetails is not null
+ if($associationDetails != null)
+ {
+ //Get the Object obtained LookupField instance
+ $lookupField = $associationDetails->getLookupField();
+
+ //Check if lookupField is not null
+ if($lookupField != null)
+ {
+ //Get the ID of the LookupField
+ echo("Field AssociationDetails LookupField ID: " . $lookupField->getId() . "\n");
+
+ //Get the Name of the LookupField
+ echo("Field AssociationDetails LookupField Name: " . $lookupField->getName() . "\n");
+ }
+
+ //Get the Object obtained LookupField instance
+ $relatedField = $associationDetails->getRelatedField();
+
+ //Check if relatedField is not null
+ if($relatedField != null)
+ {
+ //Get the ID of the LookupField
+ echo("Field AssociationDetails RelatedField ID: " . $relatedField->getId() . "\n");
+
+ //Get the Name of the LookupField
+ echo("Field AssociationDetails RelatedField Name: " . $relatedField->getName() . "\n");
+ }
+ }
+
+ if($field->getQuickSequenceNumber() != null)
+ {
+ //Get the QuickSequenceNumber of each Field
+ echo("Field QuickSequenceNumber: " . $field->getQuickSequenceNumber() . "\n");
+ }
+
+ if($field->getBusinesscardSupported() != null)
+ {
+ //Get the BusinesscardSupported of each Field
+ echo("Field BusinesscardSupported: " . $field->getBusinesscardSupported() . "\n");
+ }
+
+ //Check if MultiModuleLookup is not null
+ if($field->getMultiModuleLookup() != null)
+ {
+ //Get the MultiModuleLookup map
+ foreach($field->getMultiModuleLookup() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " . $value . "\n");
+ }
+ }
+
+ //Get the Object obtained Currency instance
+ $currency = $field->getCurrency();
+
+ //Check if currency is not null
+ if($currency != null)
+ {
+ //Get the RoundingOption of the Currency
+ echo("Field Currency RoundingOption: " . $currency->getRoundingOption() . "\n");
+
+ if($currency->getPrecision() != null)
+ {
+ //Get the Precision of the Currency
+ echo("Field Currency Precision: " . $currency->getPrecision() . "\n");
+ }
+ }
+
+ //Get the ID of each Field
+ echo("Field ID: " . $field->getId() . "\n");
+
+ if($field->getCustomField() != null)
+ {
+ //Get the CustomField of each Field
+ echo("Field CustomField: " . $field->getCustomField() . "\n");
+ }
+
+ //Get the Object obtained Module instance
+ $lookup = $field->getLookup();
+
+ //Check if lookup is not null
+ if($lookup != null)
+ {
+ //Get the Object obtained Layout instance
+ $layout = $lookup->getLayout();
+
+ //Check if layout is not null
+ if($layout != null)
+ {
+ //Get the ID of the Layout
+ echo("Field ModuleLookup Layout ID: " . $layout->getId() . "\n");
+
+ //Get the Name of the Layout
+ echo("Field ModuleLookup Layout Name: " . $layout->getName() . "\n");
+ }
+
+ //Get the DisplayLabel of the Module
+ echo("Field ModuleLookup DisplayLabel: " . $lookup->getDisplayLabel() . "\n");
+
+ //Get the APIName of the Module
+ echo("Field ModuleLookup APIName: " . $lookup->getAPIName() . "\n");
+
+ //Get the Module of the Module
+ echo("Field ModuleLookup Module: " . $lookup->getModule() . "\n");
+
+ if($lookup->getId() != null)
+ {
+ //Get the ID of the Module
+ echo("Field ModuleLookup ID: " . $lookup->getId() . "\n");
+ }
+ }
+
+ if($field->getVisible() != null)
+ {
+ //Get the Visible of each Field
+ echo("Field Visible: " . $field->getVisible() . "\n");
+ }
+
+ if($field->getLength() != null)
+ {
+ //Get the Length of each Field
+ echo("Field Length: " . $field->getLength() . "\n");
+ }
+
+ //Get the Object obtained ViewType instance
+ $viewType = $field->getViewType();
+
+ //Check if viewType is not null
+ if($viewType != null)
+ {
+ //Get the View of the ViewType
+ echo("Field ViewType View: " . $viewType->getView() . "\n");
+
+ //Get the Edit of the ViewType
+ echo("Field ViewType Edit: " . $viewType->getEdit() . "\n");
+
+ //Get the Create of the ViewType
+ echo("Field ViewType Create: " . $viewType->getCreate() . "\n");
+
+ //Get the View of the ViewType
+ echo("Field ViewType QuickCreate: " . $viewType->getQuickCreate() . "\n");
+ }
+
+ //Get the Object obtained Module instance
+ $subform = $field->getSubform();
+
+ //Check if subform is not null
+ if($subform != null)
+ {
+ //Get the Object obtained Layout instance
+ $layout = $subform->getLayout();
+
+ //Check if layout is not null
+ if($layout != null)
+ {
+ //Get the ID of the Layout
+ echo("Field Subform Layout ID: " . $layout->getId() . "\n");
+
+ //Get the Name of the Layout
+ echo("Field Subform Layout Name: " . $layout->getName() . "\n");
+ }
+
+ //Get the DisplayLabel of the Module
+ echo("Field Subform DisplayLabel: " . $subform->getDisplayLabel() . "\n");
+
+ //Get the APIName of the Module
+ echo("Field Subform APIName: " . $subform->getAPIName() . "\n");
+
+ //Get the Module of the Module
+ echo("Field Subform Module: " . $subform->getModule() . "\n");
+
+ if($subform->getId() != null)
+ {
+ //Get the ID of the Module
+ echo("Field Subform ID: " . $subform->getId() . "\n");
+ }
+ }
+
+ //Get the APIName of each Field
+ echo("Field APIName: " . $field->getAPIName() . "\n");
+
+ //Get the Object obtained Unique instance
+ $unique = $field->getUnique();
+
+ //Check if unique is not null
+ if($unique != null)
+ {
+ //Get the Casesensitive of the Unique
+ echo("Field Unique Casesensitive : " . $unique->getCasesensitive() . "\n");
+ }
+
+ if($field->getHistoryTracking() != null)
+ {
+ //Get the HistoryTracking of each Field
+ echo("Field HistoryTracking: " . $field->getHistoryTracking() . "\n");
+ }
+
+ //Get the DataType of each Field
+ echo("Field DataType: " . $field->getDataType() . "\n");
+
+ //Get the Object obtained Formula instance
+ $formula = $field->getFormula();
+
+ //Check if formula is not null
+ if($formula != null)
+ {
+ //Get the ReturnType of the Formula
+ echo("Field Formula ReturnType : " . $formula->getReturnType() . "\n");
+
+ if($formula->getExpression() != null)
+ {
+ //Get the Expression of the Formula
+ echo("Field Formula Expression : " . $formula->getExpression() . "\n");
+ }
+ }
+
+ if($field->getDecimalPlace() != null)
+ {
+ //Get the DecimalPlace of each Field
+ echo("Field DecimalPlace: " . $field->getDecimalPlace() . "\n");
+ }
+
+ if($field->getMassUpdate() != null)
+ {
+ //Get the MassUpdate of each Field
+ echo("Field MassUpdate: " . $field->getMassUpdate() . "\n");
+ }
+
+ if($field->getBlueprintSupported() != null)
+ {
+ //Get the BlueprintSupported of each Field
+ echo("Field BlueprintSupported: " . $field->getBlueprintSupported() . "\n");
+ }
+
+ //Get all entries from the MultiSelectLookup instance
+ $multiSelectLookup = $field->getMultiselectlookup();
+
+ //Check if formula is not null
+ if($multiSelectLookup != null)
+ {
+ //Get the DisplayValue of the MultiSelectLookup
+ echo("Field MultiSelectLookup DisplayLabel: " . $multiSelectLookup->getDisplayLabel() . "\n");
+
+ //Get the LinkingModule of the MultiSelectLookup
+ echo("Field MultiSelectLookup LinkingModule: " . $multiSelectLookup->getLinkingModule() . "\n");
+
+ //Get the LookupApiname of the MultiSelectLookup
+ echo("Field MultiSelectLookup LookupApiname: " . $multiSelectLookup->getLookupApiname() . "\n");
+
+ //Get the APIName of the MultiSelectLookup
+ echo("Field MultiSelectLookup APIName: " . $multiSelectLookup->getAPIName() . "\n");
+
+ //Get the ConnectedlookupApiname of the MultiSelectLookup
+ echo("Field MultiSelectLookup ConnectedlookupApiname: " . $multiSelectLookup->getConnectedlookupApiname() . "\n");
+
+ //Get the ID of the MultiSelectLookup
+ echo("Field MultiSelectLookup ID: " . $multiSelectLookup->getId() . "\n");
+ }
+
+ //Get the PickListValue of each Field
+ $pickListValues = $field->getPickListValues();
+
+ //Check if formula is not null
+ if($pickListValues != null)
+ {
+ foreach($pickListValues as $pickListValue)
+ {
+ //Get the DisplayValue of each PickListValues
+ echo("Field PickListValue DisplayValue: " . $pickListValue->getDisplayValue() . "\n");
+
+ if($pickListValue->getSequenceNumber() != null)
+ {
+ //Get the SequenceNumber of each PickListValues
+ echo(" Field PickListValue SequenceNumber: " . $pickListValue->getSequenceNumber() . "\n");
+ }
+
+ //Get the ExpectedDataType of each PickListValues
+ echo("Field PickListValue ExpectedDataType: " . $pickListValue->getExpectedDataType() . "\n");
+
+ //Get the ActualValue of each PickListValues
+ echo("Field PickListValue ActualValue: " . $pickListValue->getActualValue() . "\n");
+
+ if($pickListValue->getMaps() != null)
+ {
+ foreach($pickListValue->getMaps() as $map)
+ {
+ //Get each value from the map
+ echo($map . "\n");
+ }
+ }
+
+ //Get the SysRefName of each PickListValues
+ echo("Field PickListValue SysRefName: " . $pickListValue->getSysRefName() . "\n");
+
+ //Get the Type of each PickListValues
+ echo("Field PickListValue Type: " . $pickListValue->getType() . "\n");
+
+ }
+ }
+
+ //Get the AutoNumber of each Field
+ $autoNumber = $field->getAutoNumber();
+
+ //Check if formula is not null
+ if($autoNumber != null)
+ {
+ //Get the Prefix of the AutoNumber
+ echo("Field AutoNumber Prefix: " . $autoNumber->getPrefix() . "\n");
+
+ //Get the Suffix of the AutoNumber
+ echo("Field AutoNumber Suffix: " . $autoNumber->getSuffix() . "\n");
+
+ if($autoNumber->getStartNumber() != null)
+ {
+ //Get the StartNumber of the AutoNumber
+ echo("Field AutoNumber StartNumber: " . $autoNumber->getStartNumber() . "\n");
+ }
+ }
+
+ if($field->getDefaultValue() != null)
+ {
+ //Get the DefaultValue of each Field
+ echo("Field DefaultValue: " . $field->getDefaultValue() . "\n");
+ }
+
+ if($field->getSectionId() != null)
+ {
+ //Get the SectionId of each Field
+ echo("Field SectionId: " . $field->getSectionId() . "\n");
+ }
+
+ //Check if ValidationRule is not null
+ if($field->getValidationRule() != null)
+ {
+ //Get the details map
+ foreach($field->getValidationRule() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Check if ConvertMapping is not null
+ if($field->getConvertMapping() != null)
+ {
+ //Get the details map
+ foreach($field->getConvertMapping() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/modules/Modules.php b/samples/src/com/zoho/crm/api/modules/Modules.php
new file mode 100644
index 0000000..0e36a19
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/modules/Modules.php
@@ -0,0 +1,965 @@
+ Get Modules
+ * This method is used to get metadata about all the modules and print the response.
+ * @throws Exception
+ */
+ public static function getModules()
+ {
+ //Get instance of ModulesOperations Class
+ $moduleOperations = new ModulesOperations();
+
+ $headerInstance = new HeaderMap();
+
+ $datetime = date_create("2020-07-15T17:58:47+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $headerInstance->add(GetModulesHeader::IfModifiedSince(), $datetime);
+
+ //Call getModules method that takes headerInstance as parameters
+ $response = $moduleOperations->getModules($headerInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Module instances
+ $modules = $responseWrapper->getModules();
+
+ foreach($modules as $module)
+ {
+ //Get the Name of each Module
+ echo("Module Name: " . $module->getName() . "\n");
+
+ //Get the GlobalSearchSupported of each Module
+ echo("Module GlobalSearchSupported: " . $module->getGlobalSearchSupported() . "\n");
+
+ //Get the Deletable of each Module
+ echo("Module Deletable: " . $module->getDeletable() . "\n");
+
+ //Get the Description of each Module
+ echo("Module Description: " . $module->getDescription() . "\n");
+
+ //Get the Creatable of each Module
+ echo("Module Creatable: " . $module->getCreatable() . "\n");
+
+ //Get the InventoryTemplateSupported of each Module
+ echo("Module InventoryTemplateSupported: " . $module->getInventoryTemplateSupported() . "\n");
+
+ if($module->getModifiedTime() != null)
+ {
+ //Get the ModifiedTime of each Module
+ echo("Module ModifiedTime: ");
+
+ print_r($module->getModifiedTime());
+
+ echo("\n");
+ }
+
+ //Get the PluralLabel of each Module
+ echo("Module PluralLabel: " . $module->getPluralLabel() . "\n");
+
+ //Get the PresenceSubMenu of each Module
+ echo("Module PresenceSubMenu: " . $module->getPresenceSubMenu() . "\n");
+
+ //Get the TriggersSupported of each Module
+ echo("Module TriggersSupported: " . $module->getTriggersSupported() . "\n");
+
+ //Get the Id of each Module
+ echo("Module Id: " . $module->getId() . "\n");
+
+ //Get the Visibility of each Module
+ echo("Module Visibility: " . $module->getVisibility() . "\n");
+
+ //Get the Convertable of each Module
+ echo("Module Convertable: " . $module->getConvertable() . "\n");
+
+ //Get the Editable of each Module
+ echo("Module Editable: " . $module->getEditable() . "\n");
+
+ //Get the EmailtemplateSupport of each Module
+ echo("Module EmailtemplateSupport: " . $module->getEmailtemplateSupport() . "\n");
+
+ //Get the list of Profile instance each Module
+ $profiles = $module->getProfiles();
+
+ //Check if profiles is not null
+ if($profiles != null)
+ {
+ foreach($profiles as $profile)
+ {
+ //Get the Name of each Profile
+ echo("Module Profile Name: " . $profile->getName() . "\n");
+
+ //Get the Id of each Profile
+ echo("Module Profile Id: " . $profile->getId() . "\n");
+ }
+ }
+
+ //Get the FilterSupported of each Module
+ echo("Module FilterSupported: " . $module->getFilterSupported() . "\n");
+
+ //Get the ShowAsTab of each Module
+ echo("Module ShowAsTab: " . $module->getShowAsTab() . "\n");
+
+ //Get the WebLink of each Module
+ echo("Module WebLink: " . $module->getWebLink() . "\n");
+
+ //Get the SequenceNumber of each Module
+ echo("Module SequenceNumber: " . $module->getSequenceNumber() . "\n");
+
+ //Get the SingularLabel of each Module
+ echo("Module SingularLabel: " . $module->getSingularLabel() . "\n");
+
+ //Get the Viewable of each Module
+ echo("Module Viewable: " . $module->getViewable() . "\n");
+
+ //Get the APISupported of each Module
+ echo("Module APISupported: " . $module->getAPISupported() . "\n");
+
+ //Get the APIName of each Module
+ echo("Module APIName: " . $module->getAPIName() . "\n");
+
+ //Get the QuickCreate of each Module
+ echo("Module QuickCreate: " . $module->getQuickCreate() . "\n");
+
+ //Get the modifiedBy User instance of each Module
+ $modifiedBy = $module->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the name of the modifiedBy User
+ echo("Module Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Module Modified By User-ID: " . $modifiedBy->getId() . "\n");
+ }
+
+ //Get the GeneratedType of each Module
+ echo("Module GeneratedType: " . $module->getGeneratedType()->getValue() . "\n");
+
+ //Get the FeedsRequired of each Module
+ echo("Module FeedsRequired: " . $module->getFeedsRequired() . "\n");
+
+ //Get the ScoringSupported of each Module
+ echo("Module ScoringSupported: " . $module->getScoringSupported() . "\n");
+
+ //Get the WebformSupported of each Module
+ echo("Module WebformSupported: " . $module->getWebformSupported() . "\n");
+
+ //Get the list of Argument instance each Module
+ $arguments = $module->getArguments();
+
+ //Check if arguments is not null
+ if($arguments != null)
+ {
+ foreach($arguments as $argument)
+ {
+ //Get the Name of each Argument
+ echo("Module Argument Name: " . $argument->getName() . "\n");
+
+ //Get the Value of each Argument
+ echo("Module Argument Value: " . $argument->getValue() . "\n");
+ }
+ }
+
+ //Get the ModuleName of each Module
+ echo("Module ModuleName: " . $module->getModuleName() . "\n");
+
+ //Get the BusinessCardFieldLimit of each Module
+ echo("Module BusinessCardFieldLimit: " . $module->getBusinessCardFieldLimit() . "\n");
+
+ //Get the parentModule Module instance of each Module
+ $parentModule = $module->getParentModule();
+
+ //Check if arguments is not null
+ if($parentModule != null && $parentModule->getAPIName() != null)
+ {
+ //Get the Name of Parent Module
+ echo("Module Parent Module Name: " . $parentModule->getAPIName() . "\n");
+
+ //Get the Value of Parent Module
+ echo("Module Parent Module Id: " . $parentModule->getId() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Module
+ * This method is used to get metadata about single module with it's API Name and print the response.
+ * @param apiName The API Name of the module to obtain metadata
+ * @throws Exception
+ */
+ public static function getModule(string $moduleAPIName)
+ {
+ //example, moduleAPIName = "Leads";
+
+ //Get instance of ModulesOperations Class
+ $moduleOperations = new ModulesOperations();
+
+ //Call getModule method that takes moduleAPIName as parameter
+ $response = $moduleOperations->getModule($moduleAPIName);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Module instances
+ $modules = $responseWrapper->getModules();
+
+ foreach($modules as $module)
+ {
+ //Get the Name of each Module
+ echo("Module Name: " . $module->getName() . "\n");
+
+ //Get the GlobalSearchSupported of each Module
+ echo("Module GlobalSearchSupported: " . $module->getGlobalSearchSupported() . "\n");
+
+ //Get the KanbanView of each Module
+ echo("Module KanbanView: " . $module->getKanbanView() . "\n");
+
+ //Get the Deletable of each Module
+ echo("Module Deletable: " . $module->getDeletable() . "\n");
+
+ //Get the Description of each Module
+ echo("Module Description: " . $module->getDescription() . "\n");
+
+ //Get the Creatable of each Module
+ echo("Module Creatable: " . $module->getCreatable() . "\n");
+
+ //Get the FilterStatus of each Module
+ echo("Module FilterStatus: " . $module->getFilterStatus() . "\n");
+
+ //Get the InventoryTemplateSupported of each Module
+ echo("Module InventoryTemplateSupported: " . $module->getInventoryTemplateSupported() . "\n");
+
+ if($module->getModifiedTime() != null)
+ {
+ //Get the ModifiedTime of each Module
+ echo("Module ModifiedTime: ");
+
+ print_r($module->getModifiedTime());
+
+ echo("\n");
+ }
+
+ //Get the PluralLabel of each Module
+ echo("Module PluralLabel: " . $module->getPluralLabel() . "\n");
+
+ //Get the PresenceSubMenu of each Module
+ echo("Module PresenceSubMenu: " . $module->getPresenceSubMenu() . "\n");
+
+ //Get the TriggersSupported of each Module
+ echo("Module TriggersSupported: " . $module->getTriggersSupported() . "\n");
+
+ //Get the Id of each Module
+ echo("Module Id: " . $module->getId() . "\n");
+
+ //Get the RelatedListProperties instance of each Module
+ $relatedListProperties = $module->getRelatedListProperties();
+
+ //Check if relatedListProperties is not null
+ if($relatedListProperties != null)
+ {
+ //Get the SortBy of each RelatedListProperties
+ echo("Module RelatedListProperties SortBy: " . $relatedListProperties->getSortBy() . "\n");
+
+ //Get List of fields APIName
+ $fields = $relatedListProperties->getFields();
+
+ //Check if fields is not null
+ if($fields != null)
+ {
+ foreach($fields as $fieldName)
+ {
+ //Get the Field Name
+ echo("Module RelatedListProperties Fields: " . $fieldName . "\n");
+ }
+ }
+
+ //Get the Name of RelatedListProperties
+ echo("Module RelatedListProperties SortOrder: " . $relatedListProperties->getSortOrder() . "\n");
+ }
+
+ //Get List of properties field APIName
+ $properties = $module->getProperties();
+
+ //Check if properties is not null
+ if($properties != null)
+ {
+ foreach($properties as $fieldName)
+ {
+ //Get the Field Name
+ echo("Module Properties Fields: " . $fieldName . "\n");
+ }
+ }
+
+ //Get the PerPage of each Module
+ echo("Module PerPage: " . $module->getPerPage() . "\n");
+
+ //Get the Visibility of each Module
+ echo("Module Visibility: " . $module->getVisibility() . "\n");
+
+ //Get the Convertable of each Module
+ echo("Module Convertable: " . $module->getConvertable() . "\n");
+
+ //Get the Editable of each Module
+ echo("Module Editable: " . $module->getEditable() . "\n");
+
+ //Get the EmailtemplateSupport of each Module
+ echo("Module EmailtemplateSupport: " . $module->getEmailtemplateSupport() . "\n");
+
+ //Get the list of Profile instance each Module
+ $profiles = $module->getProfiles();
+
+ //Check if profiles is not null
+ if($profiles != null)
+ {
+ foreach($profiles as $profile)
+ {
+ //Get the Name of each Profile
+ echo("Module Profile Name: " . $profile->getName() . "\n");
+
+ //Get the Id of each Profile
+ echo("Module Profile Id: " . $profile->getId() . "\n");
+ }
+ }
+
+ //Get the FilterSupported of each Module
+ echo("Module FilterSupported: " . $module->getFilterSupported() . "\n");
+
+ //Get the DisplayField of each Module
+ echo("Module DisplayField: " . $module->getDisplayField() . "\n");
+
+ //Get List of SearchLayoutFields APIName
+ $searchLayoutFields = $module->getSearchLayoutFields();
+
+ //Check if searchLayoutFields is not null
+ if($searchLayoutFields != null)
+ {
+ foreach($searchLayoutFields as $fieldName)
+ {
+ //Get the Field Name
+ echo("Module SearchLayoutFields Fields: " . $fieldName . "\n");
+ }
+ }
+
+ //Get the KanbanViewSupported of each Module
+ echo("Module KanbanViewSupported: " . $module->getKanbanViewSupported() . "\n");
+
+ //Get the ShowAsTab of each Module
+ echo("Module ShowAsTab: " . $module->getShowAsTab() . "\n");
+
+ //Get the WebLink of each Module
+ echo("Module WebLink: " . $module->getWebLink() . "\n");
+
+ //Get the SequenceNumber of each Module
+ echo("Module SequenceNumber: " . $module->getSequenceNumber() . "\n");
+
+ //Get the SingularLabel of each Module
+ echo("Module SingularLabel: " . $module->getSingularLabel() . "\n");
+
+ //Get the Viewable of each Module
+ echo("Module Viewable: " . $module->getViewable() . "\n");
+
+ //Get the APISupported of each Module
+ echo("Module APISupported: " . $module->getAPISupported() . "\n");
+
+ //Get the APIName of each Module
+ echo("Module APIName: " . $module->getAPIName() . "\n");
+
+ //Get the QuickCreate of each Module
+ echo("Module QuickCreate: " . $module->getQuickCreate() . "\n");
+
+ //Get the modifiedBy User instance of each Module
+ $modifiedBy = $module->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the name of the modifiedBy User
+ echo("Module Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Module Modified By User-ID: " . $modifiedBy->getId() . "\n");
+ }
+
+ //Get the GeneratedType of each Module
+ echo("Module GeneratedType: " . $module->getGeneratedType()->getValue() . "\n");
+
+ //Get the FeedsRequired of each Module
+ echo("Module FeedsRequired: " . $module->getFeedsRequired() . "\n");
+
+ //Get the ScoringSupported of each Module
+ echo("Module ScoringSupported: " . $module->getScoringSupported() . "\n");
+
+ //Get the WebformSupported of each Module
+ echo("Module WebformSupported: " . $module->getWebformSupported() . "\n");
+
+ //Get the list of Argument instance each Module
+ $arguments = $module->getArguments();
+
+ //Check if arguments is not null
+ if($arguments != null)
+ {
+ foreach($arguments as $argument)
+ {
+ //Get the Name of each Argument
+ echo("Module Argument Name: " . $argument->getName() . "\n");
+
+ //Get the Value of each Argument
+ echo("Module Argument Value: " . $argument->getValue() . "\n");
+ }
+ }
+
+ //Get the ModuleName of each Module
+ echo("Module ModuleName: " . $module->getModuleName() . "\n");
+
+ //Get the BusinessCardFieldLimit of each Module
+ echo("Module BusinessCardFieldLimit: " . $module->getBusinessCardFieldLimit() . "\n");
+
+ //Get the CustomView instance of each Module
+ $customView = $module->getCustomView();
+
+ //Check if customView is not null
+ if($customView != null)
+ {
+ self::printCustomView($customView);
+ }
+
+ //Get the parentModule Module instance of each Module
+ $parentModule = $module->getParentModule();
+
+ //Check if arguments is not null
+ if($parentModule != null && $parentModule->getAPIName() != null)
+ {
+ //Get the Name of Parent Module
+ echo("Module Parent Module Name: " . $parentModule->getAPIName() . "\n");
+
+ //Get the Value of Parent Module
+ echo("Module Parent Module Id: " . $parentModule->getId() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ private static function printCustomView($customView)
+ {
+ //Get the DisplayValue of the CustomView
+ echo("Module CustomView DisplayValue: " . $customView->getDisplayValue() . "\n");
+
+ //Get the SharedType of the CustomView
+ echo("Module CustomView SharedType: " . $customView->getSharedType() . "\n");
+
+ //Get the SystemName of the CustomView
+ echo("Module CustomView SystemName: " . $customView->getSystemName() . "\n");
+
+ // Get the Criteria instance of the CustomView
+ $criteria = $customView->getCriteria();
+
+ //Check if criteria is not null
+ if($criteria != null)
+ {
+ self::printCriteria($criteria);
+ }
+
+ //Get the list of SharedDetails instance of the CustomView
+ $sharedDetails = $customView->getSharedDetails();
+
+ if($sharedDetails != null)
+ {
+ foreach($sharedDetails as $sharedDetail)
+ {
+ //Get the Name of the each SharedDetails
+ echo("Module SharedDetails Name: " . $sharedDetail->getName() . "\n");
+
+ //Get the ID of the each SharedDetails
+ echo("Module SharedDetails ID: " . $sharedDetail->getId() . "\n");
+
+ //Get the Type of the each SharedDetails
+ echo("Module SharedDetails Type: " . $sharedDetail->getType() . "\n");
+
+ //Get the Subordinates of the each SharedDetails
+ echo("Module SharedDetails Subordinates: " . $sharedDetail->getSubordinates() . "\n");
+ }
+ }
+
+ //Get the SortBy of the CustomView
+ echo("Module CustomView SortBy: " . $customView->getSortBy() . "\n");
+
+ //Get the Offline of the CustomView
+ echo("Module CustomView Offline: " . $customView->getOffline() . "\n");
+
+ //Get the Default of the CustomView
+ echo("Module CustomView Default: " . $customView->getDefault() . "\n");
+
+ //Get the SystemDefined of the CustomView
+ echo("Module CustomView SystemDefined: " . $customView->getSystemDefined() . "\n");
+
+ //Get the Name of the CustomView
+ echo("Module CustomView Name: " . $customView->getName() . "\n");
+
+ //Get the ID of the CustomView
+ echo("Module CustomView ID: " . $customView->getId() . "\n");
+
+ //Get the Category of the CustomView
+ echo("Module CustomView Category: " . $customView->getCategory() . "\n");
+
+ //Get the list of string
+ $fields = $customView->getFields();
+
+ if($fields != null)
+ {
+ foreach($fields as $field)
+ {
+ echo($field . "\n");
+ }
+ }
+
+ if($customView->getFavorite() != null)
+ {
+ //Get the Favorite of the CustomView
+ echo("Module CustomView Favorite: " . $customView->getFavorite() . "\n");
+ }
+
+ if($customView->getSortOrder() != null)
+ {
+ //Get the SortOrder of the CustomView
+ echo("Module CustomView SortOrder: " . $customView->getSortOrder() . "\n");
+ }
+ }
+
+ private static function printCriteria($criteria)
+ {
+ if($criteria->getComparator() != null)
+ {
+ //Get the Comparator of the Criteria
+ echo("Module CustomView Criteria Comparator: " . $criteria->getComparator()->getValue() . "\n");
+ }
+
+ //Get the Field of the Criteria
+ echo("Module CustomView Criteria Field: " . $criteria->getField() . "\n");
+
+ if($criteria->getValue() != null)
+ {
+ //Get the Value of the Criteria
+ echo("Module CustomView Criteria Value: " . $criteria->getValue() . "\n");
+ }
+
+ // Get the List of Criteria instance of each Criteria
+ $criteriaGroup = $criteria->getGroup();
+
+ if($criteriaGroup != null)
+ {
+ foreach($criteriaGroup as $criteria1)
+ {
+ self::printCriteria($criteria1);
+ }
+ }
+
+ if($criteria->getGroupOperator() != null)
+ {
+ //Get the Group Operator of the Criteria
+ echo("Module CustomView Criteria Group Operator: " . $criteria->getGroupOperator()->getValue() . "\n");
+ }
+ }
+
+ /**
+ * Update Module By APIName
+ * This method is used to update module details using module APIName and print the response.
+ * @param moduleAPIName The API Name of the module to obtain metadata
+ * @throws Exception
+ */
+ public static function updateModuleByAPIName(string $moduleAPIName)
+ {
+ //example, apiName = "Leads";
+
+ //Get instance of ModulesOperations Class
+ $moduleOperations = new ModulesOperations();
+
+ $modules = array();
+
+ $profiles = array();
+
+ //Get instance of Profile Class
+ $profile = new Profile();
+
+ //To set the Profile Id
+ $profile->setId("3477061000000026014");
+
+ $profile->setDelete(true);
+
+ array_push($profiles, $profile);
+
+ $module = new Module();
+
+ $module->setProfiles($profiles);
+
+ array_push($modules , $module);
+
+ $request = new BodyWrapper();
+
+ $request->setModules($modules);
+
+ //Call updateModuleByAPIName method that takes BodyWrapper instance and moduleAPIName as parameter
+ $response = $moduleOperations->updateModuleByAPIName($moduleAPIName,$request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getModules();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Module By Id
+ * This method is used to update module details using module Id and print the response.
+ * @param moduleID - The Id of the module to obtain metadata
+ * @throws Exception
+ */
+ public static function updateModuleById(string $moduleID)
+ {
+ //example, moduleAPIName = "Leads";
+
+ //Get instance of ModulesOperations Class
+ $moduleOperations = new ModulesOperations();
+
+ $modules = array();
+
+ $profiles = array();
+
+ //Get instance of Profile Class
+ $profile = new Profile();
+
+ $profile->setId("3477061000000026014");
+
+ // $profile->setDelete(true);
+
+ array_push($profiles, $profile);
+
+ $module = new Module();
+
+ $module->setProfiles($profiles);
+
+ $module->setAPIName("apiName2");
+
+ array_push($modules, $module);
+
+ $request = new BodyWrapper();
+
+ $request->setModules($modules);
+
+ //Call getModule method that takes BodyWrapper instance and moduleAPIName as parameter
+ $response = $moduleOperations->updateModuleById($moduleID,$request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained action responses
+ $actionResponses = $actionWrapper->getModules();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
diff --git a/samples/src/com/zoho/crm/api/notes/Note.php b/samples/src/com/zoho/crm/api/notes/Note.php
new file mode 100644
index 0000000..7259c3c
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/notes/Note.php
@@ -0,0 +1,1249 @@
+ Get Notes
+ * This method is used to get the list of notes and print the response.
+ * @throws Exception
+ */
+ public static function getNotes()
+ {
+ //Get instance of NotesOperations Class
+ $notesOperations = new NotesOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetNotesParam::page(), 1);
+
+ //$paramInstance->add(GetNotesParam::perPage(), 1);
+
+ //Get instance of HeaderMap Class
+ $headerInstance = new HeaderMap();
+
+ $headerInstance->add(GetNotesHeader::IfModifiedSince(), date_create("2019-05-07T15:32:24")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
+
+ //Call getNotes method that takes paramInstance and headerInstance as parameters
+ $response = $notesOperations->getNotes($paramInstance, $headerInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Note instances
+ $notes = $responseWrapper->getData();
+
+ foreach($notes as $note)
+ {
+ //Get the owner User instance of each Note
+ $owner = $note->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the name of the owner User
+ echo("Note Owner User-Name: " . $owner->getName() . "\n");
+
+ //Get the ID of the owner User
+ echo("Note Owner User-ID: " . $owner->getId() . "\n");
+
+ //Get the Email of the owner User
+ echo("Note Owner Email: " . $owner->getEmail() . "\n");
+ }
+
+ //Get the ModifiedTime of each Module
+ echo("Note ModifiedTime: ");
+
+ print_r($note->getModifiedTime());
+
+ echo("\n");
+
+ //Get the list of Attachment instance each Note
+ $attachments = $note->getAttachments();
+
+ //Check if attachments is not null
+ if($attachments != null)
+ {
+ foreach($attachments as $attachment)
+ {
+ self::printAttachment($attachment);
+ }
+ }
+
+ //Get the CreatedTime of each Note
+ echo("Note CreatedTime: ");
+
+ print_r($note->getCreatedTime());
+
+ echo("\n");
+
+ //Get the parentId Record instance of each Note
+ $parentId = $note->getParentId();
+
+ //Check if parentId is not null
+ if($parentId != null)
+ {
+ if($parentId->getKeyValue("name") != null)
+ {
+ //Get the parent record Name of each Note
+ echo("Note parent record Name: " . $parentId->getKeyValue("name") . "\n");
+ }
+
+ //Get the parent record ID of each Note
+ echo("Note parent record ID: " . $parentId->getId() . "\n");
+ }
+
+ //Get the Editable of each Note
+ echo("Note Editable: " . $note->getEditable() . "\n");
+
+ //Get the SeModule of each Note
+ echo("Note SeModule: " . $note->getSeModule() . "\n");
+
+ //Get the IsSharedToClient of each Note
+ echo("Note IsSharedToClient: " . $note->getIsSharedToClient() . "\n");
+
+ //Get the modifiedBy User instance of each Note
+ $modifiedBy = $note->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Note Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Note Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Note Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the Size of each Note
+ echo("Note Size: " . $note->getSize() . "\n");
+
+ //Get the State of each Note
+ echo("Note State: " . $note->getState() . "\n");
+
+ //Get the VoiceNote of each Note
+ echo("Note VoiceNote: " . $note->getVoiceNote() . "\n");
+
+ //Get the Id of each Note
+ echo("Note Id: " . $note->getId() . "\n");
+
+ //Get the createdBy User instance of each Note
+ $createdBy = $note->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("Note Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Note Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Note Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the NoteTitle of each Note
+ echo("Note NoteTitle: " . $note->getNoteTitle() . "\n");
+
+ //Get the NoteContent of each Note
+ echo("Note NoteContent: " . $note->getNoteContent() . "\n");
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ if($info != null)
+ {
+ if($info->getPerPage() != null)
+ {
+ //Get the PerPage of the Info
+ echo("Note Info PerPage: " . $info->getPerPage() . "\n");
+ }
+
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("Note Info Count: " . $info->getCount() . "\n");
+ }
+
+ if($info->getPage() != null)
+ {
+ //Get the Default of the Info
+ echo("Note Info Page: " . $info->getPage() . "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the Default of the Info
+ echo("Note Info MoreRecords: " . $info->getMoreRecords() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ private static function printAttachment($attachment)
+ {
+ //Get the createdBy User instance of each attachment
+ $owner = $attachment->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the Name of the Owner
+ echo("Note Attachment Owner User-Name: " . $owner->getName() . "\n");
+
+ //Get the ID of the Owner
+ echo("Note Attachment Owner User-Name: " . $owner->getId() . "\n");
+
+ //Get the Email of the Owner
+ echo("Note Attachment Owner User-Email: " . $owner->getEmail() . "\n");
+ }
+
+ //Get the modified time of each attachment
+ echo("Note Attachment Modified Time: " );
+
+ print_r($attachment->getModifiedTime());
+
+ echo("\n");
+
+ //Get the name of the File
+ echo("Note Attachment File Name: " . $attachment->getFileName() . "\n");
+
+ //Get the created time of each attachment
+ echo("Note Attachment Created Time: ");
+
+ print_r($attachment->getCreatedTime());
+
+ echo("\n");
+
+ //Get the Attachment file size
+ echo("Note Attachment File Size: " . $attachment->getSize() . "\n");
+
+ //Get the parentId Record instance of each attachment
+ $parentId = $attachment->getParentId();
+
+ //Check if parentId is not null
+ if($parentId != null)
+ {
+ //Get the parent record Name of each attachment
+ echo("Note Attachment parent record Name: " . $parentId->getKeyValue("name") . "\n");
+
+ //Get the parent record ID of each attachment
+ echo("Note Attachment parent record ID: " . $parentId->getId() . "\n");
+ }
+
+ //Get the attachment is Editable
+ echo("Note Attachment is Editable: " . $attachment->getEditable() . "\n");
+
+ //Get the file ID of each attachment
+ echo("Note Attachment File ID: " . $attachment->getFileId() . "\n");
+
+ //Get the type of each attachment
+ echo("Note Attachment File Type: " . $attachment->getType() . "\n");
+
+ //Get the seModule of each attachment
+ echo("Note Attachment seModule: " . $attachment->getSeModule() . "\n");
+
+ //Get the modifiedBy User instance of each attachment
+ $modifiedBy = $attachment->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Note Attachment Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Note Attachment Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Note Attachment Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the state of each attachment
+ echo("Note Attachment State: " . $attachment->getState() . "\n");
+
+ //Get the ID of each attachment
+ echo("Note Attachment ID: " . $attachment->getId() . "\n");
+
+ //Get the createdBy User instance of each attachment
+ $createdBy = $attachment->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the name of the createdBy User
+ echo("Note Attachment Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Note Attachment Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Note Attachment Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the linkUrl of each attachment
+ echo("Note Attachment LinkUrl: " . $attachment->getLinkUrl() . "\n");
+ }
+
+ /**
+ * Create Notes
+ * This method is used to add new notes and print the response.
+ * @throws Exception
+ */
+ public static function createNotes()
+ {
+ //Get instance of NotesOperations Class
+ $notesOperations = new NotesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Note instances
+ $notes = array();
+
+ for($i = 1; $i <= 5; $i++)
+ {
+ $nodeClass = 'com\zoho\crm\api\notes\Note';
+
+ //Get instance of Note Class
+ $note = new $nodeClass();
+
+ //Set Note_Title of the Note
+ $note->setNoteTitle("Contacted");
+
+ //Set NoteContent of the Note
+ $note->setNoteContent("Need to do further tracking");
+
+ //Get instance of Record Class
+ $parentRecord = new Record();
+
+ //Set ID of the Record
+ $parentRecord->setId("3477061000005702002");
+
+ //Set ParentId of the Note
+ $note->setParentId($parentRecord);
+
+ //Set SeModule of the Record
+ $note->setSeModule("Leads");
+
+ //Add Note instance to the list
+ array_push($notes, $note);
+ }
+
+ //Set the list to notes in BodyWrapper instance
+ $bodyWrapper->setData($notes);
+
+ //Call createNotes method that takes BodyWrapper instance as parameter
+ $response = $notesOperations->createNotes($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . " : ");
+
+ print_r($keyValue);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Notes
+ * This method is used to update an existing note and print the response.
+ * @throws Exception
+ */
+ public static function updateNotes()
+ {
+ //Get instance of NotesOperations Class
+ $notesOperations = new NotesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Note instances
+ $notes = array();
+
+ $noteClass = 'com\zoho\crm\api\notes\Note';
+
+ //Get instance of Note Class
+ $note = new $noteClass();
+
+ $note->setId("3477061000006154001");
+
+ //Set Note_Title of the Note
+ $note->setNoteTitle("Contacted12");
+
+ //Set NoteContent of the Note
+ $note->setNoteContent("Need to do further tracking12");
+
+ //Add Note instance to the list
+ array_push($notes, $note);
+
+ $note = new $noteClass();
+
+ $note->setId("3477061000006153004");
+
+ //Set Note_Title of the Note
+ $note->setNoteTitle("Contacted13");
+
+ //Set NoteContent of the Note
+ $note->setNoteContent("Need to do further tracking13");
+
+ //Add Note instance to the list
+ array_push($notes, $note);
+
+ //Set the list to notes in BodyWrapper instance
+ $bodyWrapper->setData($notes);
+
+ //Call updateNotes method that takes BodyWrapper instance as parameter
+ $response = $notesOperations->updateNotes($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . " : ");
+
+ print_r($keyValue);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * This method is used to delete notes in bulk and print the response.
+ * @param notesID - The ID of the record to delete notes
+ * @throws Exception
+ */
+ public static function deleteNotes(array $notesID)
+ {
+ //Get instance of NotesOperations Class
+ $notesOperations = new NotesOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($notesID as $id)
+ {
+ $paramInstance->add(DeleteNotesParam::ids(), $id);
+ }
+
+ //Call deleteNotes method that takes paramInstance as parameter
+ $response = $notesOperations->deleteNotes($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+
+ }
+
+ /**
+ * Get Note
+ * This method is used to get the note and print the response.
+ * @param noteId - The ID of the Note to be obtainted
+ * @throws Exception
+ */
+ public static function getNote(string $noteId)
+ {
+ //Get instance of NotesOperations Class
+ $notesOperations = new NotesOperations();
+
+ //Call getNote method
+ $response = $notesOperations->getNote($noteId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Note instances
+ $notes = $responseWrapper->getData();
+
+ foreach($notes as $note)
+ {
+ //Get the owner User instance of each Note
+ $owner = $note->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the name of the owner User
+ echo("Note Owner User-Name: " . $owner->getName() . "\n");
+
+ //Get the ID of the owner User
+ echo("Note Owner User-ID: " . $owner->getId() . "\n");
+
+ //Get the Email of the owner User
+ echo("Note Owner Email: " . $owner->getEmail() . "\n");
+ }
+
+ //Get the ModifiedTime of each Module
+ echo("Note ModifiedTime: ");
+
+ print_R($note->getModifiedTime());
+
+ echo("\n");
+
+ //Get the list of Attachment instance each Note
+ $attachments = $note->getAttachments();
+
+ //Check if attachments is not null
+ if($attachments != null)
+ {
+ foreach($attachments as $attachment)
+ {
+ self::printAttachment($attachment);
+ }
+ }
+
+ //Get the CreatedTime of each Note
+ echo("Note CreatedTime: ");
+
+ print_r($note->getCreatedTime());
+
+ echo("\n");
+
+ //Get the parentId Record instance of each Note
+ $parentId = $note->getParentId();
+
+ //Check if parentId is not null
+ if($parentId != null)
+ {
+ if($parentId->getKeyValue("name") != null)
+ {
+ //Get the parent record Name of each Note
+ echo("Note parent record Name: " . $parentId->getKeyValue("name") . "\n");
+ }
+
+ //Get the parent record ID of each Note
+ echo("Note parent record ID: " . $parentId->getId() . "\n");
+ }
+
+ //Get the Editable of each Note
+ echo("Note Editable: " . $note->getEditable() . "\n");
+
+ //Get the SeModule of each Note
+ echo("Note SeModule: " . $note->getSeModule() . "\n");
+
+ //Get the IsSharedToClient of each Note
+ echo("Note IsSharedToClient: " . $note->getIsSharedToClient() . "\n");
+
+ //Get the modifiedBy User instance of each Note
+ $modifiedBy = $note->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Note Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Note Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Note Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the Size of each Note
+ echo("Note Size: " . $note->getSize() . "\n");
+
+ //Get the State of each Note
+ echo("Note State: " . $note->getState() . "\n");
+
+ //Get the VoiceNote of each Note
+ echo("Note VoiceNote: " . $note->getVoiceNote() . "\n");
+
+ //Get the Id of each Note
+ echo("Note Id: " . $note->getId() . "\n");
+
+ //Get the createdBy User instance of each Note
+ $createdBy = $note->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("Note Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Note Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Note Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the NoteTitle of each Note
+ echo("Note NoteTitle: " . $note->getNoteTitle() . "\n");
+
+ //Get the NoteContent of each Note
+ echo("Note NoteContent: " . $note->getNoteContent() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Note
+ * This method is used to update an existing note and print the response.
+ * @param noteId - The ID of the Note to be obtainted
+ * @throws Exception
+ */
+ public static function updateNote(string $noteId)
+ {
+ //Get instance of NotesOperations Class
+ $notesOperations = new NotesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Note instances
+ $notes = array();
+
+ $nodeClass = 'com\zoho\crm\api\notes\Note';
+
+ $note = new $nodeClass();
+
+ //Set Note_Title of the Note
+ $note->setNoteTitle("Contacted12");
+
+ //Set NoteContent of the Note
+ $note->setNoteContent("Need to do further tracking12");
+
+ //Add Note instance to the list
+ array_push($notes, $note);
+
+ //Set the list to notes in BodyWrapper instance
+ $bodyWrapper->setData($notes);
+
+ //Call updateNote method that takes BodyWrapper instance and noteId as parameter
+ $response = $notesOperations->updateNote($noteId,$bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . " : ");
+
+ print_r($keyValue);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Note
+ * This method is used to delete single Note with ID and print the response.
+ * @param notesID - The ID of the Note to be deleted
+ * @throws Exception
+ */
+ public static function deleteNote(string $noteID)
+ {
+ //Get instance of NotesOperations Class
+ $notesOperations = new NotesOperations();
+
+ //Call deleteNotes method that takes BodyWrapper instance as parameter
+ $response = $notesOperations->deleteNote($noteID);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
diff --git a/samples/src/com/zoho/crm/api/notification/Notification.php b/samples/src/com/zoho/crm/api/notification/Notification.php
new file mode 100644
index 0000000..33a2cab
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/notification/Notification.php
@@ -0,0 +1,1075 @@
+ Enable Notifications
+ * This method is used to Enable Notifications and print the response.
+ * @throws Exception
+ */
+ public static function enableNotifications()
+ {
+ //Get instance of NotificationOperations Class
+ $notificationOperations = new NotificationOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Notification instances
+ $notifications = array();
+
+ $notificationClass = 'com\zoho\crm\api\notification\Notification';
+
+ //Get instance of Notification Class
+ $notification = new $notificationClass();
+
+ //Set channel Id of the Notification
+ $notification->setChannelId("100000006800211");
+
+ $events = array();
+
+ array_push($events, "Deals.all");
+
+ //To subscribe based on particular operations on given modules.
+ $notification->setEvents($events);
+
+ //To set the expiry time for instant notifications.
+ $notification->setChannelExpiry(date_create("2019-05-07T15:32:24")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
+
+ //To ensure that the notification is sent from Zoho CRM, by sending back the given value in notification URL body.
+ //By using this value, user can validate the notifications.
+ $notification->setToken("TOKEN_FOR_VERIFICATION_OF_1000000068002");
+
+ //URL to be notified (POST request)
+ $notification->setNotifyUrl("https://www.zohoapis.com");
+
+ //Add Notification instance to the list
+ array_push($notifications, $notification);
+
+ //Get instance of Notification Class
+ $notification2 = new $notificationClass();
+
+ //Set channel Id of the Notification
+ $notification2->setChannelId("100000006800211");
+
+ $events2 = array();
+
+ array_push($events2, "Accounts.all");
+
+ //To subscribe based on particular operations on given modules.
+ $notification2->setEvents($events2);
+
+ //To set the expiry time for instant notifications.
+ $dateTime = date_create("2019-05-07T15:32:24")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $notification2->setChannelExpiry($dateTime);
+
+ //To ensure that the notification is sent from Zoho CRM, by sending back the given value in notification URL body.
+ //By using this value, user can validate the notifications.
+ $notification2->setToken("TOKEN_FOR_VERIFICATION_OF_1000000068002");
+
+ //URL to be notified (POST request)
+ $notification2->setNotifyUrl("https://www.zohoapis.com");
+
+ //Add Notification instance to the list
+ array_push($notifications, $notification2);
+
+ //Set the list to notifications in BodyWrapper instance
+ $bodyWrapper->setWatch($notifications);
+
+ //Call enableNotifications method that takes BodyWrapper instance as parameter
+ $response = $notificationOperations->enableNotifications($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode());
+
+ //Check if expected response is received
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getWatch();
+
+ foreach ($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $keyName => $value)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ if($value[0] instanceof $notificationClass)
+ {
+ $eventList = $value;
+
+ foreach($eventList as $event)
+ {
+ //Get the ChannelExpiry of each Notification
+ echo("Notification ChannelExpiry: "); print_r($event->getChannelExpiry());
+
+ //Get the ResourceUri each Notification
+ echo("Notification ResourceUri: " . $event->getResourceUri() . "\n");
+
+ //Get the ResourceId each Notification
+ echo("Notification ResourceId: " . $event->getResourceId() . "\n");
+
+ //Get the ResourceName each Notification
+ echo("Notification ResourceName: " . $event->getResourceName() . "\n");
+
+ //Get the ChannelId each Notification
+ echo("Notification ChannelId: " . $event->getChannelId() . "\n");
+ }
+ }
+ }
+ else
+ {
+ //Get each value in the map
+ echo($keyName . ": "); print_r($value);
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {//If response is not as expected
+
+ //Get model object from response
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Get Notification Details
+ * This method is used to get all the Notification and print the response.
+ * @throws Exception
+ */
+ public static function getNotificationDetails()
+ {
+ //Get instance of NotificationOperations Class
+ $notificationOperations = new NotificationOperations();
+
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetNotificationDetailsParam::channelId(), "100000006800211");
+
+ $paramInstance->add(GetNotificationDetailsParam::module(), "Accounts");
+
+ $paramInstance->add(GetNotificationDetailsParam::page(), 1);
+
+ $paramInstance->add(GetNotificationDetailsParam::perPage(), 2);
+
+ //Call getNotificationDetails method
+ $response = $notificationOperations->getNotificationDetails($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Check if expected response is received
+ if($response->isExpected())
+ {
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Notification instances
+ $notifications = $responseWrapper->getWatch();
+
+ foreach($notifications as $notification)
+ {
+ //Get the NotifyOnRelatedAction of each Notification
+ echo("Notification NotifyOnRelatedAction: " . $notification->getNotifyOnRelatedAction() . "\n");
+
+ //Get the ChannelExpiry of each Notification
+ echo("Notification ChannelExpiry: "); print_r($notification->getChannelExpiry());
+
+ //Get the ResourceUri each Notification
+ echo("Notification ResourceUri: " . $notification->getResourceUri() . "\n");
+
+ //Get the ResourceId each Notification
+ echo("Notification ResourceId: " . $notification->getResourceId() . "\n");
+
+ //Get the NotifyUrl each Notification
+ echo("Notification NotifyUrl: " . $notification->getNotifyUrl() . "\n");
+
+ //Get the ResourceName each Notification
+ echo("Notification ResourceName: " . $notification->getResourceName() . "\n");
+
+ //Get the ChannelId each Notification
+ echo("Notification ChannelId: " . $notification->getChannelId() . "\n");
+
+ //Get the events List of each Notification
+ $fields = $notification->getEvents();
+
+ //Check if fields is not null
+ if($fields != null)
+ {
+ foreach($fields as $fieldName)
+ {
+ //Get the Events
+ echo("Notification Events: " . $fieldName . "\n");
+ }
+ }
+
+ //Get the Token each Notification
+ echo("Notification Token: " . $notification->getToken() . "\n");
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getPerPage() != null)
+ {
+ //Get the PerPage of the Info
+ echo("Record Info PerPage: " . $info->getPerPage() . "\n");
+ }
+
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("Record Info Count: " . $info->getCount() . "\n");
+ }
+
+ if($info->getPage() != null)
+ {
+ //Get the Page of the Info
+ echo("Record Info Page: " . $info->getPage() . "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the MoreRecords of the Info
+ echo("Record Info MoreRecords: " . $info->getMoreRecords() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else if($response->getStatusCode() != 204 )
+ {//If response is not as expected
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Update Notifications
+ * This method is used to update Notifications and print the response.
+ * @throws Exception
+ */
+ public static function updateNotifications()
+ {
+ //Get instance of NotificationOperations Class
+ $notificationOperations = new NotificationOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Notification instances
+ $notificationList = array();
+
+ $notificationClass = 'com\zoho\crm\api\notification\Notification';
+
+ //Get instance of Notification Class
+ $notification = new $notificationClass();
+
+ //Set ChannelId to the Notification instance
+ $notification->setChannelId("100000006800211");
+
+ $events = array();
+
+ array_push($events, "Accounts.all");
+
+ //To subscribe based on particular operations on given modules.
+ $notification->setEvents($events);
+
+ //Set name to the Notification instance
+ $notification->setChannelExpiry(date_create("2021-02-26T15:28:34+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
+
+ //To ensure that the notification is sent from Zoho CRM, by sending back the given value in notification URL body.
+ //By using this value, user can validate the notifications.
+ $notification->setToken("TOKEN_FOR_VERIFICATION_OF_1000000068002");
+
+ //URL to be notified (POST request)
+ $notification->setNotifyUrl("https://www.zohoapis.com");
+
+ //Add Notification instance to the list
+ array_push($notificationList, $notification);
+
+ //Set the list to notification in BodyWrapper instance
+ $bodyWrapper->setWatch($notificationList);
+
+ //Call updateNotifications method that takes BodyWrapper instance as parameter
+ $response = $notificationOperations->updateNotifications($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode());
+
+ //Check if expected response is received
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getWatch();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue());
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue());
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $keyName => $value)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ if($value[0] instanceof $notificationClass)
+ {
+ $eventList = $value;
+
+ foreach($eventList as $event)
+ {
+ //Get the ChannelExpiry of each Notification
+ echo("Notification ChannelExpiry: "); print_r($event->getChannelExpiry());
+
+ //Get the ResourceUri each Notification
+ echo("Notification ResourceUri: " . $event->getResourceUri() . "\n");
+
+ //Get the ResourceId each Notification
+ echo("Notification ResourceId: " . $event->getResourceId() . "\n");
+
+ //Get the ResourceName each Notification
+ echo("Notification ResourceName: " . $event->getResourceName() . "\n");
+
+ //Get the ChannelId each Notification
+ echo("Notification ChannelId: " . $event->getChannelId() . "\n");
+ }
+ }
+ }
+ else
+ {
+ //Get each value in the map
+ echo($keyName . ": "); print_r($value);
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {//If response is not as expected
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Update Specific Information of a Notification
+ * This method is used to update single Notification and print the response.
+ * @throws Exception
+ */
+ public static function updateNotification()
+ {
+ //Get instance of NotificationOperations Class
+ $notificationOperations = new NotificationOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Notification instances
+ $notificationList = array();
+
+ //Get instance of Notification Class
+
+ $notificationClass = 'com\zoho\crm\api\notification\Notification';
+
+ $notification = new $notificationClass();
+
+ //Set ChannelId to the Notification instance
+ $notification->setChannelId("100000006800212");
+
+ $events = array();
+
+ array_push($events, "Deals.all");
+
+ //To subscribe based on particular operations on given modules.
+ $notification->setEvents($events);
+
+ //Set name to the Notification instance
+ $notification->setChannelExpiry(date_create("2021-02-26T15:28:34+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
+
+ //To ensure that the notification is sent from Zoho CRM, by sending back the given value in notification URL body.
+ //By using this value, user can validate the notifications.
+ $notification->setToken("TOKEN_FOR_VERIFICATION_OF_1000000068002");
+
+ //URL to be notified (POST request)
+ $notification->setNotifyUrl("https://www.zohoapis.com");
+
+ //Add Notification instance to the list
+ array_push($notificationList, $notification);
+
+ //Set the list to notification in BodyWrapper instance
+ $bodyWrapper->setWatch($notificationList);
+
+ //Call updateNotification method that takes BodyWrapper instance as parameters
+ $response = $notificationOperations->updateNotification($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Check if expected response is received
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getWatch();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: \n");
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $keyName => $value)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ if($value[0] instanceof $notificationClass)
+ {
+ $eventList = $value;
+
+ foreach($eventList as $event)
+ {
+ //Get the ChannelExpiry of each Notification
+ echo("Notification ChannelExpiry: "); print_r($event->getChannelExpiry());
+
+ //Get the ResourceUri each Notification
+ echo("Notification ResourceUri: " . $event->getResourceUri() . "\n");
+
+ //Get the ResourceId each Notification
+ echo("Notification ResourceId: " . $event->getResourceId() . "\n");
+
+ //Get the ResourceName each Notification
+ echo("Notification ResourceName: " . $event->getResourceName() . "\n");
+
+ //Get the ChannelId each Notification
+ echo("Notification ChannelId: " . $event->getChannelId() . "\n");
+ }
+ }
+ }
+ else
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $value);
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue());
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue());
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue());
+ }
+ }
+ else
+ {//If response is not as expected
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Disable Notifications
+ * To stop all the instant notifications enabled by the user for a channel.
+ * @param channelIds - Specify the unique IDs of the notification channels to be disabled.
+ * @throws Exception
+ */
+ public static function disableNotifications(array $channelIds)
+ {
+ //example
+ //$channelIds = array(3477061000005208001);
+
+ //Get instance of NotificationOperations Class
+ $notificationOperations = new NotificationOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($channelIds as $id)
+ {
+ $paramInstance->add(DisableNotificationsParam::channelIds(), $id);
+ }
+
+ //Call disableNotifications method that takes paramInstance as parameter
+ $response = $notificationOperations->disableNotifications($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode());
+
+ //Check if expected response is received
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained Notification instances
+ $actionResponses = $actionWrapper->getWatch();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {//If response is not as expected
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Disable Specific Notifications
+ * This method is used to disable notifications for the specified events in a channel.
+ * @throws Exception
+ */
+ public static function disableNotification()
+ {
+ //Get instance of NotificationOperations Class
+ $notificationOperations = new NotificationOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Notification instances
+ $notificationList = array();
+
+ //Get instance of Notification Class
+ $notificationClass = 'com\zoho\crm\api\notification\Notification';
+
+ $notification = new $notificationClass();
+
+ //Set ChannelId to the Notification instance
+ $notification->setChannelId("100000006800211");
+
+ $events = array();
+
+ array_push($events, "Deals.edit");
+
+ //To subscribe based on particular operations on given modules.
+ $notification->setEvents($events);
+
+ $notification->setDeleteevents(true);
+
+ //Add Notification instance to the list
+ array_push($notificationList, $notification);
+
+ //Set the list to notification in BodyWrapper instance
+ $bodyWrapper->setWatch($notificationList);
+
+ //Call disableNotification which takes BodyWrapper instance as parameter
+ $response = $notificationOperations->disableNotification($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Check if expected response is received
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getWatch();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {//If response is not as expected
+ print_r($response);
+ }
+ }
+ }
+}
diff --git a/samples/src/com/zoho/crm/api/organization/Organization.php b/samples/src/com/zoho/crm/api/organization/Organization.php
new file mode 100644
index 0000000..15ad94e
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/organization/Organization.php
@@ -0,0 +1,280 @@
+ Get Organization
+ * This method is used to get the organization data and print the response.
+ * @throws Exception
+ */
+ public static function getOrganization()
+ {
+ //Get instance of OrgOperations Class
+ $orgOperations = new OrgOperations();
+
+ //Call getNotes method
+ $response = $orgOperations->getOrganization();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Note instances
+ $orgs = $responseWrapper->getOrg();
+
+ foreach($orgs as $org)
+ {
+ //Get the Country of each Organization
+ echo("Organization Country: " . $org->getCountry() . "\n");
+
+ //Get the PhotoId of each Organization
+ echo("Organization PhotoId: " . $org->getPhotoId() . "\n");
+
+ //Get the City of each Organization
+ echo("Organization City: " . $org->getCity() . "\n");
+
+ //Get the Description of each Organization
+ echo("Organization Description: " . $org->getDescription() . "\n");
+
+ //Get the McStatus of each Organization
+ echo("Organization McStatus: " . $org->getMcStatus() . "\n");
+
+ //Get the GappsEnabled of each Organization
+ echo("Organization GappsEnabled: " . $org->getGappsEnabled() . "\n");
+
+ //Get the DomainName of each Organization
+ echo("Organization DomainName: " . $org->getDomainName() . "\n");
+
+ //Get the TranslationEnabled of each Organization
+ echo("Organization TranslationEnabled: " . $org->getTranslationEnabled() . "\n");
+
+ //Get the Street of each Organization
+ echo("Organization Street: " . $org->getStreet() . "\n");
+
+ //Get the Alias of each Organization
+ echo("Organization Alias: " . $org->getAlias() . "\n");
+
+ //Get the Currency of each Organization
+ echo("Organization Currency: " . $org->getCurrency() . "\n");
+
+ //Get the Id of each Organization
+ echo("Organization Id: " . $org->getId() . "\n");
+
+ //Get the State of each Organization
+ echo("Organization State: " . $org->getState() . "\n");
+
+ //Get the Fax of each Organization
+ echo("Organization Fax: " . $org->getFax() . "\n");
+
+ //Get the EmployeeCount of each Organization
+ echo("Organization EmployeeCount: " . $org->getEmployeeCount() . "\n");
+
+ //Get the Zip of each Organization
+ echo("Organization Zip: " . $org->getZip() . "\n");
+
+ //Get the Website of each Organization
+ echo("Organization Website: " . $org->getWebsite() . "\n");
+
+ //Get the CurrencySymbol of each Organization
+ echo("Organization CurrencySymbol: " . $org->getCurrencySymbol() . "\n");
+
+ //Get the Mobile of each Organization
+ echo("Organization Mobile: " . $org->getMobile() . "\n");
+
+ //Get the CurrencyLocale of each Organization
+ echo("Organization CurrencyLocale: " . $org->getCurrencyLocale() . "\n");
+
+ //Get the PrimaryZuid of each Organization
+ echo("Organization PrimaryZuid: " . $org->getPrimaryZuid() . "\n");
+
+ //Get the ZiaPortalId of each Organization
+ echo("Organization ZiaPortalId: " . $org->getZiaPortalId() . "\n");
+
+ //Get the TimeZone of each Organization
+ echo("Organization TimeZone: " . $org->getTimeZone() . "\n");
+
+ //Get the Zgid of each Organization
+ echo("Organization Zgid: " . $org->getZgid() . "\n");
+
+ //Get the CountryCode of each Organization
+ echo("Organization CountryCode: " . $org->getCountryCode() . "\n");
+
+ //Get the Object obtained LicenseDetails instance
+ $licenseDetails = $org->getLicenseDetails();
+
+ //Check if licenseDetails is not null
+ if($licenseDetails != null)
+ {
+ //Get the PaidExpiry of each LicenseDetails
+ echo("Organization LicenseDetails PaidExpiry: ");
+
+ print_r($licenseDetails->getPaidExpiry());
+
+ echo("\n");
+
+ //Get the UsersLicensePurchased of each LicenseDetails
+ echo("Organization LicenseDetails UsersLicensePurchased: " . $licenseDetails->getUsersLicensePurchased() . "\n");
+
+ //Get the TrialType of each LicenseDetails
+ echo("Organization LicenseDetails TrialType: " . $licenseDetails->getTrialType() . "\n");
+
+ //Get the TrialExpiry of each LicenseDetails
+ echo("Organization LicenseDetails TrialExpiry: " . $licenseDetails->getTrialExpiry() . "\n");
+
+ //Get the Paid of each LicenseDetails
+ echo("Organization LicenseDetails Paid: " . $licenseDetails->getPaid() . "\n");
+
+ //Get the PaidType of each LicenseDetails
+ echo("Organization LicenseDetails PaidType: " . $licenseDetails->getPaidType() . "\n");
+ }
+
+ //Get the Phone of each Organization
+ echo("Organization Phone: " . $org->getPhone() . "\n");
+
+ //Get the CompanyName of each Organization
+ echo("Organization CompanyName: " . $org->getCompanyName() . "\n");
+
+ //Get the PrivacySettings of each Organization
+ echo("Organization PrivacySettings: " . $org->getPrivacySettings() . "\n");
+
+ //Get the PrimaryEmail of each Organization
+ echo("Organization PrimaryEmail: " . $org->getPrimaryEmail() . "\n");
+
+ //Get the IsoCode of each Organization
+ echo("Organization IsoCode: " . $org->getIsoCode() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Upload Organization Photo
+ * This method is used to upload the brand logo or image of the organization and print the response.
+ * @param absoluteFilePath - The absolute file path of the file to be attached
+ * @throws Exception
+ */
+ public static function uploadOrganizationPhoto(string $absoluteFilePath)
+ {
+ //Get instance of OrgOperations Class
+ $orgOperations = new OrgOperations();
+
+ //Get instance of FileBodyWrapper class that will contain the request file
+ $fileBodyWrapper = new FileBodyWrapper();
+
+ //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
+ $streamWrapper = new StreamWrapper(null, null, $absoluteFilePath);
+
+ //Set file to the FileBodyWrapper instance
+ $fileBodyWrapper->setFile($streamWrapper);
+
+ //Call uploadOrganizationPhoto method that takes FileBodyWrapper instance
+ $response = $orgOperations->uploadOrganizationPhoto($fileBodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionResponse = $response->getObject();
+
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/profile/Profile.php b/samples/src/com/zoho/crm/api/profile/Profile.php
new file mode 100644
index 0000000..4e80af9
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/profile/Profile.php
@@ -0,0 +1,352 @@
+ Get Profiles
+ * This method is used to retrieve the data of profiles through an API request and print the response.
+ * @throws Exception
+ */
+ public static function getProfiles()
+ {
+ //example
+ //moduleAPIName = "Leads";
+
+ //Get instance of ProfilesOperations Class
+ $profilesOperations = new ProfilesOperations();
+
+ //Call getProfiles method
+ $response = $profilesOperations->getProfiles();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Profile instances
+ $profiles = $responseWrapper->getProfiles();
+
+ foreach($profiles as $profile)
+ {
+ //Get the DisplayLabel of the each Profile
+ echo("Profile DisplayLabel: " . $profile->getDisplayLabel() . "\n");
+
+ if($profile->getCreatedTime() != null)
+ {
+ //Get the CreatedTime of each Profile
+ echo("Profile CreatedTime: ");
+ print_r($profile->getCreatedTime());
+ echo("\n");
+ }
+
+ if($profile->getModifiedTime() != null)
+ {
+ //Get the ModifiedTime of each Profile
+ echo("Profile ModifiedTime: ");
+ print_r($profile->getModifiedTime());
+ echo("\n");
+ }
+
+ //Get the Name of the each Profile
+ echo("Profile Name: " . $profile->getName() . "\n");
+
+ //Get the modifiedBy User instance of each Profile
+ $modifiedBy = $profile->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("Profile Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("Profile Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Profile Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the Description of the each Profile
+ echo("Profile Description: " . $profile->getDescription() . "\n");
+
+ //Get the ID of the each Profile
+ echo("Profile ID: " . $profile->getId() . "\n");
+
+ //Get the Category of the each Profile
+ echo("Profile Category: " . $profile->getCategory() . "\n");
+
+ //Get the createdBy User instance of each Profile
+ $createdBy = $profile->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("Profile Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("Profile Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Profile Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * 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
+ */
+ public static function getProfile(string $profileId)
+ {
+ //example
+ //moduleAPIName = "Leads";
+
+ //Get instance of ProfilesOperations Class
+ $profilesOperations = new ProfilesOperations();
+
+ //Call getProfile method that takes profileId as parameter
+ $response = $profilesOperations->getProfile($profileId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Profile instances
+ $profiles = $responseWrapper->getProfiles();
+
+ foreach($profiles as $profile)
+ {
+ //Get the DisplayLabel of the each Profile
+ echo("Profile DisplayLabel: " . $profile->getDisplayLabel() . "\n");
+
+ if($profile->getCreatedTime() != null)
+ {
+ //Get the CreatedTime of each Profile
+ echo("Profile CreatedTime: ");
+ print_r($profile->getCreatedTime());
+ echo("\n");
+ }
+
+ if($profile->getModifiedTime() != null)
+ {
+ //Get the CreatedTime of each Profile
+ echo("Profile CreatedTime: ");
+ print_r($profile->getModifiedTime());
+ echo("\n");
+ }
+
+ //Get the permissionsDetails of each Profile
+ $permissionsDetails = $profile->getPermissionsDetails();
+
+ //Check if permissionsDetails is not null
+ if($permissionsDetails != null)
+ {
+ foreach($permissionsDetails as $permissionsDetail)
+ {
+ //Get the DisplayLabel of the each PermissionDetail
+ echo("Profile PermissionDetail DisplayLabel: " . $permissionsDetail->getDisplayLabel() . "\n");
+
+ //Get the Module of the each PermissionDetail
+ echo("Profile PermissionDetail Module: " . $permissionsDetail->getModule() . "\n");
+
+ //Get the Name of the each PermissionDetail
+ echo("Profile PermissionDetail Name: " . $permissionsDetail->getName() . "\n");
+
+ //Get the ID of the each PermissionDetail
+ echo("Profile PermissionDetail ID: " . $permissionsDetail->getId() . "\n");
+
+ //Get the Enabled of the each PermissionDetail
+ echo("Profile PermissionDetail Enabled: " . $permissionsDetail->getEnabled() . "\n");
+ }
+ }
+
+ //Get the Name of the each Profile
+ echo("Profile Name: " . $profile->getName() . "\n");
+
+ //Get the modifiedBy User instance of each Profile
+ $modifiedBy = $profile->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("Profile Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("Profile Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Profile Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the Description of the each Profile
+ echo("Profile Description: " . $profile->getDescription() . "\n");
+
+ //Get the ID of the each Profile
+ echo("Profile ID: " . $profile->getId() . "\n");
+
+ //Get the Category of the each Profile
+ echo("Profile Category: " . $profile->getCategory() . "\n");
+
+ //Get the createdBy User instance of each Profile
+ $createdBy = $profile->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("Profile Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("Profile Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Profile Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the sections of each Profile
+ $sections = $profile->getSections();
+
+ //Check if sections is not null
+ if($sections != null)
+ {
+ foreach($sections as $section)
+ {
+ //Get the Name of the each Section
+ echo("Profile Section Name: " . $section->getName() . "\n");
+
+ //Get the categories of each Section
+ $categories = $section->getCategories();
+
+ foreach($categories as $category)
+ {
+ //Get the DisplayLabel of the each Category
+ echo("Profile Section Category DisplayLabel: " . $category->getDisplayLabel() . "\n");
+
+ //Get the permissionsDetails List of each Category
+ $categoryPermissionsDetails = $category->getPermissionsDetails();
+
+ //Check if categoryPermissionsDetails is not null
+ if($categoryPermissionsDetails != null)
+ {
+ foreach($categoryPermissionsDetails as $permissionsDetailID)
+ {
+ //Get the permissionsDetailID of the Category
+ echo("Profile Section Category permissionsDetailID: " . $permissionsDetailID . "\n");
+ }
+ }
+
+ //Get the Name of the each Category
+ echo("Profile Section Category Name: " . $category->getName() . "\n");
+ }
+ }
+ }
+
+ if($profile->getDelete() != null)
+ {
+ //Get the Delete of the each Profile
+ echo("Profile Delete: " . $profile->getDelete() . "\n");
+ }
+
+ if($profile->getDefault() != null)
+ {
+ //Get the Default of the each Profile
+ echo("Profile Default: " . $profile->getDefault() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/query/Query.php b/samples/src/com/zoho/crm/api/query/Query.php
new file mode 100644
index 0000000..eb7eb24
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/query/Query.php
@@ -0,0 +1,192 @@
+ Get Records
+ * This method is used to get records from the module through a COQL query.
+ * @throws Exception
+ */
+ public static function getRecords()
+ {
+ //Get instance of QueryOperations Class
+ $queryOperations = new QueryOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ $selectQuery = "select Last_Name from Leads where Last_Name is not null limit 200";
+
+ $bodyWrapper->setSelectQuery($selectQuery);
+
+ //Call getRecords method that takes BodyWrapper instance as parameter
+ $response = $queryOperations->getRecords($bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Check if expected response is received
+ if($response->isExpected())
+ {
+ //Get the object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Record instances
+ $records = $responseWrapper->getData();
+
+ foreach($records as $record)
+ {
+ //Get the ID of each Record
+ echo("Record ID: " . $record->getId() . "\n");
+
+ //Get the createdBy User instance of each Record
+ $createdBy = $record->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("Record Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("Record Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Record Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the CreatedTime of each Record
+ echo("Record CreatedTime: " . $record->getCreatedTime() . "\n");
+
+ //Get the modifiedBy User instance of each Record
+ $modifiedBy = $record->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("Record Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("Record Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Record Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the ModifiedTime of each Record
+ echo("Record ModifiedTime: " . $record->getModifiedTime() . "\n");
+
+ //To get particular field value
+ echo("Record Field Value: " . $record->getKeyValue("Last_Name") . "\n");// FieldApiName
+
+ echo("Record KeyValues: \n");
+
+ //Get the KeyValue map
+ foreach($record->getKeyValues() as $keyName => $value)
+ {
+ if($value != null)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ echo("Record KeyName : " . $keyName . "\n");
+
+ $dataList = $value;
+
+ foreach($dataList as $data)
+ {
+ if(is_array($data))
+ {
+ echo("Record KeyName : " . $keyName . " - Value : \n");
+
+ foreach($data as $key => $arrayValue)
+ {
+ echo($key . " : " . $arrayValue);
+ }
+ }
+ else
+ {
+ print_r($data); echo("\n");
+ }
+ }
+ }
+ else
+ {
+ echo("Record KeyName : " . $keyName . " - Value : " . print_r($value));
+ }
+ }
+ }
+ }
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("Record Info Count: " . $info->getCount() . "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the MoreRecords of the Info
+ echo("Record Info MoreRecords: " . $info->getMoreRecords() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {//If response is not as expected
+ print_r($response);
+ }
+ }
+ }
+}
+
diff --git a/samples/src/com/zoho/crm/api/record/Record.php b/samples/src/com/zoho/crm/api/record/Record.php
new file mode 100644
index 0000000..609392f
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/record/Record.php
@@ -0,0 +1,4242 @@
+ Get Record
+ * This method is used to get a single record of a module with ID and print the response.
+ * @param moduleAPIName - The API Name of the record's module.
+ * @param recordId - The ID of the record to be obtained.
+ * @param destinationFolder - The absolute path of the destination folder to store the attachment
+ * @throws Exception
+ */
+ public static function getRecord(string $moduleAPIName, string $recordId, string $destinationFolder)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ // $paramInstance->add(GetRecordParam::approved(), "false");
+
+ // $paramInstance->add(GetRecordParam::converted(), "false");
+
+ // $fieldNames = array("Deal_Name", "Company");
+
+ // foreach($fieldNames as $fieldName)
+ // {
+ // $paramInstance->add(GetRecordParam::fields(), $fieldName);
+ // }
+
+ // $startdatetime = date_create("2020-06-27T15:10:00");
+
+ // $paramInstance->add(GetRecordParam::startDateTime(), $startdatetime);
+
+ // $enddatetime = date_create("2020-06-29T15:10:00");
+
+ // $paramInstance->add(GetRecordParam::endDateTime(), $enddatetime);
+
+ // $paramInstance->add(GetRecordParam::territoryId(), "3477061000003051357");
+
+ // $paramInstance->add(GetRecordParam::includeChild(), true);
+
+ $headerInstance = new HeaderMap();
+
+ // $ifmodifiedsince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ // $headerInstance->add(GetRecordHeader::IfModifiedSince(), $ifmodifiedsince);
+
+ //Call getRecord method that takes paramInstance, moduleAPIName and recordID as parameter
+ $response = $recordOperations->getRecord( $recordId,$moduleAPIName,$paramInstance, $headerInstance, );
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Record instances
+ $records = $responseWrapper->getData();
+
+ if($records != null)
+ {
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ foreach($records as $record)
+ {
+ //Get the ID of each Record
+ echo("Record ID: " . $record->getId() . "\n");
+
+ //Get the createdBy User instance of each Record
+ $createdBy = $record->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("Record Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("Record Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Record Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the CreatedTime of each Record
+ echo("Record CreatedTime: ");
+
+ print_r($record->getCreatedTime());
+
+ echo("\n");
+
+ //Get the modifiedBy User instance of each Record
+ $modifiedBy = $record->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("Record Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("Record Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Record Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the ModifiedTime of each Record
+ echo("Record ModifiedTime: ");
+
+ print_r($record->getModifiedTime());
+
+ print_r("\n");
+
+ //Get the list of Tag instance each Record
+ $tags = $record->getTag();
+
+ //Check if tags is not null
+ if($tags != null)
+ {
+ foreach($tags as $tag)
+ {
+ //Get the Name of each Tag
+ echo("Record Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("Record Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+
+ //To get particular field value
+ echo("Record Field Value: " . $record->getKeyValue("Last_Name") . "\n");// FieldApiName
+
+ echo("Record KeyValues : \n" );
+
+ //Get the KeyValue map
+ foreach($record->getKeyValues() as $keyName => $value)
+ {
+ if($value != null)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ if($value[0] instanceof FileDetails)
+ {
+ $fileDetails = $value;
+
+ foreach($fileDetails as $fileDetail)
+ {
+ //Get the Extn of each FileDetails
+ echo("Record FileDetails Extn: " . $fileDetail->getExtn() . "\n");
+
+ //Get the IsPreviewAvailable of each FileDetails
+ echo("Record FileDetails IsPreviewAvailable: " . $fileDetail->getIsPreviewAvailable() . "\n");
+
+ //Get the DownloadUrl of each FileDetails
+ echo("Record FileDetails DownloadUrl: " . $fileDetail->getDownloadUrl() . "\n");
+
+ //Get the DeleteUrl of each FileDetails
+ echo("Record FileDetails DeleteUrl: " . $fileDetail->getDeleteUrl() . "\n");
+
+ //Get the EntityId of each FileDetails
+ echo("Record FileDetails EntityId: " . $fileDetail->getEntityId() . "\n");
+
+ //Get the Mode of each FileDetails
+ echo("Record FileDetails Mode: " . $fileDetail->getMode() . "\n");
+
+ //Get the OriginalSizeByte of each FileDetails
+ echo("Record FileDetails OriginalSizeByte: " . $fileDetail->getOriginalSizeByte() . "\n");
+
+ //Get the PreviewUrl of each FileDetails
+ echo("Record FileDetails PreviewUrl: " . $fileDetail->getPreviewUrl() . "\n");
+
+ //Get the FileName of each FileDetails
+ echo("Record FileDetails FileName: " . $fileDetail->getFileName() . "\n");
+
+ //Get the FileId of each FileDetails
+ echo("Record FileDetails FileId: " . $fileDetail->getFileId() . "\n");
+
+ //Get the AttachmentId of each FileDetails
+ echo("Record FileDetails AttachmentId: " . $fileDetail->getAttachmentId() . "\n");
+
+ //Get the FileSize of each FileDetails
+ echo("Record FileDetails FileSize: " . $fileDetail->getFileSize() . "\n");
+
+ //Get the CreatorId of each FileDetails
+ echo("Record FileDetails CreatorId: " . $fileDetail->getCreatorId() . "\n");
+
+ //Get the LinkDocs of each FileDetails
+ echo("Record FileDetails LinkDocs: " . $fileDetail->getLinkDocs() . "\n");
+ }
+ }
+ else if($value[0] instanceof Choice)
+ {
+ $choice = $value;
+
+ foreach($choice as $choiceValue)
+ {
+ echo("Record " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ }
+ else if($value[0] instanceof InventoryLineItems)
+ {
+ $productDetails = $value;
+
+ foreach($productDetails as $productDetail)
+ {
+ $lineItemProduct = $productDetail->getProduct();
+
+ if($lineItemProduct != null)
+ {
+ echo("Record ProductDetails LineItemProduct ProductCode: " . $lineItemProduct->getProductCode() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Currency: " . $lineItemProduct->getCurrency() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Name: " . $lineItemProduct->getName() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Id: " . $lineItemProduct->getId() . "\n");
+ }
+
+ echo("Record ProductDetails Quantity: " . $productDetail->getQuantity() . "\n");
+
+ echo("Record ProductDetails Discount: " . $productDetail->getDiscount() . "\n");
+
+ echo("Record ProductDetails TotalAfterDiscount: " . $productDetail->getTotalAfterDiscount() . "\n");
+
+ echo("Record ProductDetails NetTotal: " . $productDetail->getNetTotal() . "\n");
+
+ if($productDetail->getBook() != null)
+ {
+ echo("Record ProductDetails Book: " . $productDetail->getBook() . "\n");
+ }
+
+ echo("Record ProductDetails Tax: " . $productDetail->getTax() . "\n");
+
+ echo("Record ProductDetails ListPrice: " . $productDetail->getListPrice() . "\n");
+
+ echo("Record ProductDetails UnitPrice: " . $productDetail->getUnitPrice() . "\n");
+
+ echo("Record ProductDetails QuantityInStock: " . $productDetail->getQuantityInStock() . "\n");
+
+ echo("Record ProductDetails Total: " . $productDetail->getTotal() . "\n");
+
+ echo("Record ProductDetails ID: " . $productDetail->getId() . "\n");
+
+ echo("Record ProductDetails ProductDescription: " . $productDetail->getProductDescription() . "\n");
+
+ $lineTaxes = $productDetail->getLineTax();
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("Record ProductDetails LineTax Percentage: " . $lineTax->getPercentage() . "\n");
+
+ echo("Record ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("Record ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("Record ProductDetails LineTax Value: " . $lineTax->getValue() . "\n");
+ }
+ }
+ }
+ else if($value[0] instanceof Tag)
+ {
+ $tagList = $value;
+
+ foreach($tagList as $tag)
+ {
+ //Get the Name of each Tag
+ echo("Record Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("Record Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof PricingDetails)
+ {
+ $pricingDetails = $value;
+
+ foreach($pricingDetails as $pricingDetail)
+ {
+ echo("Record PricingDetails ToRange: " . $pricingDetail->getToRange(). "\n");
+
+ echo("Record PricingDetails Discount: " . $pricingDetail->getDiscount(). "\n");
+
+ echo("Record PricingDetails ID: " . $pricingDetail->getId() . "\n");
+
+ echo("Record PricingDetails FromRange: " . $pricingDetail->getFromRange(). "\n");
+ }
+ }
+ else if($value[0] instanceof Participants)
+ {
+ $participants = $value;
+
+ foreach($participants as $participant)
+ {
+ echo("RelatedRecord Participants Name: " . $participant->getName() . "\n");
+
+ echo("RelatedRecord Participants Invited: " . $participant->getInvited() . "\n");
+
+ echo("RelatedRecord Participants ID: " . $participant->getId() . "\n");
+
+ echo("RelatedRecord Participants Type: " . $participant->getType() . "\n");
+
+ echo("RelatedRecord Participants Participant: " . $participant->getParticipant() . "\n");
+
+ echo("RelatedRecord Participants Status: " . $participant->getStatus() . "\n");
+ }
+ }
+ else if($value[0] instanceof $recordClass)
+ {
+ $recordList = $value;
+
+ foreach($recordList as $record1)
+ {
+ //Get the details map
+ foreach($record1->getKeyValues() as $key => $value1)
+ {
+ //Get each value in the map
+ echo($key . " : " );
+
+ print_r($value1);
+
+ echo("\n");
+ }
+ }
+ }
+ else if($value[0] instanceof LineTax)
+ {
+ $lineTaxes = $value;
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("Record ProductDetails LineTax Percentage: " . $lineTax->getPercentage(). "\n");
+
+ echo("Record ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("Record ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("Record ProductDetails LineTax Value: " . $lineTax->getValue(). "\n");
+ }
+ }
+ else if($value[0] instanceof Comment)
+ {
+ $comments = $value;
+
+ foreach($comments as $comment)
+ {
+ echo("Record Comment CommentedBy: " . $comment->getCommentedBy() . "\n");
+
+ echo("Record Comment CommentedTime: ");
+
+ print_r($comment->getCommentedTime());
+
+ echo("\n");
+
+ echo("Record Comment CommentContent: " . $comment->getCommentContent(). "\n");
+
+ echo("Record Comment Id: " . $comment->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof Attachment)
+ {
+ $attachments = $value;
+
+ foreach ($attachments as $attachment)
+ {
+ //Get the owner User instance of each attachment
+ $owner = $attachment->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the Name of the Owner
+ echo("Record Attachment Owner User-Name: " . $owner->getName() . "\n");
+
+ //Get the ID of the Owner
+ echo("Record Attachment Owner User-ID: " . $owner->getId() . "\n");
+
+ //Get the Email of the Owner
+ echo("Record Attachment Owner User-Email: " . $owner->getEmail() . "\n");
+ }
+
+ //Get the modified time of each attachment
+ echo("Record Attachment Modified Time: ");
+
+ print_r($attachment->getModifiedTime());
+
+ echo("\n");
+
+ //Get the name of the File
+ echo("Record Attachment File Name: " . $attachment->getFileName() . "\n");
+
+ //Get the created time of each attachment
+ echo("Record Attachment Created Time: " );
+
+ print_r($attachment->getCreatedTime());
+
+ echo("\n");
+
+ //Get the Attachment file size
+ echo("Record Attachment File Size: " . $attachment->getSize() . "\n");
+
+ //Get the parentId Record instance of each attachment
+ $parentId = $attachment->getParentId();
+
+ //Check if parentId is not null
+ if($parentId != null)
+ {
+ //Get the parent record Name of each attachment
+ echo("Record Attachment parent record Name: " . $parentId->getKeyValue("name") . "\n");
+
+ //Get the parent record ID of each attachment
+ echo("Record Attachment parent record ID: " . $parentId->getId() . "\n");
+ }
+
+ //Get the attachment is Editable
+ echo("Record Attachment is Editable: " . $attachment->getEditable() . "\n");
+
+ //Get the file ID of each attachment
+ echo("Record Attachment File ID: " . $attachment->getFileId() . "\n");
+
+ //Get the type of each attachment
+ echo("Record Attachment File Type: " . $attachment->getType() . "\n");
+
+ //Get the seModule of each attachment
+ echo("Record Attachment seModule: " . $attachment->getSeModule() . "\n");
+
+ //Get the modifiedBy User instance of each attachment
+ $modifiedBy = $attachment->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Record Attachment Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Record Attachment Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Record Attachment Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the state of each attachment
+ echo("Record Attachment State: " . $attachment->getState() . "\n");
+
+ //Get the ID of each attachment
+ echo("Record Attachment ID: " . $attachment->getId() . "\n");
+
+ //Get the createdBy User instance of each attachment
+ $createdBy = $attachment->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the name of the createdBy User
+ echo("Record Attachment Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Record Attachment Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Record Attachment Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the linkUrl of each attachment
+ echo("Record Attachment LinkUrl: " . $attachment->getLinkUrl() . "\n");
+ }
+ }
+ else
+ {
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ else if($value instanceof Layout)
+ {
+ $layout = $value;
+
+ if($layout != null)
+ {
+ echo("Record " . $keyName. " ID: " . $layout->getId() . "\n");
+
+ echo("Record " . $keyName . " Name: " . $layout->getName() . "\n");
+ }
+ }
+ else if($value instanceof User)
+ {
+ $user = $value;
+
+ if($user != null)
+ {
+ echo("Record " . $keyName . " User-ID: " . $user->getId() . "\n");
+
+ echo("Record " . $keyName . " User-Name: " . $user->getName() . "\n");
+
+ echo("Record " . $keyName . " User-Email: " . $user->getEmail() . "\n");
+ }
+ }
+ else if($value instanceof $recordClass)
+ {
+ $recordValue = $value;
+
+ echo("Record " . $keyName . " ID: " . $recordValue->getId() . "\n");
+
+ echo("Record " . $keyName . " Name: " . $recordValue->getKeyValue("name") . "\n");
+ }
+ else if($value instanceof Choice)
+ {
+ $choiceValue = $value;
+
+ echo("Record " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ else if($value instanceof RemindAt)
+ {
+ echo($keyName . ": " . $value->getAlarm() . "\n");
+ }
+ else if($value instanceof RecurringActivity)
+ {
+ echo($keyName . " : RRULE" . ": " . $value->getRrule() . "\n");
+ }
+ else if($value instanceof Consent)
+ {
+ $consent = $value;
+
+ echo("Record Consent ID: " . $consent->getId());
+
+ //Get the Owner User instance of each attachment
+ $owner = $consent->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the name of the owner User
+ echo("Record Consent Owner Name: " . $owner->getName());
+
+ //Get the ID of the owner User
+ echo("Record Consent Owner ID: " . $owner->getId());
+
+ //Get the Email of the owner User
+ echo("Record Consent Owner Email: " . $owner->getEmail());
+ }
+
+ $consentCreatedBy = $consent->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($consentCreatedBy != null)
+ {
+ //Get the name of the CreatedBy User
+ echo("Record Consent CreatedBy Name: " . $consentCreatedBy->getName());
+
+ //Get the ID of the CreatedBy User
+ echo("Record Consent CreatedBy ID: " . $consentCreatedBy->getId());
+
+ //Get the Email of the CreatedBy User
+ echo("Record Consent CreatedBy Email: " . $consentCreatedBy->getEmail());
+ }
+
+ $consentModifiedBy = $consent->getModifiedBy();
+
+ //Check if createdBy is not null
+ if($consentModifiedBy != null)
+ {
+ //Get the name of the ModifiedBy User
+ echo("Record Consent ModifiedBy Name: " . $consentModifiedBy->getName());
+
+ //Get the ID of the ModifiedBy User
+ echo("Record Consent ModifiedBy ID: " . $consentModifiedBy->getId());
+
+ //Get the Email of the ModifiedBy User
+ echo("Record Consent ModifiedBy Email: " . $consentModifiedBy->getEmail());
+ }
+
+ echo("Record Consent CreatedTime: " . $consent->getCreatedTime());
+
+ echo("Record Consent ModifiedTime: " . $consent->getModifiedTime());
+
+ echo("Record Consent ContactThroughEmail: " . $consent->getContactThroughEmail());
+
+ echo("Record Consent ContactThroughSocial: " . $consent->getContactThroughSocial());
+
+ echo("Record Consent ContactThroughSurvey: " . $consent->getContactThroughSurvey());
+
+ echo("Record Consent ContactThroughPhone: " . $consent->getContactThroughPhone());
+
+ echo("Record Consent MailSentTime: " . $consent->getMailSentTime().toString());
+
+ echo("Record Consent ConsentDate: " . $consent->getConsentDate().toString());
+
+ echo("Record Consent ConsentRemarks: " . $consent->getConsentRemarks());
+
+ echo("Record Consent ConsentThrough: " . $consent->getConsentThrough());
+
+ echo("Record Consent DataProcessingBasis: " . $consent->getDataProcessingBasis());
+
+ //To get custom values
+ echo("Record Consent Lawful Reason: " . $consent->getKeyValue("Lawful_Reason"));
+ }
+ else
+ {
+ //Get each value in the map
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ }
+ }
+ }
+ }
+ else if($responseHandler instanceof FileBodyWrapper)
+ {
+ //Get object from response
+ $fileBodyWrapper = $responseHandler;
+
+ //Get StreamWrapper instance from the returned FileBodyWrapper instance
+ $streamWrapper = $fileBodyWrapper->getFile();
+
+ //Create a file instance with the absolute_file_path
+ $fp = fopen($destinationFolder."/".$streamWrapper->getName(), "w");
+
+ //Get stream from the response
+ $stream = $streamWrapper->getStream();
+
+ fputs($fp, $stream);
+
+ fclose($fp);
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Update Record
+ * This method is used to update a single record of a module with ID and print the response.
+ * @param moduleAPIName - The API Name of the record's module.
+ * @param recordId - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function updateRecord(string $moduleAPIName, string $recordId)
+ {
+ //API Name of the module to update record
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Record instances
+ $records = array();
+
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ //Get instance of Record Class
+ $record1 = new $recordClass();
+
+ /*
+ * Call addFieldValue method that takes two arguments
+ * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
+ * 2 -> Value
+ */
+
+ $field = new Field("");
+
+ // $record1->addFieldValue(Leads::City(), "City");
+
+ // $record1->addFieldValue(Leads::LastName(), "Last Name");
+
+ // $record1->addFieldValue(Leads::FirstName(), "First Name");
+
+ // $record1->addFieldValue(Leads::Company(), "KKRNP");
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ // $record1->addKeyValue("Custom_field", "Value");
+
+ // $record1->addKeyValue("Custom_field_2", "value");
+
+ // $record1->addKeyValue("Date_1", new \DateTime('2020-03-08'));
+
+ // $record1->addKeyValue("Date_Time_2", date_create("2021-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
+
+ $fileDetails = array();
+
+ // $fileDetail1 = new FileDetails();
+
+ // $fileDetail1->setAttachmentId("3477061000006072005");
+
+ // $fileDetail1->setDelete("null");
+
+ // array_push($fileDetails, $fileDetail1);
+
+ $fileDetail2 = new FileDetails();
+
+ $fileDetail2->setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32244f4e660f3702f05463e2fd0a2d8c1c");
+
+ array_push($fileDetails, $fileDetail2);
+
+ $fileDetail3 = new FileDetails();
+
+ $fileDetail3->setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c326a3f4c7562925ac9afc0f7433dd2098c");
+
+ array_push($fileDetails, $fileDetail3);
+
+ $record1->addKeyValue("File_Upload", $fileDetails);
+
+ //Add Record instance to the list
+ array_push($records, $record1);
+
+ //Set the list to Records in BodyWrapper instance
+ $request->setData($records);
+
+ $trigger = array("approval", "workflow", "blueprint");
+
+ $request->setTrigger($trigger);
+
+ //Call updateRecord method that takes BodyWrapper instance, ModuleAPIName and recordId as parameter.
+ $response = $recordOperations->updateRecord( $recordId, $moduleAPIName,$request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Delete Record
+ * This method is used to delete a single record of a module with ID and print the response.
+ * @param moduleAPIName - The API Name of the record's module.
+ * @param recordId - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function deleteRecord(string $moduleAPIName, string $recordId)
+ {
+ //API Name of the module to delete record
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(DeleteRecordParam::wfTrigger(), false);
+
+ //Call deleteRecord method that takes paramInstance, ModuleAPIName and recordId as parameter.
+ $response = $recordOperations->deleteRecord($recordId,$moduleAPIName, $paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Get Records
+ * This method is used to get all the records of a module and print the response.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @throws Exception
+ *
+ */
+ public static function getRecords(string $moduleAPIName)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class that takes moduleAPIName as parameter
+ $recordOperations = new RecordOperations();
+
+ $paramInstance = new ParameterMap();
+
+ // $paramInstance->add(GetRecordsParam::approved(), "true");
+
+ // $paramInstance->add(GetRecordsParam::converted(), "1234");
+
+ // $paramInstance->add(GetRecordsParam::cvid(), "3477061000000089005");
+
+ // $ids = array("3477061000005623115", "3477061000004352001");
+
+ // foreach($ids as $id)
+ // {
+ // $paramInstance->add(GetRecordsParam::ids(), $id);
+ // }
+
+ // $paramInstance->add(GetRecordsParam::uid(), "3477061000005181008");
+
+ // $fieldNames = array("Last_Name", "City");
+
+ // foreach($fieldNames as $fieldName)
+ // {
+ $paramInstance->add(GetRecordsParam::fields(), "id");
+ // }
+
+ // $paramInstance->add(GetRecordsParam::sortBy(), "Email");
+
+ // $paramInstance->add(GetRecordsParam::sortOrder(), "desc");
+
+ $paramInstance->add(GetRecordsParam::page(), 1);
+
+ $paramInstance->add(GetRecordsParam::perPage(), 3);
+
+ $startdatetime = date_create("2020-06-27T15:10:00+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ // $paramInstance->add(GetRecordsParam::startDateTime(), $startdatetime);
+
+ // $enddatetime = date_create("2020-06-29T15:10:00+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ // $paramInstance->add(GetRecordsParam::endDateTime(), $enddatetime);
+
+ // $paramInstance->add(GetRecordsParam::territoryId(), "3477061000003051357");
+
+ // $paramInstance->add(GetRecordsParam::includeChild(), true);
+
+ $headerInstance = new HeaderMap();
+
+ // $datetime = date_create("2021-02-26T15:28:34+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ // $headerInstance->add(GetRecordsHeader::IfModifiedSince(), $datetime);
+
+ //Call getRecords method
+ $response = $recordOperations->getRecords($moduleAPIName,$paramInstance, $headerInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ if($response->isExpected())
+ {
+ //Get the object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Record instances
+ $records = $responseWrapper->getData();
+
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ foreach($records as $record)
+ {
+ //Get the ID of each Record
+ echo("Record ID: " . $record->getId() . "\n");
+
+ //Get the createdBy User instance of each Record
+ $createdBy = $record->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("Record Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("Record Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Record Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the CreatedTime of each Record
+ echo("Record CreatedTime: ");
+
+ print_r($record->getCreatedTime());
+
+ echo("\n");
+
+ //Get the modifiedBy User instance of each Record
+ $modifiedBy = $record->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("Record Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("Record Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Record Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the ModifiedTime of each Record
+ echo("Record ModifiedTime: ");
+
+ print_r($record->getModifiedTime());
+
+ echo("\n");
+
+ //Get the list of Tag instance each Record
+ $tags = $record->getTag();
+
+ //Check if tags is not null
+ if($tags != null)
+ {
+ foreach($tags as $tag)
+ {
+ //Get the Name of each Tag
+ echo("Record Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("Record Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+
+ //To get particular field value
+ echo("Record Field Value: " . $record->getKeyValue("Last_Name") . "\n");// FieldApiName
+
+ echo("Record KeyValues : \n" );
+
+ //Get the KeyValue map
+ foreach($record->getKeyValues() as $keyName => $value)
+ {
+ if($value != null)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ if($value[0] instanceof FileDetails)
+ {
+ $fileDetails = $value;
+
+ foreach($fileDetails as $fileDetail)
+ {
+ $fileDetails = $value;
+
+ foreach($fileDetails as $fileDetail)
+ {
+ //Get the Extn of each FileDetails
+ echo("Record FileDetails Extn: " . $fileDetail->getExtn() . "\n");
+
+ //Get the IsPreviewAvailable of each FileDetails
+ echo("Record FileDetails IsPreviewAvailable: " . $fileDetail->getIsPreviewAvailable() . "\n");
+
+ //Get the DownloadUrl of each FileDetails
+ echo("Record FileDetails DownloadUrl: " . $fileDetail->getDownloadUrl() . "\n");
+
+ //Get the DeleteUrl of each FileDetails
+ echo("Record FileDetails DeleteUrl: " . $fileDetail->getDeleteUrl() . "\n");
+
+ //Get the EntityId of each FileDetails
+ echo("Record FileDetails EntityId: " . $fileDetail->getEntityId() . "\n");
+
+ //Get the Mode of each FileDetails
+ echo("Record FileDetails Mode: " . $fileDetail->getMode() . "\n");
+
+ //Get the OriginalSizeByte of each FileDetails
+ echo("Record FileDetails OriginalSizeByte: " . $fileDetail->getOriginalSizeByte() . "\n");
+
+ //Get the PreviewUrl of each FileDetails
+ echo("Record FileDetails PreviewUrl: " . $fileDetail->getPreviewUrl() . "\n");
+
+ //Get the FileName of each FileDetails
+ echo("Record FileDetails FileName: " . $fileDetail->getFileName() . "\n");
+
+ //Get the FileId of each FileDetails
+ echo("Record FileDetails FileId: " . $fileDetail->getFileId() . "\n");
+
+ //Get the AttachmentId of each FileDetails
+ echo("Record FileDetails AttachmentId: " . $fileDetail->getAttachmentId() . "\n");
+
+ //Get the FileSize of each FileDetails
+ echo("Record FileDetails FileSize: " . $fileDetail->getFileSize() . "\n");
+
+ //Get the CreatorId of each FileDetails
+ echo("Record FileDetails CreatorId: " . $fileDetail->getCreatorId() . "\n");
+
+ //Get the LinkDocs of each FileDetails
+ echo("Record FileDetails LinkDocs: " . $fileDetail->getLinkDocs() . "\n");
+ }
+ }
+ }
+ else if($value[0] instanceof Choice)
+ {
+ $choice = $value;
+
+ foreach($choice as $choiceValue)
+ {
+ echo("Record " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ }
+ else if($value[0] instanceof InventoryLineItems)
+ {
+ $productDetails = $value;
+
+ foreach($productDetails as $productDetail)
+ {
+ $lineItemProduct = $productDetail->getProduct();
+
+ if($lineItemProduct != null)
+ {
+ echo("Record ProductDetails LineItemProduct ProductCode: " . $lineItemProduct->getProductCode() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Currency: " . $lineItemProduct->getCurrency() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Name: " . $lineItemProduct->getName() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Id: " . $lineItemProduct->getId() . "\n");
+ }
+
+ echo("Record ProductDetails Quantity: " . $productDetail->getQuantity() . "\n");
+
+ echo("Record ProductDetails Discount: " . $productDetail->getDiscount() . "\n");
+
+ echo("Record ProductDetails TotalAfterDiscount: " . $productDetail->getTotalAfterDiscount() . "\n");
+
+ echo("Record ProductDetails NetTotal: " . $productDetail->getNetTotal() . "\n");
+
+ if($productDetail->getBook() != null)
+ {
+ echo("Record ProductDetails Book: " . $productDetail->getBook() . "\n");
+ }
+
+ echo("Record ProductDetails Tax: " . $productDetail->getTax() . "\n");
+
+ echo("Record ProductDetails ListPrice: " . $productDetail->getListPrice() . "\n");
+
+ echo("Record ProductDetails UnitPrice: " . $productDetail->getUnitPrice() . "\n");
+
+ echo("Record ProductDetails QuantityInStock: " . $productDetail->getQuantityInStock() . "\n");
+
+ echo("Record ProductDetails Total: " . $productDetail->getTotal() . "\n");
+
+ echo("Record ProductDetails ID: " . $productDetail->getId() . "\n");
+
+ echo("Record ProductDetails ProductDescription: " . $productDetail->getProductDescription() . "\n");
+
+ $lineTaxes = $productDetail->getLineTax();
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("Record ProductDetails LineTax Percentage: " . $lineTax->getPercentage() . "\n");
+
+ echo("Record ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("Record ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("Record ProductDetails LineTax Value: " . $lineTax->getValue() . "\n");
+ }
+ }
+ }
+ else if($value[0] instanceof Tag)
+ {
+ $tagList = $value;
+
+ foreach($tagList as $tag)
+ {
+ //Get the Name of each Tag
+ echo("Record Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("Record Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof PricingDetails)
+ {
+ $pricingDetails = $value;
+
+ foreach($pricingDetails as $pricingDetail)
+ {
+ echo("Record PricingDetails ToRange: " . $pricingDetail->getToRange(). "\n");
+
+ echo("Record PricingDetails Discount: " . $pricingDetail->getDiscount(). "\n");
+
+ echo("Record PricingDetails ID: " . $pricingDetail->getId() . "\n");
+
+ echo("Record PricingDetails FromRange: " . $pricingDetail->getFromRange(). "\n");
+ }
+ }
+ else if($value[0] instanceof Participants)
+ {
+ $participants = $value;
+
+ foreach($participants as $participant)
+ {
+ echo("RelatedRecord Participants Name: " . $participant->getName() . "\n");
+
+ echo("RelatedRecord Participants Invited: " . $participant->getInvited() . "\n");
+
+ echo("RelatedRecord Participants ID: " . $participant->getId() . "\n");
+
+ echo("RelatedRecord Participants Type: " . $participant->getType() . "\n");
+
+ echo("RelatedRecord Participants Participant: " . $participant->getParticipant() . "\n");
+
+ echo("RelatedRecord Participants Status: " . $participant->getStatus() . "\n");
+ }
+ }
+ else if($value[0] instanceof $recordClass)
+ {
+ $recordList = $value;
+
+ foreach($recordList as $record1)
+ {
+ //Get the details map
+ foreach($record1->getKeyValues() as $key => $value1)
+ {
+ //Get each value in the map
+ echo($key . " : " );
+
+ print_r($value1);
+
+ echo("\n");
+ }
+ }
+ }
+ else if($value[0] instanceof LineTax)
+ {
+ $lineTaxes = $value;
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("Record ProductDetails LineTax Percentage: " . $lineTax->getPercentage(). "\n");
+
+ echo("Record ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("Record ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("Record ProductDetails LineTax Value: " . $lineTax->getValue(). "\n");
+ }
+ }
+ else if($value[0] instanceof Comment)
+ {
+ $comments = $value;
+
+ foreach($comments as $comment)
+ {
+ echo("Record Comment CommentedBy: " . $comment->getCommentedBy() . "\n");
+
+ echo("Record Comment CommentedTime: ");
+
+ print_r($comment->getCommentedTime());
+
+ echo("\n");
+
+ echo("Record Comment CommentContent: " . $comment->getCommentContent(). "\n");
+
+ echo("Record Comment Id: " . $comment->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof Attachment)
+ {
+ $attachments = $value;
+
+ foreach ($attachments as $attachment)
+ {
+ //Get the owner User instance of each attachment
+ $owner = $attachment->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the Name of the Owner
+ echo("Record Attachment Owner User-Name: " . $owner->getName() . "\n");
+
+ //Get the ID of the Owner
+ echo("Record Attachment Owner User-ID: " . $owner->getId() . "\n");
+
+ //Get the Email of the Owner
+ echo("Record Attachment Owner User-Email: " . $owner->getEmail() . "\n");
+ }
+
+ //Get the modified time of each attachment
+ echo("Record Attachment Modified Time: ");
+
+ print_r($attachment->getModifiedTime());
+
+ echo("\n");
+
+ //Get the name of the File
+ echo("Record Attachment File Name: " . $attachment->getFileName() . "\n");
+
+ //Get the created time of each attachment
+ echo("Record Attachment Created Time: " );
+
+ print_r($attachment->getCreatedTime());
+
+ echo("\n");
+
+ //Get the Attachment file size
+ echo("Record Attachment File Size: " . $attachment->getSize() . "\n");
+
+ //Get the parentId Record instance of each attachment
+ $parentId = $attachment->getParentId();
+
+ //Check if parentId is not null
+ if($parentId != null)
+ {
+ //Get the parent record Name of each attachment
+ echo("Record Attachment parent record Name: " . $parentId->getKeyValue("name") . "\n");
+
+ //Get the parent record ID of each attachment
+ echo("Record Attachment parent record ID: " . $parentId->getId() . "\n");
+ }
+
+ //Get the attachment is Editable
+ echo("Record Attachment is Editable: " . $attachment->getEditable() . "\n");
+
+ //Get the file ID of each attachment
+ echo("Record Attachment File ID: " . $attachment->getFileId() . "\n");
+
+ //Get the type of each attachment
+ echo("Record Attachment File Type: " . $attachment->getType() . "\n");
+
+ //Get the seModule of each attachment
+ echo("Record Attachment seModule: " . $attachment->getSeModule() . "\n");
+
+ //Get the modifiedBy User instance of each attachment
+ $modifiedBy = $attachment->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Record Attachment Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Record Attachment Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Record Attachment Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the state of each attachment
+ echo("Record Attachment State: " . $attachment->getState() . "\n");
+
+ //Get the ID of each attachment
+ echo("Record Attachment ID: " . $attachment->getId() . "\n");
+
+ //Get the createdBy User instance of each attachment
+ $createdBy = $attachment->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the name of the createdBy User
+ echo("Record Attachment Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Record Attachment Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Record Attachment Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the linkUrl of each attachment
+ echo("Record Attachment LinkUrl: " . $attachment->getLinkUrl() . "\n");
+ }
+ }
+ else
+ {
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ }
+ else if($value instanceof Layout)
+ {
+ $layout = $value;
+
+ if($layout != null)
+ {
+ echo("Record " . $keyName. " ID: " . $layout->getId() . "\n");
+
+ echo("Record " . $keyName . " Name: " . $layout->getName() . "\n");
+ }
+ }
+ else if($value instanceof User)
+ {
+ $user = $value;
+
+ if($user != null)
+ {
+ echo("Record " . $keyName . " User-ID: " . $user->getId() . "\n");
+
+ echo("Record " . $keyName . " User-Name: " . $user->getName() . "\n");
+
+ echo("Record " . $keyName . " User-Email: " . $user->getEmail() . "\n");
+ }
+ }
+ else if($value instanceof $recordClass)
+ {
+ $recordValue = $value;
+
+ echo("Record " . $keyName . " ID: " . $recordValue->getId() . "\n");
+
+ echo("Record " . $keyName . " Name: " . $recordValue->getKeyValue("name") . "\n");
+ }
+ else if($value instanceof Choice)
+ {
+ $choiceValue = $value;
+
+ echo("Record " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ else if($value instanceof RemindAt)
+ {
+ echo($keyName . ": " . $value->getAlarm() . "\n");
+ }
+ else if($value instanceof RecurringActivity)
+ {
+ echo($keyName . " : RRULE" . ": " . $value->getRrule() . "\n");
+ }
+ else if($value instanceof Consent)
+ {
+ $consent = $value;
+
+ echo("Record Consent ID: " . $consent->getId());
+
+ //Get the Owner User instance of each attachment
+ $owner = $consent->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the name of the owner User
+ echo("Record Consent Owner Name: " . $owner->getName());
+
+ //Get the ID of the owner User
+ echo("Record Consent Owner ID: " . $owner->getId());
+
+ //Get the Email of the owner User
+ echo("Record Consent Owner Email: " . $owner->getEmail());
+ }
+
+ $consentCreatedBy = $consent->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($consentCreatedBy != null)
+ {
+ //Get the name of the CreatedBy User
+ echo("Record Consent CreatedBy Name: " . $consentCreatedBy->getName());
+
+ //Get the ID of the CreatedBy User
+ echo("Record Consent CreatedBy ID: " . $consentCreatedBy->getId());
+
+ //Get the Email of the CreatedBy User
+ echo("Record Consent CreatedBy Email: " . $consentCreatedBy->getEmail());
+ }
+
+ $consentModifiedBy = $consent->getModifiedBy();
+
+ //Check if createdBy is not null
+ if($consentModifiedBy != null)
+ {
+ //Get the name of the ModifiedBy User
+ echo("Record Consent ModifiedBy Name: " . $consentModifiedBy->getName());
+
+ //Get the ID of the ModifiedBy User
+ echo("Record Consent ModifiedBy ID: " . $consentModifiedBy->getId());
+
+ //Get the Email of the ModifiedBy User
+ echo("Record Consent ModifiedBy Email: " . $consentModifiedBy->getEmail());
+ }
+
+ echo("Record Consent CreatedTime: " . $consent->getCreatedTime());
+
+ echo("Record Consent ModifiedTime: " . $consent->getModifiedTime());
+
+ echo("Record Consent ContactThroughEmail: " . $consent->getContactThroughEmail());
+
+ echo("Record Consent ContactThroughSocial: " . $consent->getContactThroughSocial());
+
+ echo("Record Consent ContactThroughSurvey: " . $consent->getContactThroughSurvey());
+
+ echo("Record Consent ContactThroughPhone: " . $consent->getContactThroughPhone());
+
+ echo("Record Consent MailSentTime: " . $consent->getMailSentTime().toString());
+
+ echo("Record Consent ConsentDate: " . $consent->getConsentDate().toString());
+
+ echo("Record Consent ConsentRemarks: " . $consent->getConsentRemarks());
+
+ echo("Record Consent ConsentThrough: " . $consent->getConsentThrough());
+
+ echo("Record Consent DataProcessingBasis: " . $consent->getDataProcessingBasis());
+
+ //To get custom values
+ echo("Record Consent Lawful Reason: " . $consent->getKeyValue("Lawful_Reason"));
+ }
+ else
+ {
+ //Get each value in the map
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getPerPage() != null)
+ {
+ //Get the PerPage of the Info
+ echo("Record Info PerPage: " . $info->getPerPage() . "\n");
+ }
+
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("Record Info Count: " . $info->getCount() . "\n");
+ }
+
+ if($info->getPage() != null)
+ {
+ //Get the Page of the Info
+ echo("Record Info Page: " . $info->getPage() . "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the MoreRecords of the Info
+ echo("Record Info MoreRecords: " . $info->getMoreRecords() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Create Records
+ * This method is used to create records of a module and print the response
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @throws Exception
+ */
+ public static function createRecords(string $moduleAPIName)
+ {
+ //API Name of the module to create records
+ //$moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class that takes moduleAPIName as parameter
+ $recordOperations = new RecordOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $bodyWrapper = new BodyWrapper();
+
+ //List of Record instances
+ $records = array();
+
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ //Get instance of Record Class
+ $record1 = new $recordClass();
+
+ /*
+ * Call addFieldValue method that takes two arguments
+ * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
+ * 2 -> Value
+ */
+ $field = new Field("");
+
+ // $record1->addFieldValue(Leads::City(), "City");
+
+ $record1->addFieldValue(Leads::LastName(), "FROm PHP");
+
+ // $record1->addFieldValue(Leads::FirstName(), "First Name");
+
+ // $record1->addFieldValue(Leads::Company(), "KKRNP");
+
+ // $record1->addFieldValue(Vendors::VendorName(), "Vendor Name");
+
+ // $record1->addFieldValue(Deals::Stage(), new Choice("Clo"));
+
+ // $record1->addFieldValue(Deals::DealName(), "deal_name");
+
+ // $record1->addFieldValue(Deals::Description(), "deals description");
+
+ // $record1->addFieldValue(Deals::ClosingDate(), new \DateTime("2021-06-02"));
+
+ // $record1->addFieldValue(Deals::Amount(), 50.7);
+
+ // $record1->addFieldValue(Campaigns::CampaignName(), "Campaign_Name");
+
+ // $record1->addFieldValue(Solutions::SolutionTitle(), "Solution_Title");
+
+ $record1->addFieldValue(Accounts::AccountName(), "Account_Name");
+
+ // $record1->addFieldValue(Cases::CaseOrigin(), new Choice("AutomatedSDK"));
+
+ // $record1->addFieldValue(Cases::Status(), new Choice("AutomatedSDK"));
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ // $record1->addKeyValue("Custom_field", "Value");
+
+ // $record1->addKeyValue("Custom_field_2", "value");
+
+ $record1->addKeyValue("Date_1", new \DateTime('2021-03-08'));
+
+ $record1->addKeyValue("Date_Time_2", date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
+
+ // $record1->addKeyValue("Subject", "From PHP");
+
+ // $taxName = array(new Choice("Vat"), new Choice("Sales Tax"));
+
+ // $record1->addKeyValue("Tax", $taxName);
+
+ // $record1->addKeyValue("Product_Name", "AutomatedSDK");
+
+ // $fileDetails = array();
+
+ // $fileDetail1 = new FileDetails();
+
+ // $fileDetail1->setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32a6d84fd0653c0fe3eb5d30f3c0dee629");
+
+ // array_push($fileDetails, $fileDetail1);
+
+ // $fileDetail2 = new FileDetails();
+
+ // $fileDetail2->setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32cf8c21acc735a439b1e84e92ec8454d7");
+
+ // array_push($fileDetails, $fileDetail2);
+
+ // $fileDetail3 = new FileDetails();
+
+ // $fileDetail3->setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c3207c8e1a4448a63b609f1ba7bd4aee6eb");
+
+ // array_push($fileDetails, $fileDetail3);
+
+ // $record1->addKeyValue("File_Upload", $fileDetails);
+
+ // /** Following methods are being used only by Inventory modules */
+
+ // $vendorName = new $recordClass();
+
+ // $record1->addFieldValue(Vendors::id(), "3477061000007247001");
+
+ // $record1->addFieldValue(Purchase_Orders::VendorName(), $vendorName);
+
+ // $dealName = new $recordClass();
+
+ // $dealName->addFieldValue(Deals::id(), "3477061000004995070");
+
+ // $record1->addFieldValue(Sales_Orders::DealName(), $dealName);
+
+ // $contactName = new $recordClass();
+
+ // $contactName->addFieldValue(Contacts::id(), "3477061000004977055");
+
+ // $record1->addFieldValue(Purchase_Orders::ContactName(), $contactName);
+
+ // $accountName = new $recordClass();
+
+ // $accountName->addKeyValue("name", "automatedAccount");
+
+ // $record1->addFieldValue(Quotes::AccountName(), $accountName);
+
+ // $record1->addKeyValue("Discount", 10.5);
+
+ // $inventoryLineItemList = array();
+
+ // $inventoryLineItem = new InventoryLineItems();
+
+ // $lineItemProduct = new LineItemProduct();
+
+ // $lineItemProduct->setId("3477061000005356009");
+
+ // $inventoryLineItem->setProduct($lineItemProduct);
+
+ // $inventoryLineItem->setQuantity(1.5);
+
+ // $inventoryLineItem->setProductDescription("productDescription");
+
+ // $inventoryLineItem->setListPrice(10.0);
+
+ // $inventoryLineItem->setDiscount("5.0");
+
+ // $inventoryLineItem->setDiscount("5.25%");
+
+ // $productLineTaxes = array();
+
+ // $productLineTax = new LineTax();
+
+ // $productLineTax->setName("Sales Tax");
+
+ // $productLineTax->setPercentage(20.0);
+
+ // array_push($productLineTaxes, $productLineTax);
+
+ // $inventoryLineItem->setLineTax($productLineTaxes);
+
+ // array_push($inventoryLineItemList, $inventoryLineItem);
+
+ // $record1->addKeyValue("Product_Details", $inventoryLineItemList);
+
+ // $lineTaxes = array();
+
+ // $lineTax = new LineTax();
+
+ // $lineTax->setName("Sales Tax");
+
+ // $lineTax->setPercentage(20.0);
+
+ // array_push($lineTaxes,$lineTax);
+
+ // $record1->addKeyValue('$line_tax', $lineTaxes);
+
+ /** End Inventory **/
+
+ /** Following methods are being used only by Activity modules */
+
+ // Tasks,Calls,Events
+ // $record1->addFieldValue(Tasks::Description(), "Test Task");
+
+ // $record1->addKeyValue("Currency",new Choice("INR"));
+
+ // $remindAt = new RemindAt();
+
+ // $remindAt->setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00.05:30");
+
+ // $record1->addFieldValue(Tasks::RemindAt(), $remindAt);
+
+ // $whoId = new $recordClass();
+
+ // $whoId->setId("3477061000004977055");
+
+ // $record1->addFieldValue(Tasks::WhoId(), $whoId);
+
+ // $record1->addFieldValue(Tasks::Status(),new Choice("Waiting for input"));
+
+ // $record1->addFieldValue(Tasks::DueDate(), new \DateTime('2021-03-08'));
+
+ // $record1->addFieldValue(Tasks::Priority(),new Choice("High"));
+
+ // $record1->addKeyValue('$se_module', "Accounts");
+
+ // $whatId = new $recordClass();
+
+ // $whatId->setId("3477061000000207118");
+
+ // $record1->addFieldValue(Tasks::WhatId(), $whatId);
+
+ /** Recurring Activity can be provided in any activity module*/
+
+ // $recurringActivity = new RecurringActivity();
+
+ // $recurringActivity->setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
+
+ // $record1->addFieldValue(Events::RecurringActivity(), $recurringActivity);
+
+ // Events
+ // $record1->addFieldValue(Events::Description(), "Test Events");
+
+ $startdatetime = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $record1->addFieldValue(Events::StartDateTime(), $startdatetime);
+
+ // $participants = array();
+
+ // $participant1 = new Participants();
+
+ // $participant1->setParticipant("raja@gmail.com");
+
+ // $participant1->setType("email");
+
+ // $participant1->setId("3477061000005902017");
+
+ // array_push($participants, $participant1);
+
+ // $participant2 = new Participants();
+
+ // $participant2->addKeyValue("participant", "3477061000005844006");
+
+ // $participant2->addKeyValue("type", "lead");
+
+ // array_push($participants, $participant2);
+
+ // $record1->addFieldValue(Events::Participants(), $participants);
+
+ // $record1->addKeyValue('$send_notification', true);
+
+ $record1->addFieldValue(Events::EventTitle(), "From PHP");
+
+ $enddatetime = date_create("2020-07-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $record1->addFieldValue(Events::EndDateTime(), $enddatetime);
+
+ // $remindAt = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ // $record1->addFieldValue(Events::RemindAt(), $remindAt);
+
+ // $record1->addFieldValue(Events::CheckInStatus(), "PLANNED");
+
+ // $remindAt = new RemindAt();
+
+ // $remindAt->setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-23T12:30:00+05:30");
+
+ // $record1->addFieldValue(Tasks::RemindAt(), $remindAt);
+
+ // $record1->addKeyValue('$se_module', "Leads");
+
+ // $whatId = new $recordClass();
+
+ // $whatId->setId("3477061000004381002");
+
+ // $record1->addFieldValue(Events::WhatId(), $whatId);
+
+ // $record1->addFieldValue(Tasks::WhatId(), $whatId);
+
+ // $record1->addFieldValue(Calls::CallType(), new Choice("Outbound"));
+
+ // $record1->addFieldValue(Calls::CallStartTime(), date_create("2020-07-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
+
+ /** End Activity **/
+
+ /** Following methods are being used only by Price_Books modules */
+
+ // $pricingDetails = array();
+
+ // $pricingDetail1 = new PricingDetails();
+
+ // $pricingDetail1->setFromRange(1.0);
+
+ // $pricingDetail1->setToRange(5.0);
+
+ // $pricingDetail1->setDiscount(2.0);
+
+ // array_push($pricingDetails, $pricingDetail1);
+
+ // $pricingDetail2 = new PricingDetails();
+
+ // $pricingDetail2->addKeyValue("from_range", 6.0);
+
+ // $pricingDetail2->addKeyValue("to_range", 11.0);
+
+ // $pricingDetail2->addKeyValue("discount", 3.0);
+
+ // array_push($pricingDetails, $pricingDetail2);
+
+ // $record1->addFieldValue(Price_Books::PricingDetails(), $pricingDetails);
+
+ // $record1->addKeyValue("Email", "raja.k123@zoho.com");
+
+ // $record1->addFieldValue(Price_Books::Description(), "TEST");
+
+ // $record1->addFieldValue(Price_Books::PriceBookName(), "book_name");
+
+ // $record1->addFieldValue(Price_Books::PricingModel(), new Choice("Flat"));
+
+ $tagList = array();
+
+ $tag = new Tag();
+
+ $tag->setName("Testtask");
+
+ array_push($tagList, $tag);
+
+ //Set the list to Tags in Record instance
+ $record1->setTag($tagList);
+
+ //Add Record instance to the list
+ // array_push($records, $record1);
+
+ //Set the list to Records in BodyWrapper instance
+ $bodyWrapper->setData($records);
+
+ $trigger = array("approval", "workflow", "blueprint");
+
+ $bodyWrapper->setTrigger($trigger);
+
+ //bodyWrapper.setLarId("3477061000000087515");
+
+ //Call createRecords method that takes BodyWrapper instance as parameter.
+ $response = $recordOperations->createRecords($moduleAPIName,$bodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Update Records
+ * This method is used to update records of a module and print the response.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @throws Exception
+ */
+ public static function updateRecords(string $moduleAPIName)
+ {
+ //API Name of the module to create records
+ //$moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Record instances
+ $records = array();
+
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ //Get instance of Record Class
+ $record1 = new $recordClass();
+
+ $record1->setId("3477061000006606002");
+
+ /*
+ * Call addFieldValue method that takes two arguments
+ * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
+ * 2 -> Value
+ */
+ $field = new Field("");
+
+ $record1->addFieldValue(Leads::City(), "City");
+
+ $record1->addFieldValue(Leads::LastName(), "Last Name");
+
+ $record1->addFieldValue(Leads::FirstName(), "First Name");
+
+ $record1->addFieldValue(Leads::Company(), "KKRNP");
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ $record1->addKeyValue("Custom_field", "Value");
+
+ $record1->addKeyValue("Custom_field_2", "value");
+
+ //Add Record instance to the list
+ // array_push($records, $record1);
+
+ //Get instance of Record Class
+ $record2 = new $recordClass();
+
+ $record2->setId("3477061000006603294");
+
+ /*
+ * Call addFieldValue method that takes two arguments
+ * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
+ * 2 -> Value
+ */
+ $record2->addFieldValue(Leads::City(), "City");
+
+ $record2->addFieldValue(Leads::LastName(), "Last Name");
+
+ $record2->addFieldValue(Leads::FirstName(), "First Name");
+
+ $record2->addFieldValue(Leads::Company(), "KKRNP");
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ $record2->addKeyValue("Custom_field", "Value");
+
+ $record2->addKeyValue("Custom_field_2", "value");
+
+ //Add Record instance to the list
+ // array_push($records, $record2);
+
+ //Set the list to Records in BodyWrapper instance
+ $request->setData($records);
+
+ $trigger = array("approval", "workflow", "blueprint");
+
+ $request->setTrigger($trigger);
+
+ //Call createRecords method that takes BodyWrapper instance and moduleAPIName as parameter.
+ $response = $recordOperations->updateRecords($moduleAPIName, $request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Delete Records
+ * This method is used to delete records of a module and print the response
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @param recordIds - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function deleteRecords(string $moduleAPIName, array $recordIds)
+ {
+ //API Name of the module to update record
+ //$moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($recordIds as $id)
+ {
+ $paramInstance->add(DeleteRecordsParam::ids(), $id);
+ }
+
+ // $paramInstance->add(DeleteRecordsParam::wfTrigger(), "true");
+
+ //Call deleteRecord method that takes ModuleAPIName and recordId as parameter.
+ $response = $recordOperations->deleteRecords($moduleAPIName,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Upsert Records
+ * This method is used to Upsert records of a module and print the response.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @throws Exception
+ */
+ public static function upsertRecords(string $moduleAPIName)
+ {
+ //API Name of the module to create records
+ //$moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class that takes moduleAPIName as parameter
+ $recordOperations = new RecordOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Record instances
+ $records = array();
+
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ //Get instance of Record Class
+ $record1 = new $recordClass();
+
+ /*
+ * Call addFieldValue method that takes two arguments
+ * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
+ * 2 -> Value
+ */
+ $field = new Field("");
+
+ $record1->addFieldValue(Leads::City(), "City");
+
+ // $record1->addFieldValue(Leads::LastName(), "Last Name");
+
+ $record1->addFieldValue(Leads::FirstName(), "First Name");
+
+ $record1->addFieldValue(Leads::Company(), "Company1");
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ $record1->addKeyValue("Custom_field", "Value");
+
+ $record1->addKeyValue("Custom_field_2", "value");
+
+ //Add Record instance to the list
+ array_push($records, $record1);
+
+ //Get instance of Record Class
+ $record2 = new $recordClass();
+
+ /*
+ * Call addFieldValue method that takes two arguments
+ * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
+ * 2 -> Value
+ */
+ $record2->addFieldValue(Leads::City(), "City");
+
+ // $record2->addFieldValue(Leads::LastName(), "Last Name");
+
+ $record2->addFieldValue(Leads::FirstName(), "First Name");
+
+ $record2->addFieldValue(Leads::Company(), "Company12");
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ $record2->addKeyValue("Custom_field", "Value");
+
+ $record2->addKeyValue("Custom_field_2", "value");
+
+ //Add Record instance to the list
+ array_push($records, $record2);
+
+ $duplicateCheckFields = array("City", "Last_Name", "First_Name");
+
+ $request->setDuplicateCheckFields($duplicateCheckFields);
+
+ //Set the list to Records in BodyWrapper instance
+ $request->setData($records);
+
+ //Call createRecords method that takes BodyWrapper instance as parameter.
+ $response = $recordOperations->upsertRecords($moduleAPIName, $request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Get Deleted Records
+ * This method is used to deleted records of a module and print the response.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @throws Exception
+ */
+ public static function getDeletedRecords(string $moduleAPIName)
+ {
+ //example, $moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetDeletedRecordsParam::type(), "laa");//all, recycle, permanent
+
+ // $paramInstance->add(GetDeletedRecordsParam::page(), 1);
+
+ // $paramInstance->add(GetDeletedRecordsParam::perPage(), 2);
+
+ //Get instance of HeaderMap Class
+ $headerInstance = new HeaderMap();
+
+ $ifModifiedSince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $headerInstance->add(GetDeletedRecordsHeader::IfModifiedSince(), $ifModifiedSince);
+
+ //Call getDeletedRecords method that takes paramInstance, headerInstance and moduleAPIName as parameter
+ $response = $recordOperations->getDeletedRecords($moduleAPIName,$paramInstance, $headerInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ if($response->isExpected())
+ {
+ //Get the object from response
+ $deletedRecordsHandler = $response->getObject();
+
+ if($deletedRecordsHandler instanceof DeletedRecordsWrapper)
+ {
+ //Get the received DeletedRecordsWrapper instance
+ $deletedRecordsWrapper = $deletedRecordsHandler;
+
+ //Get the list of obtained DeletedRecord instances
+ $deletedRecords = $deletedRecordsWrapper->getData();
+
+ foreach($deletedRecords as $deletedRecord)
+ {
+ //Get the deletedBy User instance of each DeletedRecord
+ $deletedBy = $deletedRecord->getDeletedBy();
+
+ //Check if deletedBy is not null
+ if($deletedBy != null)
+ {
+ //Get the name of the deletedBy User
+ echo("DeletedRecord Deleted By User-Name: " . $deletedBy->getName() . "\n");
+
+ //Get the ID of the deletedBy User
+ echo("DeletedRecord Deleted By User-ID: " . $deletedBy->getId() . "\n");
+ }
+
+ //Get the ID of each DeletedRecord
+ echo("DeletedRecord ID: " . $deletedRecord->getId() . "\n");
+
+ //Get the DisplayName of each DeletedRecord
+ echo("DeletedRecord DisplayName: " . $deletedRecord->getDisplayName() . "\n");
+
+ //Get the Type of each DeletedRecord
+ echo("DeletedRecord Type: " . $deletedRecord->getType() . "\n");
+
+ //Get the createdBy User instance of each DeletedRecord
+ $createdBy = $deletedRecord->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the name of the createdBy User
+ echo("DeletedRecord Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("DeletedRecord Created By User-ID: " . $createdBy->getId() . "\n");
+ }
+
+ //Get the DeletedTime of each DeletedRecord
+ echo("DeletedRecord DeletedTime: ");
+
+ print_r($deletedRecord->getDeletedTime());
+
+ echo("\n");
+ }
+
+ //Get the Object obtained Info instance
+ $info = $deletedRecordsWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getPerPage() != null)
+ {
+ //Get the PerPage of the Info
+ echo("Deleted Record Info PerPage: " . $info->getPerPage() . "\n");
+ }
+
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("Deleted Record Info Count: " . $info->getCount() . "\n");
+ }
+
+ if($info->getPage() != null)
+ {
+ //Get the Page of the Info
+ echo("Deleted Record Info Page: " . $info->getPage() . "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the MoreRecords of the Info
+ echo("Deleted Record Info MoreRecords: " . $info->getMoreRecords() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($deletedRecordsHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $deletedRecordsHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Search Records
+ * This method is used to search records of a module and print the response.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @throws Exception
+ */
+ public static function searchRecords(string $moduleAPIName)
+ {
+ //example, moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class that takes moduleAPIName as parameter
+ $recordOperations = new RecordOperations();
+
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(SearchRecordsParam::criteria(), "((Last_Name:starts_with:Last Name) or (Company:starts_with:fasf\\(123\\) K))");
+
+ $paramInstance->add(SearchRecordsParam::email(), "raja@gmail.com");
+
+ $paramInstance->add(SearchRecordsParam::phone(), "234567890");
+
+ $paramInstance->add(SearchRecordsParam::word(), "First Name Last Name");
+
+ $paramInstance->add(SearchRecordsParam::converted(), "both");
+
+ $paramInstance->add(SearchRecordsParam::approved(), "both");
+
+ $paramInstance->add(SearchRecordsParam::page(), 1);
+
+ $paramInstance->add(SearchRecordsParam::perPage(), 2);
+
+ //Call getRecords method
+ $response = $recordOperations->searchRecords($moduleAPIName,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ if($response->isExpected())
+ {
+ //Get the object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Record instance
+ $records = $responseWrapper->getData();
+
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ foreach($records as $record)
+ {
+ //Get the ID of each Record
+ echo("Record ID: " . $record->getId() . "\n");
+
+ //Get the createdBy User instance of each Record
+ $createdBy = $record->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("Record Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("Record Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("Record Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the CreatedTime of each Record
+ echo("Record CreatedTime: ");
+
+ print_r($record->getCreatedTime());
+
+ echo("\n");
+
+ //Get the modifiedBy User instance of each Record
+ $modifiedBy = $record->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("Record Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("Record Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("Record Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the ModifiedTime of each Record
+ echo("Record ModifiedTime: ");
+
+ print_r($record->getModifiedTime());
+
+ echo("\n");
+
+ //Get the list of Tag instance each Record
+ $tags = $record->getTag();
+
+ //Check if tags is not null
+ if($tags != null)
+ {
+ foreach($tags as $tag)
+ {
+ //Get the Name of each Tag
+ echo("Record Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("Record Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+
+ //To get particular field value
+ echo("Record Field Value: " . $record->getKeyValue("Last_Name") . "\n");// FieldApiName
+
+ echo("Record KeyValues : \n" );
+
+ //Get the KeyValue map
+ foreach($record->getKeyValues() as $keyName => $value)
+ {
+ if($value != null)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ if($value[0] instanceof FileDetails)
+ {
+ $fileDetails = $value;
+
+ foreach($fileDetails as $fileDetail)
+ {
+ //Get the Extn of each FileDetails
+ echo("Record FileDetails Extn: " . $fileDetail->getExtn() . "\n");
+
+ //Get the IsPreviewAvailable of each FileDetails
+ echo("Record FileDetails IsPreviewAvailable: " . $fileDetail->getIsPreviewAvailable() . "\n");
+
+ //Get the DownloadUrl of each FileDetails
+ echo("Record FileDetails DownloadUrl: " . $fileDetail->getDownloadUrl() . "\n");
+
+ //Get the DeleteUrl of each FileDetails
+ echo("Record FileDetails DeleteUrl: " . $fileDetail->getDeleteUrl() . "\n");
+
+ //Get the EntityId of each FileDetails
+ echo("Record FileDetails EntityId: " . $fileDetail->getEntityId() . "\n");
+
+ //Get the Mode of each FileDetails
+ echo("Record FileDetails Mode: " . $fileDetail->getMode() . "\n");
+
+ //Get the OriginalSizeByte of each FileDetails
+ echo("Record FileDetails OriginalSizeByte: " . $fileDetail->getOriginalSizeByte() . "\n");
+
+ //Get the PreviewUrl of each FileDetails
+ echo("Record FileDetails PreviewUrl: " . $fileDetail->getPreviewUrl() . "\n");
+
+ //Get the FileName of each FileDetails
+ echo("Record FileDetails FileName: " . $fileDetail->getFileName() . "\n");
+
+ //Get the FileId of each FileDetails
+ echo("Record FileDetails FileId: " . $fileDetail->getFileId() . "\n");
+
+ //Get the AttachmentId of each FileDetails
+ echo("Record FileDetails AttachmentId: " . $fileDetail->getAttachmentId() . "\n");
+
+ //Get the FileSize of each FileDetails
+ echo("Record FileDetails FileSize: " . $fileDetail->getFileSize() . "\n");
+
+ //Get the CreatorId of each FileDetails
+ echo("Record FileDetails CreatorId: " . $fileDetail->getCreatorId() . "\n");
+
+ //Get the LinkDocs of each FileDetails
+ echo("Record FileDetails LinkDocs: " . $fileDetail->getLinkDocs() . "\n");
+ }
+ }
+ else if($value[0] instanceof Choice)
+ {
+ $choice = $value;
+
+ foreach($choice as $choiceValue)
+ {
+ echo("Record " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ }
+ else if($value[0] instanceof InventoryLineItems)
+ {
+ $productDetails = $value;
+
+ foreach($productDetails as $productDetail)
+ {
+ $lineItemProduct = $productDetail->getProduct();
+
+ if($lineItemProduct != null)
+ {
+ echo("Record ProductDetails LineItemProduct ProductCode: " . $lineItemProduct->getProductCode() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Currency: " . $lineItemProduct->getCurrency() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Name: " . $lineItemProduct->getName() . "\n");
+
+ echo("Record ProductDetails LineItemProduct Id: " . $lineItemProduct->getId() . "\n");
+ }
+
+ echo("Record ProductDetails Quantity: " . $productDetail->getQuantity() . "\n");
+
+ echo("Record ProductDetails Discount: " . $productDetail->getDiscount() . "\n");
+
+ echo("Record ProductDetails TotalAfterDiscount: " . $productDetail->getTotalAfterDiscount() . "\n");
+
+ echo("Record ProductDetails NetTotal: " . $productDetail->getNetTotal() . "\n");
+
+ if($productDetail->getBook() != null)
+ {
+ echo("Record ProductDetails Book: " . $productDetail->getBook() . "\n");
+ }
+
+ echo("Record ProductDetails Tax: " . $productDetail->getTax() . "\n");
+
+ echo("Record ProductDetails ListPrice: " . $productDetail->getListPrice() . "\n");
+
+ echo("Record ProductDetails UnitPrice: " . $productDetail->getUnitPrice() . "\n");
+
+ echo("Record ProductDetails QuantityInStock: " . $productDetail->getQuantityInStock() . "\n");
+
+ echo("Record ProductDetails Total: " . $productDetail->getTotal() . "\n");
+
+ echo("Record ProductDetails ID: " . $productDetail->getId() . "\n");
+
+ echo("Record ProductDetails ProductDescription: " . $productDetail->getProductDescription() . "\n");
+
+ $lineTaxes = $productDetail->getLineTax();
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("Record ProductDetails LineTax Percentage: " . $lineTax->getPercentage() . "\n");
+
+ echo("Record ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("Record ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("Record ProductDetails LineTax Value: " . $lineTax->getValue() . "\n");
+ }
+ }
+ }
+ else if($value[0] instanceof Tag)
+ {
+ $tagList = $value;
+
+ foreach($tagList as $tag)
+ {
+ //Get the Name of each Tag
+ echo("Record Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("Record Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof PricingDetails)
+ {
+ $pricingDetails = $value;
+
+ foreach($pricingDetails as $pricingDetail)
+ {
+ echo("Record PricingDetails ToRange: " . $pricingDetail->getToRange(). "\n");
+
+ echo("Record PricingDetails Discount: " . $pricingDetail->getDiscount(). "\n");
+
+ echo("Record PricingDetails ID: " . $pricingDetail->getId() . "\n");
+
+ echo("Record PricingDetails FromRange: " . $pricingDetail->getFromRange(). "\n");
+ }
+ }
+ else if($value[0] instanceof Participants)
+ {
+ $participants = $value;
+
+ foreach($participants as $participant)
+ {
+ echo("RelatedRecord Participants Name: " . $participant->getName() . "\n");
+
+ echo("RelatedRecord Participants Invited: " . $participant->getInvited() . "\n");
+
+ echo("RelatedRecord Participants ID: " . $participant->getId() . "\n");
+
+ echo("RelatedRecord Participants Type: " . $participant->getType() . "\n");
+
+ echo("RelatedRecord Participants Participant: " . $participant->getParticipant() . "\n");
+
+ echo("RelatedRecord Participants Status: " . $participant->getStatus() . "\n");
+ }
+ }
+ else if($value instanceof User)
+ {
+ $user = $value;
+
+ if($user != null)
+ {
+ echo("Record " . $keyName . " User-ID: " . $user->getId() . "\n");
+
+ echo("Record " . $keyName . " User-Name: " . $user->getName() . "\n");
+
+ echo("Record " . $keyName . " User-Email: " . $user->getEmail() . "\n");
+ }
+ }
+ else if($value[0] instanceof $recordClass)
+ {
+ $recordList = $value;
+
+ foreach($recordList as $record1)
+ {
+ //Get the details map
+ foreach($record1->getKeyValues() as $key => $value1)
+ {
+ //Get each value in the map
+ echo($key . " : " );
+
+ print_r($value1);
+
+ echo("\n");
+ }
+ }
+ }
+ else if($value[0] instanceof LineTax)
+ {
+ $lineTaxes = $value;
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("Record ProductDetails LineTax Percentage: " . $lineTax->getPercentage(). "\n");
+
+ echo("Record ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("Record ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("Record ProductDetails LineTax Value: " . $lineTax->getValue(). "\n");
+ }
+ }
+ else if($value[0] instanceof Comment)
+ {
+ $comments = $value;
+
+ foreach($comments as $comment)
+ {
+ echo("Record Comment CommentedBy: " . $comment->getCommentedBy() . "\n");
+
+ echo("Record Comment CommentedTime: ");
+
+ print_r($comment->getCommentedTime());
+
+ echo("\n");
+
+ echo("Record Comment CommentContent: " . $comment->getCommentContent(). "\n");
+
+ echo("Record Comment Id: " . $comment->getId() . "\n");
+ }
+ }
+ else
+ {
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ else if($value instanceof Layout)
+ {
+ $layout = $value;
+
+ if($layout != null)
+ {
+ echo("Record " . $keyName. " ID: " . $layout->getId() . "\n");
+
+ echo("Record " . $keyName . " Name: " . $layout->getName() . "\n");
+ }
+ }
+ else if($value instanceof User)
+ {
+ $user = $value;
+
+ if($user != null)
+ {
+ echo("Record " . $keyName . " User-ID: " . $user->getId() . "\n");
+
+ echo("Record " . $keyName . " User-Name: " . $user->getName() . "\n");
+
+ echo("Record " . $keyName . " User-Email: " . $user->getEmail() . "\n");
+ }
+ }
+ else if($value instanceof $recordClass)
+ {
+ $recordValue = $value;
+
+ echo("Record " . $keyName . " ID: " . $recordValue->getId() . "\n");
+
+ echo("Record " . $keyName . " Name: " . $recordValue->getKeyValue("name") . "\n");
+ }
+ else if($value instanceof Choice)
+ {
+ $choiceValue = $value;
+
+ echo("Record " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ else if($value instanceof RemindAt)
+ {
+ echo($keyName . ": " . $value->getAlarm() . "\n");
+ }
+ else if($value instanceof RecurringActivity)
+ {
+ echo($keyName . " : RRULE" . ": " . $value->getRrule() . "\n");
+ }
+ else
+ {
+ //Get each value in the map
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ }
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getPerPage() != null)
+ {
+ //Get the PerPage of the Info
+ echo("Record Info PerPage: " . $info->getPerPage() . "\n");
+ }
+
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("Record Info Count: " . $info->getCount() . "\n");
+ }
+
+ if($info->getPage() != null)
+ {
+ //Get the Page of the Info
+ echo("Record Info Page: " . $info->getPage() . "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the MoreRecords of the Info
+ echo("Record Info MoreRecords: " . $info->getMoreRecords() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Convert Lead
+ * This method is used to Convert Lead record of a module and print the response.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @param recordId - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function convertLead(string $recordId)
+ {
+ //API Name of the module to update record
+ //$moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of ConvertBodyWrapper Class that will contain the request body
+ $request = new ConvertBodyWrapper();
+
+ //List of LeadConverter instances
+ $data = array();
+
+ //Get instance of LeadConverter Class
+ $record1 = new LeadConverter();
+
+ $record1->setOverwrite(true);
+
+ $record1->setNotifyLeadOwner(true);
+
+ $record1->setNotifyNewEntityOwner(true);
+
+ $record1->setAccounts("3477061000005848125");
+
+ $record1->setContacts("3477061000000358009");
+
+ $record1->setAssignTo("3477061000000173021");
+
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ $deals = new $recordClass();
+
+ /*
+ * Call addFieldValue method that takes two arguments
+ * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
+ * 2 -> Value
+ */
+ $field = new Field("");
+
+ // $deals->addFieldValue(Deals::DealName(), "deal_name");
+
+ // $deals->addFieldValue(Deals::Description(), "deals description");
+
+ // $deals->addFieldValue(Deals::ClosingDate(), new \DateTime("2021-06-02"));
+
+ // $deals->addFieldValue(Deals::Stage(), new Choice("Closed Won"));
+
+ // $deals->addFieldValue(Deals::Amount(), 50.7);
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ $deals->addKeyValue("Custom_field", "Value");
+
+ $deals->addKeyValue("Custom_field_2", "value");
+
+ $tagList = array();
+
+ $tag = new Tag();
+
+ $tag->setName("TestDeals");
+
+ array_push($tagList, $tag);
+
+ $deals->setTag($tagList);
+
+ // $record1->setDeals($deals);
+
+ //Add Record instance to the list
+ array_push($data, $record1);
+
+ //Set the list to Records in BodyWrapper instance
+ $request->setData($data);
+
+ //Call updateRecord method that takes BodyWrapper instance, ModuleAPIName and recordId as parameter.
+ $response = $recordOperations->convertLead($recordId,$request );
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $convertActionHandler = $response->getObject();
+
+ if($convertActionHandler instanceof ConvertActionWrapper)
+ {
+ //Get the received ConvertActionWrapper instance
+ $convertActionWrapper = $convertActionHandler;
+
+ //Get the list of obtained ConvertActionResponse instances
+ $convertActionResponses = $convertActionWrapper->getData();
+
+ foreach($convertActionResponses as $convertActionResponse)
+ {
+ //Check if the request is successful
+ if($convertActionResponse instanceof SuccessfulConvert)
+ {
+ //Get the received SuccessfulConvert instance
+ $successfulConvert = $convertActionResponse;
+
+ //Get the Accounts ID of Record
+ echo("LeadConvert Accounts ID: " . $successfulConvert->getAccounts() . "\n");
+
+ //Get the Contacts ID of Record
+ echo("LeadConvert Contacts ID: " . $successfulConvert->getContacts() . "\n");
+
+ //Get the Deals ID of Record
+ echo("LeadConvert Deals ID: " . $successfulConvert->getDeals() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($convertActionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $convertActionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($convertActionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $convertActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * This method is used to download a photo associated with a module.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @param recordId - The ID of the record to be obtained.
+ * @param destinationFolder - The absolute path of the destination folder to store the photo.
+ * @throws Exception
+ */
+ public static function getPhoto(string $moduleAPIName, string $recordId, string $destinationFolder)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$destinationFolder = "/Users/user_name/Desktop";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Call downloadAttachment method that takes moduleAPIName and recordId as parameters
+ $response = $recordOperations->getPhoto($recordId,$moduleAPIName );
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $downloadHandler = $response->getObject();
+
+ if($downloadHandler instanceof FileBodyWrapper)
+ {
+ //Get object from response
+ $fileBodyWrapper = $downloadHandler;
+
+ //Get StreamWrapper instance from the returned FileBodyWrapper instance
+ $streamWrapper = $fileBodyWrapper->getFile();
+
+ //Create a file instance with the absolute_file_path
+ $fp = fopen($destinationFolder."/".$streamWrapper->getName(), "w");
+
+ //Get stream from the response
+ $stream = $streamWrapper->getStream();
+
+ fputs($fp, $stream);
+
+ fclose($fp);
+ }
+ //Check if the request returned an exception
+ else if($downloadHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $downloadHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * This method is used to attach a photo to a $record-> You must include the photo in the request with content type as multipart/form data.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @param recordId - The ID of the record to be obtained.
+ * @param absoluteFilePath - The absolute file path of the file to be uploads
+ * @throws Exception
+ */
+ public static function uploadPhoto(string $moduleAPIName, string $recordId, string $absoluteFilePath)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$absoluteFilePath = "/Users/use_name/Desktop/image.png"
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of FileBodyWrapper class that will contain the request file
+ $fileBodyWrapper = new FileBodyWrapper();
+
+ //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
+ $streamWrapper = new StreamWrapper(null, null, $absoluteFilePath);
+
+ //Set file to the FileBodyWrapper instance
+ $fileBodyWrapper->setFile($streamWrapper);
+
+ //Call uploadPhoto method that takes FileBodyWrapper instance, moduleAPIName and recordId as parameter
+ $response = $recordOperations->uploadPhoto($recordId, $moduleAPIName,$fileBodyWrapper);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $fileHandler = $response->getObject();
+
+ //Check if the request is successful
+ if($fileHandler instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $fileHandler;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($fileHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $fileHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * This method is used to delete a photo from a record in a module.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @param recordId - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function deletePhoto(string $moduleAPIName, string $recordId)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Call getAttachments method that takes moduleAPIName and recordId as parameter
+ $response = $recordOperations->deletePhoto($recordId,$moduleAPIName);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $fileHandler = $response->getObject();
+
+ //Check if the request is successful
+ if($fileHandler instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $fileHandler;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($successResponse->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($successResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($fileHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $fileHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * This method is used to update the values of specific fields for multiple records and print the response.
+ * @param moduleAPIName - The API Name of the module to obtain records.
+ * @throws Exception
+ */
+ public static function massUpdateRecords(string $moduleAPIName)
+ {
+ //API Name of the module to massUpdateRecords
+ //$moduleAPIName = "Leads";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of MassUpdateBodyWrapper Class that will contain the request body
+ $request = new MassUpdateBodyWrapper();
+
+ //List of Record instances
+ $records = array();
+
+ $recordClass = 'com\zoho\crm\api\record\Record';
+
+ //Get instance of Record Class
+ $record1 = new $recordClass();
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ $record1->addKeyValue("City", "Value");
+
+ //Add Record instance to the list
+ array_push($records, $record1);
+
+ //Set the list to Records in BodyWrapper instance
+ $request->setData($records);
+
+ $request->setCvid("3477061000000087501");
+
+ // $ids = array("3477061000006603276");
+
+ // $request->setIds($ids);
+
+ // $territory = new Territory();
+
+ // $territory->setId("3477061000003051357");
+
+ // $territory->setIncludeChild(true);
+
+ // $request->setTerritory($territory);
+
+ $request->setOverWrite(true);
+
+ //Call massUpdateRecords method that takes BodyWrapper instance, ModuleAPIName as parameter.
+ $response = $recordOperations->massUpdateRecords($moduleAPIName, $request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $massUpdateActionHandler = $response->getObject();
+
+ if($massUpdateActionHandler instanceof MassUpdateActionWrapper)
+ {
+ //Get the received MassUpdateActionWrapper instance
+ $massUpdateActionWrapper = $massUpdateActionHandler;
+
+ //Get the list of obtained MassUpdateActionResponse instances
+ $massUpdateActionResponses = $massUpdateActionWrapper->getData();
+
+ foreach($massUpdateActionResponses as $massUpdateActionResponse)
+ {
+ //Check if the request is successful
+ if($massUpdateActionResponse instanceof MassUpdateSuccessResponse)
+ {
+ //Get the received MassUpdateSuccessResponse instance
+ $massUpdateSuccessResponse = $massUpdateActionResponse;
+
+ //Get the Status
+ echo("Status: " . $massUpdateSuccessResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $massUpdateSuccessResponse->getCode()->getValue() . "\n");
+
+ if($massUpdateSuccessResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach ($massUpdateSuccessResponse->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": ");
+
+ print_r($keyValue);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $massUpdateSuccessResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($massUpdateActionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $massUpdateActionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($massUpdateActionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $massUpdateActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * This method is used to get the status of the mass update job scheduled previously and print the response.
+ * @param moduleAPIName- The API Name of the module to obtain records.
+ * @param jobId - The ID of the job from the response of Mass Update Records.
+ * @throws Exception
+ */
+ public static function getMassUpdateStatus(string $moduleAPIName, string $jobId)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of RecordOperations Class
+ $recordOperations = new RecordOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetMassUpdateStatusParam::jobId(), $jobId);
+
+ //Call getRecord method that takes paramInstance, moduleAPIName as parameter
+ $response = $recordOperations->getMassUpdateStatus($moduleAPIName,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $massUpdateResponseHandler = $response->getObject();
+
+ if($massUpdateResponseHandler instanceof MassUpdateResponseWrapper)
+ {
+ //Get the received MassUpdateResponseWrapper instance
+ $massUpdateResponseWrapper = $massUpdateResponseHandler;
+
+ //Get the list of obtained MassUpdateResponse instances
+ $massUpdateResponses = $massUpdateResponseWrapper->getData();
+
+ foreach($massUpdateResponses as $massUpdateResponse)
+ {
+ //Check if the request is successful
+ if($massUpdateResponse instanceof MassUpdate)
+ {
+ //Get the received MassUpdate instance
+ $massUpdate = $massUpdateResponse;
+
+ //Get the Status of each MassUpdate
+ echo("MassUpdate Status: " . $massUpdate->getStatus()->getValue() . "\n");
+
+ //Get the FailedCount of each MassUpdate
+ echo("MassUpdate FailedCount: " . $massUpdate->getFailedCount() . "\n");
+
+ //Get the UpdatedCount of each MassUpdate
+ echo("MassUpdate UpdatedCount: " . $massUpdate->getUpdatedCount() . "\n");
+
+ //Get the NotUpdatedCount of each MassUpdate
+ echo("MassUpdate NotUpdatedCount: " . $massUpdate->getNotUpdatedCount() . "\n");
+
+ //Get the TotalCount of each MassUpdate
+ echo("MassUpdate TotalCount: " . $massUpdate->getTotalCount() . "\n");
+
+ }
+ //Check if the request returned an exception
+ else if($massUpdateResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $massUpdateResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($massUpdateResponseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $massUpdateResponseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/relatedlist/RelatedList.php b/samples/src/com/zoho/crm/api/relatedlist/RelatedList.php
new file mode 100644
index 0000000..df9c661
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/relatedlist/RelatedList.php
@@ -0,0 +1,205 @@
+ Get RelatedLists
+ * This method is used to get the related list data of a particular module and print the response.
+ * @param moduleAPIName - The API Name of the module to get related lists
+ * @throws Exception
+ */
+ public static function getRelatedLists(string $moduleAPIName)
+ {
+ //example, moduleAPIName = "Leads";
+
+ //Get instance of RelatedListsOperations Class that takes moduleAPIName as parameter
+ $relatedListsOperations = new RelatedListsOperations($moduleAPIName);
+
+ //Call getRelatedLists method
+ $response = $relatedListsOperations->getRelatedLists();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained RelatedList instances
+ $relatedLists = $responseWrapper->getRelatedLists();
+
+ foreach($relatedLists as $relatedList)
+ {
+ //Get the SequenceNumber of each RelatedList
+ echo("RelatedList SequenceNumber: " . $relatedList->getSequenceNumber() . "\n");
+
+ //Get the DisplayLabel of each RelatedList
+ echo("RelatedList DisplayLabel: " . $relatedList->getDisplayLabel() . "\n");
+
+ //Get the APIName of each RelatedList
+ echo("RelatedList APIName: " . $relatedList->getAPIName() . "\n");
+
+ //Get the Module of each RelatedList
+ echo("RelatedList Module: " . $relatedList->getModule() . "\n");
+
+ //Get the Name of each RelatedList
+ echo("RelatedList Name: " . $relatedList->getName() . "\n");
+
+ //Get the Action of each RelatedList
+ echo("RelatedList Action: " . $relatedList->getAction() . "\n");
+
+ //Get the ID of each RelatedList
+ echo("RelatedList ID: " . $relatedList->getId() . "\n");
+
+ //Get the Href of each RelatedList
+ echo("RelatedList Href: " . $relatedList->getHref() . "\n");
+
+ //Get the Type of each RelatedList
+ echo("RelatedList Type: " . $relatedList->getType() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get RelatedList
+ * This method is used to get the single related list data of a particular module with relatedListId and print the response.
+ * @param moduleAPIName - The API Name of the module to get related list
+ * @param relatedListId - The ID of the relatedList to be obtained
+ * @throws Exception
+ */
+ public static function getRelatedList(string $moduleAPIName, string $relatedListId)
+ {
+ //example,
+ //moduleAPIName = "Leads";
+ //relatedListId = "525508000005067912";
+
+ //Get instance of RelatedListsOperations Class that takes moduleAPIName as parameter
+ $relatedListsOperations = new RelatedListsOperations($moduleAPIName);
+
+ //Call getRelatedLists method which takes relatedListId as parameter
+ $response = $relatedListsOperations->getRelatedList($relatedListId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained CustomView instances
+ $relatedLists = $responseWrapper->getRelatedLists();
+
+ foreach($relatedLists as $relatedList)
+ {
+ //Get the SequenceNumber of each RelatedList
+ echo("RelatedList SequenceNumber: " . $relatedList->getSequenceNumber() . "\n");
+
+ //Get the DisplayLabel of each RelatedList
+ echo("RelatedList DisplayLabel: " . $relatedList->getDisplayLabel() . "\n");
+
+ //Get the APIName of each RelatedList
+ echo("RelatedList APIName: " . $relatedList->getAPIName() . "\n");
+
+ //Get the Module of each RelatedList
+ echo("RelatedList Module: " . $relatedList->getModule() . "\n");
+
+ //Get the Name of each RelatedList
+ echo("RelatedList Name: " . $relatedList->getName() . "\n");
+
+ //Get the Action of each RelatedList
+ echo("RelatedList Action: " . $relatedList->getAction() . "\n");
+
+ //Get the ID of each RelatedList
+ echo("RelatedList ID: " . $relatedList->getId() . "\n");
+
+ //Get the Href of each RelatedList
+ echo("RelatedList Href: " . $relatedList->getHref() . "\n");
+
+ //Get the Type of each RelatedList
+ echo("RelatedList Type: " . $relatedList->getType() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/relatedrecords/RelatedRecords.php b/samples/src/com/zoho/crm/api/relatedrecords/RelatedRecords.php
new file mode 100644
index 0000000..1e72276
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/relatedrecords/RelatedRecords.php
@@ -0,0 +1,1943 @@
+ Get Related Records
+ * This method is used to get the related list records and print the response.
+ * @param moduleAPIName - The API Name of the module to get related records.
+ * @param recordId - The ID of the record to be obtained.
+ * @param relatedListAPIName - The API name of the related list. To get the API name of the related list.
+ * @throws Exception
+ */
+ public static function getRelatedRecords(string $moduleAPIName, string $recordId, string $relatedListAPIName)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$relatedListAPIName = "Products";
+
+ //Get instance of RelatedRecordsOperations Class that takes moduleAPIName, recordId and relatedListAPIName as parameter
+ $relatedRecordsOperations = new RelatedRecordsOperations( $relatedListAPIName, $recordId, $moduleAPIName);
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetRelatedRecordsParam::page(), 1);
+
+ $paramInstance->add(GetRelatedRecordsParam::perPage(), 2);
+
+ //Get instance of HeaderMap Class
+ $headerInstance = new HeaderMap();
+
+ $datetime = date_create("2019-02-26T15:28:34+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $headerInstance->add(GetRelatedRecordsHeader::IfModifiedSince(), $datetime);
+
+ //Call getRelatedRecords method that takes paramInstance, headerInstance as parameter
+ $response = $relatedRecordsOperations->getRelatedRecords($paramInstance, $headerInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Record instance
+ $records = $responseWrapper->getData();
+
+ if($records != null)
+ {
+ foreach($records as $record)
+ {
+ //Get the ID of each Record
+ echo("RelatedRecord ID: " . $record->getId() . "\n");
+
+ //Get the createdBy User instance of each Record
+ $createdBy = $record->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("RelatedRecord Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("RelatedRecord Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("RelatedRecord Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the CreatedTime of each Record
+ echo("RelatedRecord CreatedTime: ");
+
+ print_r($record->getCreatedTime());
+
+ echo("\n");
+
+ //Get the modifiedBy User instance of each Record
+ $modifiedBy = $record->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("RelatedRecord Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("RelatedRecord Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("RelatedRecord Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the ModifiedTime of each Record
+ echo("RelatedRecord ModifiedTime: ");
+
+ print_r($record->getModifiedTime());
+
+ echo("\n");
+
+ //Get the list of Tag instance each Record
+ $tags = $record->getTag();
+
+ //Check if tags is not null
+ if($tags != null)
+ {
+ foreach($tags as $tag)
+ {
+ //Get the Name of each Tag
+ echo("RelatedRecord Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("RelatedRecord Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+
+ //To get particular field value
+ echo("RelatedRecord Field Value: " . $record->getKeyValue("Last_Name") . "\n");// FieldApiName
+
+ echo("RelatedRecord KeyValues : \n" );
+
+ //Get the KeyValue map
+ foreach($record->getKeyValues() as $keyName => $value)
+ {
+ if($value != null)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ if($value[0] instanceof FileDetails)
+ {
+ $fileDetails = $value;
+
+ foreach($fileDetails as $fileDetail)
+ {
+ //Get the Extn of each FileDetails
+ echo("RelatedRecord FileDetails Extn: " . $fileDetail->getExtn() . "\n");
+
+ //Get the IsPreviewAvailable of each FileDetails
+ echo("RelatedRecord FileDetails IsPreviewAvailable: " . $fileDetail->getIsPreviewAvailable() . "\n");
+
+ //Get the DownloadUrl of each FileDetails
+ echo("RelatedRecord FileDetails DownloadUrl: " . $fileDetail->getDownloadUrl() . "\n");
+
+ //Get the DeleteUrl of each FileDetails
+ echo("RelatedRecord FileDetails DeleteUrl: " . $fileDetail->getDeleteUrl() . "\n");
+
+ //Get the EntityId of each FileDetails
+ echo("RelatedRecord FileDetails EntityId: " . $fileDetail->getEntityId() . "\n");
+
+ //Get the Mode of each FileDetails
+ echo("RelatedRecord FileDetails Mode: " . $fileDetail->getMode() . "\n");
+
+ //Get the OriginalSizeByte of each FileDetails
+ echo("RelatedRecord FileDetails OriginalSizeByte: " . $fileDetail->getOriginalSizeByte() . "\n");
+
+ //Get the PreviewUrl of each FileDetails
+ echo("RelatedRecord FileDetails PreviewUrl: " . $fileDetail->getPreviewUrl() . "\n");
+
+ //Get the FileName of each FileDetails
+ echo("RelatedRecord FileDetails FileName: " . $fileDetail->getFileName() . "\n");
+
+ //Get the FileId of each FileDetails
+ echo("RelatedRecord FileDetails FileId: " . $fileDetail->getFileId() . "\n");
+
+ //Get the AttachmentId of each FileDetails
+ echo("RelatedRecord FileDetails AttachmentId: " . $fileDetail->getAttachmentId() . "\n");
+
+ //Get the FileSize of each FileDetails
+ echo("RelatedRecord FileDetails FileSize: " . $fileDetail->getFileSize() . "\n");
+
+ //Get the CreatorId of each FileDetails
+ echo("RelatedRecord FileDetails CreatorId: " . $fileDetail->getCreatorId() . "\n");
+
+ //Get the LinkDocs of each FileDetails
+ echo("RelatedRecord FileDetails LinkDocs: " . $fileDetail->getLinkDocs() . "\n");
+ }
+ }
+ else if($value[0] instanceof InventoryLineItems)
+ {
+ $productDetails = $value;
+
+ foreach($productDetails as $productDetail)
+ {
+ $lineItemProduct = $productDetail->getProduct();
+
+ if($lineItemProduct != null)
+ {
+ echo("RelatedRecord ProductDetails LineItemProduct ProductCode: " . $lineItemProduct->getProductCode() . "\n");
+
+ echo("RelatedRecord ProductDetails LineItemProduct Currency: " . $lineItemProduct->getCurrency() . "\n");
+
+ echo("RelatedRecord ProductDetails LineItemProduct Name: " . $lineItemProduct->getName() . "\n");
+
+ echo("RelatedRecord ProductDetails LineItemProduct Id: " . $lineItemProduct->getId() . "\n");
+ }
+
+ echo("RelatedRecord ProductDetails Quantity: " . $productDetail->getQuantity(). "\n");
+
+ echo("RelatedRecord ProductDetails Discount: " . $productDetail->getDiscount() . "\n");
+
+ echo("RelatedRecord ProductDetails TotalAfterDiscount: " . $productDetail->getTotalAfterDiscount(). "\n");
+
+ echo("RelatedRecord ProductDetails NetTotal: " . $productDetail->getNetTotal(). "\n");
+
+ if($productDetail->getBook() != null)
+ {
+ echo("RelatedRecord ProductDetails Book: " . $productDetail->getBook(). "\n");
+ }
+
+ echo("RelatedRecord ProductDetails Tax: " . $productDetail->getTax(). "\n");
+
+ echo("RelatedRecord ProductDetails ListPrice: " . $productDetail->getListPrice(). "\n");
+
+ echo("RelatedRecord ProductDetails UnitPrice: " . $productDetail->getUnitPrice(). "\n");
+
+ echo("RelatedRecord ProductDetails QuantityInStock: " . $productDetail->getQuantityInStock(). "\n");
+
+ echo("RelatedRecord ProductDetails Total: " . $productDetail->getTotal(). "\n");
+
+ echo("RelatedRecord ProductDetails ID: " . $productDetail->getId() . "\n");
+
+ echo("RelatedRecord ProductDetails ProductDescription: " . $productDetail->getProductDescription() . "\n");
+
+ $lineTaxes = $productDetail->getLineTax();
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("RelatedRecord ProductDetails LineTax Percentage: " . $lineTax->getPercentage(). "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Value: " . $lineTax->getValue(). "\n");
+ }
+ }
+ }
+ else if($value[0] instanceof Tag)
+ {
+ $tagList = $value;
+
+ foreach($tagList as $tag)
+ {
+ //Get the Name of each Tag
+ echo("RelatedRecord Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("RelatedRecord Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof PricingDetails)
+ {
+ $pricingDetails = $value;
+
+ foreach($pricingDetails as $pricingDetail)
+ {
+ echo("RelatedRecord PricingDetails ToRange: " . $pricingDetail->getToRange(). "\n");
+
+ echo("RelatedRecord PricingDetails Discount: " . $pricingDetail->getDiscount(). "\n");
+
+ echo("RelatedRecord PricingDetails ID: " . $pricingDetail->getId() . "\n");
+
+ echo("RelatedRecord PricingDetails FromRange: " . $pricingDetail->getFromRange(). "\n");
+ }
+ }
+ else if($value[0] instanceof Participants)
+ {
+ $participants = $value;
+
+ foreach($participants as $participant)
+ {
+ echo("RelatedRecord Participants Name: " . $participant->getName() . "\n");
+
+ echo("RelatedRecord Participants Invited: " . $participant->getInvited() . "\n");
+
+ echo("RelatedRecord Participants ID: " . $participant->getId() . "\n");
+
+ echo("RelatedRecord Participants Type: " . $participant->getType() . "\n");
+
+ echo("RelatedRecord Participants Participant: " . $participant->getParticipant() . "\n");
+
+ echo("RelatedRecord Participants Status: " . $participant->getStatus() . "\n");
+ }
+ }
+ else if($value[0] instanceof Record)
+ {
+ $recordList = $value;
+
+ foreach($recordList as $record1)
+ {
+ //Get the details map
+ foreach($record1->getKeyValues() as $key => $value1)
+ {
+ //Get each value in the map
+ echo($key . " : " );
+
+ print_r($value1);
+
+ echo("\n");
+ }
+ }
+ }
+ else if($value[0] instanceof LineTax)
+ {
+ $lineTaxes = $value;
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("RelatedRecord ProductDetails LineTax Percentage: " . $lineTax->getPercentage(). "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Value: " . $lineTax->getValue(). "\n");
+ }
+ }
+ else if($value[0] instanceof Choice)
+ {
+ $choice = $value;
+
+ foreach($choice as $choiceValue)
+ {
+ echo("RelatedRecord " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ }
+ else if($value[0] instanceof Comment)
+ {
+ $comments = $value;
+
+ foreach($comments as $comment)
+ {
+ echo("Record Comment CommentedBy: " . $comment->getCommentedBy() . "\n");
+
+ echo("Record Comment CommentedTime: ");
+
+ print_r($comment->getCommentedTime());
+
+ echo("\n");
+
+ echo("Record Comment CommentContent: " . $comment->getCommentContent(). "\n");
+
+ echo("Record Comment Id: " . $comment->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof Attachment)
+ {
+ $attachments = $value;
+
+ foreach ($attachments as $attachment)
+ {
+ //Get the owner User instance of each attachment
+ $owner = $attachment->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the Name of the Owner
+ echo("RelatedRecord Attachment Owner User-Name: " . $owner->getName() . "\n");
+
+ //Get the ID of the Owner
+ echo("RelatedRecord Attachment Owner User-ID: " . $owner->getId() . "\n");
+
+ //Get the Email of the Owner
+ echo("RelatedRecord Attachment Owner User-Email: " . $owner->getEmail() . "\n");
+ }
+
+ //Get the modified time of each attachment
+ echo("RelatedRecord Attachment Modified Time: ");
+
+ print_r($attachment->getModifiedTime());
+
+ echo("\n");
+
+ //Get the name of the File
+ echo("RelatedRecord Attachment File Name: " . $attachment->getFileName() . "\n");
+
+ //Get the created time of each attachment
+ echo("RelatedRecord Attachment Created Time: " );
+
+ print_r($attachment->getCreatedTime());
+
+ echo("\n");
+
+ //Get the Attachment file size
+ echo("RelatedRecord Attachment File Size: " . $attachment->getSize() . "\n");
+
+ //Get the parentId Record instance of each attachment
+ $parentId = $attachment->getParentId();
+
+ //Check if parentId is not null
+ if($parentId != null)
+ {
+ //Get the parent record Name of each attachment
+ echo("RelatedRecord Attachment parent record Name: " . $parentId->getKeyValue("name") . "\n");
+
+ //Get the parent record ID of each attachment
+ echo("RelatedRecord Attachment parent record ID: " . $parentId->getId() . "\n");
+ }
+
+ //Get the attachment is Editable
+ echo("RelatedRecord Attachment is Editable: " . $attachment->getEditable() . "\n");
+
+ //Get the file ID of each attachment
+ echo("RelatedRecord Attachment File ID: " . $attachment->getFileId() . "\n");
+
+ //Get the type of each attachment
+ echo("RelatedRecord Attachment File Type: " . $attachment->getType() . "\n");
+
+ //Get the seModule of each attachment
+ echo("RelatedRecord Attachment seModule: " . $attachment->getSeModule() . "\n");
+
+ //Get the modifiedBy User instance of each attachment
+ $modifiedBy = $attachment->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("RelatedRecord Attachment Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("RelatedRecord Attachment Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("RelatedRecord Attachment Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the state of each attachment
+ echo("RelatedRecord Attachment State: " . $attachment->getState() . "\n");
+
+ //Get the ID of each attachment
+ echo("RelatedRecord Attachment ID: " . $attachment->getId() . "\n");
+
+ //Get the createdBy User instance of each attachment
+ $createdBy = $attachment->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the name of the createdBy User
+ echo("RelatedRecord Attachment Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("RelatedRecord Attachment Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("RelatedRecord Attachment Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the linkUrl of each attachment
+ echo("RelatedRecord Attachment LinkUrl: " . $attachment->getLinkUrl() . "\n");
+ }
+ }
+ else
+ {
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ else if($value instanceof Layout)
+ {
+ $layout = $value;
+
+ if($layout != null)
+ {
+ echo("RelatedRecord " . $keyName. " ID: " . $layout->getId() . "\n");
+
+ echo("RelatedRecord " . $keyName . " Name: " . $layout->getName() . "\n");
+ }
+ }
+ else if($value instanceof User)
+ {
+ $user = $value;
+
+ if($user != null)
+ {
+ echo("RelatedRecord " . $keyName . " User-ID: " . $user->getId() . "\n");
+
+ echo("RelatedRecord " . $keyName . " User-Name: " . $user->getName() . "\n");
+
+ echo("RelatedRecord " . $keyName . " User-Email: " . $user->getEmail() . "\n");
+ }
+ }
+ else if($value instanceof Choice)
+ {
+ $choiceValue = $value;
+
+ echo("RelatedRecord " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ else if($value instanceof Record)
+ {
+ $recordValue = $value;
+
+ echo("RelatedRecord " . $keyName . " ID: " . $recordValue->getId() . "\n");
+
+ echo("RelatedRecord " . $keyName . " Name: " . $recordValue->getKeyValue("name") . "\n");
+ }
+ else if($value instanceof Consent)
+ {
+ $consent = $value;
+
+ echo("RelatedRecord Consent ID: " . $consent->getId());
+
+ //Get the Owner User instance of each attachment
+ $owner = $consent->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the name of the owner User
+ echo("RelatedRecord Consent Owner Name: " . $owner->getName());
+
+ //Get the ID of the owner User
+ echo("RelatedRecord Consent Owner ID: " . $owner->getId());
+
+ //Get the Email of the owner User
+ echo("RelatedRecord Consent Owner Email: " . $owner->getEmail());
+ }
+
+ $consentCreatedBy = $consent->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($consentCreatedBy != null)
+ {
+ //Get the name of the CreatedBy User
+ echo("RelatedRecord Consent CreatedBy Name: " . $consentCreatedBy->getName());
+
+ //Get the ID of the CreatedBy User
+ echo("RelatedRecord Consent CreatedBy ID: " . $consentCreatedBy->getId());
+
+ //Get the Email of the CreatedBy User
+ echo("RelatedRecord Consent CreatedBy Email: " . $consentCreatedBy->getEmail());
+ }
+
+ $consentModifiedBy = $consent->getModifiedBy();
+
+ //Check if createdBy is not null
+ if($consentModifiedBy != null)
+ {
+ //Get the name of the ModifiedBy User
+ echo("RelatedRecord Consent ModifiedBy Name: " . $consentModifiedBy->getName());
+
+ //Get the ID of the ModifiedBy User
+ echo("RelatedRecord Consent ModifiedBy ID: " . $consentModifiedBy->getId());
+
+ //Get the Email of the ModifiedBy User
+ echo("RelatedRecord Consent ModifiedBy Email: " . $consentModifiedBy->getEmail());
+ }
+
+ echo("RelatedRecord Consent CreatedTime: " . $consent->getCreatedTime());
+
+ echo("RelatedRecord Consent ModifiedTime: " . $consent->getModifiedTime());
+
+ echo("RelatedRecord Consent ContactThroughEmail: " . $consent->getContactThroughEmail());
+
+ echo("RelatedRecord Consent ContactThroughSocial: " . $consent->getContactThroughSocial());
+
+ echo("RelatedRecord Consent ContactThroughSurvey: " . $consent->getContactThroughSurvey());
+
+ echo("RelatedRecord Consent ContactThroughPhone: " . $consent->getContactThroughPhone());
+
+ echo("RelatedRecord Consent MailSentTime: " . $consent->getMailSentTime().toString());
+
+ echo("RelatedRecord Consent ConsentDate: " . $consent->getConsentDate().toString());
+
+ echo("RelatedRecord Consent ConsentRemarks: " . $consent->getConsentRemarks());
+
+ echo("RelatedRecord Consent ConsentThrough: " . $consent->getConsentThrough());
+
+ echo("RelatedRecord Consent DataProcessingBasis: " . $consent->getDataProcessingBasis());
+
+ //To get custom values
+ echo("RelatedRecord Consent Lawful Reason: " . $consent->getKeyValue("Lawful_Reason"));
+ }
+ else
+ {
+ //Get each value in the map
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ }
+ }
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getPerPage() != null)
+ {
+ //Get the PerPage of the Info
+ echo("RelatedRecord Info PerPage: " . $info->getPerPage(). "\n");
+ }
+
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("RelatedRecord Info Count: " . $info->getCount(). "\n");
+ }
+
+ if($info->getPage() != null)
+ {
+ //Get the Page of the Info
+ echo("RelatedRecord Info Page: " . $info->getPage(). "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the MoreRecords of the Info
+ echo("RelatedRecord Info MoreRecords: " . $info->getMoreRecords(). "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Update Related Records
+ * This method is used to update the relation between the records and print the response.
+ * @param moduleAPIName - The API Name of the module to update related records.
+ * @param recordId - The ID of the record to be obtained.
+ * @param relatedListAPIName - The API name of the related list. To get the API name of the related list.
+ * @throws Exception
+ */
+ public static function updateRelatedRecords(string $moduleAPIName, string $recordId, string $relatedListAPIName)
+ {
+ //API Name of the module to update record
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$relatedListAPIName = "Products";
+
+ //Get instance of RelatedRecordsOperations Class that takes moduleAPIName, recordId and relatedListAPIName as parameter
+ $relatedRecordsOperations = new RelatedRecordsOperations($relatedListAPIName, $recordId, $moduleAPIName);
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Record instances
+ $records = array();
+
+ //Get instance of Record Class
+ $record1 = new Record();
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ $record1->addKeyValue("id", "3477061000005919001");
+
+ $record1->addKeyValue("list_price", 50.56);
+
+ //Add Record instance to the list
+ array_push($records, $record1);
+
+ //Get instance of Record Class
+ $record2 = new Record();
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+ $record2->addKeyValue("id", "3477061000005917011");
+
+ $record2->addKeyValue("list_price", 50.56);
+
+ //Add Record instance to the list
+ array_push($records, $record2);
+
+ //Set the list to Records in BodyWrapper instance
+ $request->setData($records);
+
+ //Call updateRecord method that takes BodyWrapper instance as parameter.
+ $response = $relatedRecordsOperations->updateRelatedRecords($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Delink Records
+ * This method is used to delete the association between modules and print the response.
+ * @param moduleAPIName - The API Name of the module to delink related records.
+ * @param recordId - The ID of the record to be obtained.
+ * @param relatedListAPIName - The API name of the related list. To get the API name of the related list.
+ * @param relatedListIds - The ID of the related record.
+ * @throws Exception
+ */
+ public static function delinkRecords(string $moduleAPIName, string $recordId, string $relatedListAPIName, array $relatedListIds)
+ {
+ //API Name of the module to update record
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$relatedListAPIName = "Products";
+
+ //Get instance of RelatedRecordsOperations Class that takes moduleAPIName, recordId and relatedListAPIName as parameter
+ $relatedRecordsOperations = new RelatedRecordsOperations($relatedListAPIName, $recordId, $moduleAPIName);
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($relatedListIds as $relatedListId)
+ {
+ $paramInstance->add(DelinkRecordsParam::ids(), $relatedListId);
+ }
+
+ //Call delinkRecords method that takes paramInstance instance as parameter.
+ $response = $relatedRecordsOperations->delinkRecords($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Get Related Record
+ * This method is used to get the single related list record and print the response.
+ * @param moduleAPIName - The API Name of the module to get related record.
+ * @param recordId - The ID of the record to be obtained.
+ * @param relatedListAPIName - The API name of the related list. To get the API name of the related list.
+ * @param relatedListId - The ID of the related record.
+ * @throws Exception
+ */
+ public static function getRelatedRecord(string $moduleAPIName, string $recordId, string $relatedListAPIName, string $relatedListId, string $destinationFolder)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$relatedListAPIName = "Products";
+ //$relatedRecordId = "3477061000004994115";
+ //$destinationFolder = "/Users/user_name/Desktop";
+
+ //Get instance of RelatedRecordsOperations Class that takes moduleAPIName, recordId and relatedListAPIName as parameter
+ $relatedRecordsOperations = new RelatedRecordsOperations($relatedListAPIName, $recordId, $moduleAPIName);
+
+ $headerInstance = new HeaderMap();
+
+ $ifmodifiedsince = date_create("2020-07-15T17:58:47+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $headerInstance->add(GetRelatedRecordHeader::IfModifiedSince(), $ifmodifiedsince);
+
+ //Call getRelatedRecord method that takes headerInstance and relatedRecordId as parameter
+ $response = $relatedRecordsOperations->getRelatedRecord($relatedListId,$headerInstance );
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Record instance
+ $records = $responseWrapper->getData();
+
+ foreach($records as $record)
+ {
+ //Get the ID of each Record
+ echo("RelatedRecord ID: " . $record->getId() . "\n");
+
+ //Get the createdBy User instance of each Record
+ $createdBy = $record->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("RelatedRecord Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("RelatedRecord Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("RelatedRecord Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the CreatedTime of each Record
+ echo("RelatedRecord CreatedTime: ");
+
+ print_r($record->getCreatedTime());
+
+ echo("\n");
+
+ //Get the modifiedBy User instance of each Record
+ $modifiedBy = $record->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("RelatedRecord Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("RelatedRecord Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("RelatedRecord Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the ModifiedTime of each Record
+ echo("RelatedRecord ModifiedTime: ");
+
+ print_r($record->getModifiedTime());
+
+ echo("\n");
+
+ //Get the list of Tag instance each Record
+ $tags = $record->getTag();
+
+ //Check if tags is not null
+ if($tags != null)
+ {
+ foreach($tags as $tag)
+ {
+ //Get the Name of each Tag
+ echo("RelatedRecord Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("RelatedRecord Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+
+ //To get particular field value
+ echo("RelatedRecord Field Value: " . $record->getKeyValue("Last_Name") . "\n");// FieldApiName
+
+ echo("RelatedRecord KeyValues : \n" );
+
+ //Get the KeyValue map
+ foreach($record->getKeyValues() as $keyName => $value)
+ {
+ if($value != null)
+ {
+ if((is_array($value) && sizeof($value) > 0) && isset($value[0]))
+ {
+ if($value[0] instanceof FileDetails)
+ {
+ $fileDetails = $value;
+
+ foreach($fileDetails as $fileDetail)
+ {
+ //Get the Extn of each FileDetails
+ echo("RelatedRecord FileDetails Extn: " . $fileDetail->getExtn() . "\n");
+
+ //Get the IsPreviewAvailable of each FileDetails
+ echo("RelatedRecord FileDetails IsPreviewAvailable: " . $fileDetail->getIsPreviewAvailable() . "\n");
+
+ //Get the DownloadUrl of each FileDetails
+ echo("RelatedRecord FileDetails DownloadUrl: " . $fileDetail->getDownloadUrl() . "\n");
+
+ //Get the DeleteUrl of each FileDetails
+ echo("RelatedRecord FileDetails DeleteUrl: " . $fileDetail->getDeleteUrl() . "\n");
+
+ //Get the EntityId of each FileDetails
+ echo("RelatedRecord FileDetails EntityId: " . $fileDetail->getEntityId() . "\n");
+
+ //Get the Mode of each FileDetails
+ echo("RelatedRecord FileDetails Mode: " . $fileDetail->getMode() . "\n");
+
+ //Get the OriginalSizeByte of each FileDetails
+ echo("RelatedRecord FileDetails OriginalSizeByte: " . $fileDetail->getOriginalSizeByte() . "\n");
+
+ //Get the PreviewUrl of each FileDetails
+ echo("RelatedRecord FileDetails PreviewUrl: " . $fileDetail->getPreviewUrl() . "\n");
+
+ //Get the FileName of each FileDetails
+ echo("RelatedRecord FileDetails FileName: " . $fileDetail->getFileName() . "\n");
+
+ //Get the FileId of each FileDetails
+ echo("RelatedRecord FileDetails FileId: " . $fileDetail->getFileId() . "\n");
+
+ //Get the AttachmentId of each FileDetails
+ echo("RelatedRecord FileDetails AttachmentId: " . $fileDetail->getAttachmentId() . "\n");
+
+ //Get the FileSize of each FileDetails
+ echo("RelatedRecord FileDetails FileSize: " . $fileDetail->getFileSize() . "\n");
+
+ //Get the CreatorId of each FileDetails
+ echo("RelatedRecord FileDetails CreatorId: " . $fileDetail->getCreatorId() . "\n");
+
+ //Get the LinkDocs of each FileDetails
+ echo("RelatedRecord FileDetails LinkDocs: " . $fileDetail->getLinkDocs() . "\n");
+ }
+ }
+ else if($value[0] instanceof InventoryLineItems)
+ {
+ $productDetails = $value;
+
+ foreach($productDetails as $productDetail)
+ {
+ $lineItemProduct = $productDetail->getProduct();
+
+ if($lineItemProduct != null)
+ {
+ echo("RelatedRecord ProductDetails LineItemProduct ProductCode: " . $lineItemProduct->getProductCode() . "\n");
+
+ echo("RelatedRecord ProductDetails LineItemProduct Currency: " . $lineItemProduct->getCurrency() . "\n");
+
+ echo("RelatedRecord ProductDetails LineItemProduct Name: " . $lineItemProduct->getName() . "\n");
+
+ echo("RelatedRecord ProductDetails LineItemProduct Id: " . $lineItemProduct->getId() . "\n");
+ }
+
+ echo("RelatedRecord ProductDetails Quantity: " . $productDetail->getQuantity(). "\n");
+
+ echo("RelatedRecord ProductDetails Discount: " . $productDetail->getDiscount() . "\n");
+
+ echo("RelatedRecord ProductDetails TotalAfterDiscount: " . $productDetail->getTotalAfterDiscount(). "\n");
+
+ echo("RelatedRecord ProductDetails NetTotal: " . $productDetail->getNetTotal(). "\n");
+
+ if($productDetail->getBook() != null)
+ {
+ echo("RelatedRecord ProductDetails Book: " . $productDetail->getBook(). "\n");
+ }
+
+ echo("RelatedRecord ProductDetails Tax: " . $productDetail->getTax(). "\n");
+
+ echo("RelatedRecord ProductDetails ListPrice: " . $productDetail->getListPrice(). "\n");
+
+ echo("RelatedRecord ProductDetails UnitPrice: " . $productDetail->getUnitPrice(). "\n");
+
+ echo("RelatedRecord ProductDetails QuantityInStock: " . $productDetail->getQuantityInStock(). "\n");
+
+ echo("RelatedRecord ProductDetails Total: " . $productDetail->getTotal(). "\n");
+
+ echo("RelatedRecord ProductDetails ID: " . $productDetail->getId() . "\n");
+
+ echo("RelatedRecord ProductDetails ProductDescription: " . $productDetail->getProductDescription() . "\n");
+
+ $lineTaxes = $productDetail->getLineTax();
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("RelatedRecord ProductDetails LineTax Percentage: " . $lineTax->getPercentage(). "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Value: " . $lineTax->getValue(). "\n");
+ }
+ }
+ }
+ else if($value[0] instanceof Tag)
+ {
+ $tagList = $value;
+
+ foreach($tagList as $tag)
+ {
+ //Get the Name of each Tag
+ echo("RelatedRecord Tag Name: " . $tag->getName() . "\n");
+
+ //Get the Id of each Tag
+ echo("RelatedRecord Tag ID: " . $tag->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof PricingDetails)
+ {
+ $pricingDetails = $value;
+
+ foreach($pricingDetails as $pricingDetail)
+ {
+ echo("RelatedRecord PricingDetails ToRange: " . $pricingDetail->getToRange(). "\n");
+
+ echo("RelatedRecord PricingDetails Discount: " . $pricingDetail->getDiscount(). "\n");
+
+ echo("RelatedRecord PricingDetails ID: " . $pricingDetail->getId() . "\n");
+
+ echo("RelatedRecord PricingDetails FromRange: " . $pricingDetail->getFromRange(). "\n");
+ }
+ }
+ else if($value[0] instanceof Participants)
+ {
+ $participants = $value;
+
+ foreach($participants as $participant)
+ {
+ echo("RelatedRecord Participants Name: " . $participant->getName() . "\n");
+
+ echo("RelatedRecord Participants Invited: " . $participant->getInvited() . "\n");
+
+ echo("RelatedRecord Participants ID: " . $participant->getId() . "\n");
+
+ echo("RelatedRecord Participants Type: " . $participant->getType() . "\n");
+
+ echo("RelatedRecord Participants Participant: " . $participant->getParticipant() . "\n");
+
+ echo("RelatedRecord Participants Status: " . $participant->getStatus() . "\n");
+ }
+ }
+ else if($value[0] instanceof Record)
+ {
+ $recordList = $value;
+
+ foreach($recordList as $record1)
+ {
+ //Get the details map
+ foreach($record1->getKeyValues() as $key => $value1)
+ {
+ //Get each value in the map
+ echo($key . " : " );
+
+ print_r($value1);
+
+ echo("\n");
+ }
+ }
+ }
+ else if($value[0] instanceof LineTax)
+ {
+ $lineTaxes = $value;
+
+ foreach($lineTaxes as $lineTax)
+ {
+ echo("RelatedRecord ProductDetails LineTax Percentage: " . $lineTax->getPercentage(). "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Name: " . $lineTax->getName() . "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Id: " . $lineTax->getId() . "\n");
+
+ echo("RelatedRecord ProductDetails LineTax Value: " . $lineTax->getValue(). "\n");
+ }
+ }
+ else if($value[0] instanceof Choice)
+ {
+ $choice = $value;
+
+ foreach($choice as $choiceValue)
+ {
+ echo("RelatedRecord " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ }
+ else if($value[0] instanceof Comment)
+ {
+ $comments = $value;
+
+ foreach($comments as $comment)
+ {
+ echo("Record Comment CommentedBy: " . $comment->getCommentedBy() . "\n");
+
+ echo("Record Comment CommentedTime: ");
+
+ print_r($comment->getCommentedTime());
+
+ echo("\n");
+
+ echo("Record Comment CommentContent: " . $comment->getCommentContent(). "\n");
+
+ echo("Record Comment Id: " . $comment->getId() . "\n");
+ }
+ }
+ else if($value[0] instanceof Attachment)
+ {
+ $attachments = $value;
+
+ foreach ($attachments as $attachment)
+ {
+ //Get the owner User instance of each attachment
+ $owner = $attachment->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the Name of the Owner
+ echo("RelatedRecord Attachment Owner User-Name: " . $owner->getName() . "\n");
+
+ //Get the ID of the Owner
+ echo("RelatedRecord Attachment Owner User-ID: " . $owner->getId() . "\n");
+
+ //Get the Email of the Owner
+ echo("RelatedRecord Attachment Owner User-Email: " . $owner->getEmail() . "\n");
+ }
+
+ //Get the modified time of each attachment
+ echo("RelatedRecord Attachment Modified Time: ");
+
+ print_r($attachment->getModifiedTime());
+
+ echo("\n");
+
+ //Get the name of the File
+ echo("RelatedRecord Attachment File Name: " . $attachment->getFileName() . "\n");
+
+ //Get the created time of each attachment
+ echo("RelatedRecord Attachment Created Time: " );
+
+ print_r($attachment->getCreatedTime());
+
+ echo("\n");
+
+ //Get the Attachment file size
+ echo("RelatedRecord Attachment File Size: " . $attachment->getSize() . "\n");
+
+ //Get the parentId Record instance of each attachment
+ $parentId = $attachment->getParentId();
+
+ //Check if parentId is not null
+ if($parentId != null)
+ {
+ //Get the parent record Name of each attachment
+ echo("RelatedRecord Attachment parent record Name: " . $parentId->getKeyValue("name") . "\n");
+
+ //Get the parent record ID of each attachment
+ echo("RelatedRecord Attachment parent record ID: " . $parentId->getId() . "\n");
+ }
+
+ //Get the attachment is Editable
+ echo("RelatedRecord Attachment is Editable: " . $attachment->getEditable() . "\n");
+
+ //Get the file ID of each attachment
+ echo("RelatedRecord Attachment File ID: " . $attachment->getFileId() . "\n");
+
+ //Get the type of each attachment
+ echo("RelatedRecord Attachment File Type: " . $attachment->getType() . "\n");
+
+ //Get the seModule of each attachment
+ echo("RelatedRecord Attachment seModule: " . $attachment->getSeModule() . "\n");
+
+ //Get the modifiedBy User instance of each attachment
+ $modifiedBy = $attachment->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("RelatedRecord Attachment Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("RelatedRecord Attachment Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the Email of the modifiedBy User
+ echo("RelatedRecord Attachment Modified By User-Email: " . $modifiedBy->getEmail() . "\n");
+ }
+
+ //Get the state of each attachment
+ echo("RelatedRecord Attachment State: " . $attachment->getState() . "\n");
+
+ //Get the ID of each attachment
+ echo("RelatedRecord Attachment ID: " . $attachment->getId() . "\n");
+
+ //Get the createdBy User instance of each attachment
+ $createdBy = $attachment->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the name of the createdBy User
+ echo("RelatedRecord Attachment Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("RelatedRecord Attachment Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the Email of the createdBy User
+ echo("RelatedRecord Attachment Created By User-Email: " . $createdBy->getEmail() . "\n");
+ }
+
+ //Get the linkUrl of each attachment
+ echo("RelatedRecord Attachment LinkUrl: " . $attachment->getLinkUrl() . "\n");
+ }
+ }
+ else
+ {
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ else if($value instanceof Record)
+ {
+ $recordValue = $value;
+
+ echo("RelatedRecord " . $keyName . " ID: " . $recordValue->getId() . "\n");
+
+ echo("RelatedRecord " . $keyName . " Name: " . $recordValue->getKeyValue("name") . "\n");
+ }
+ else if($value instanceof Layout)
+ {
+ $layout = $value;
+
+ if($layout != null)
+ {
+ echo("RelatedRecord " . $keyName. " ID: " . $layout->getId() . "\n");
+
+ echo("RelatedRecord " . $keyName . " Name: " . $layout->getName() . "\n");
+ }
+ }
+ else if($value instanceof User)
+ {
+ $user = $value;
+
+ if($user != null)
+ {
+ echo("RelatedRecord " . $keyName . " User-ID: " . $user->getId() . "\n");
+
+ echo("RelatedRecord " . $keyName . " User-Name: " . $user->getName() . "\n");
+
+ echo("RelatedRecord " . $keyName . " User-Email: " . $user->getEmail() . "\n");
+ }
+ }
+ else if($value instanceof Choice)
+ {
+ $choiceValue = $value;
+
+ echo("RelatedRecord " . $keyName . " : " . $choiceValue->getValue() . "\n");
+ }
+ else if($value instanceof Consent)
+ {
+ $consent = $value;
+
+ echo("RelatedRecord Consent ID: " . $consent->getId());
+
+ //Get the Owner User instance of each attachment
+ $owner = $consent->getOwner();
+
+ //Check if owner is not null
+ if($owner != null)
+ {
+ //Get the name of the owner User
+ echo("RelatedRecord Consent Owner Name: " . $owner->getName());
+
+ //Get the ID of the owner User
+ echo("RelatedRecord Consent Owner ID: " . $owner->getId());
+
+ //Get the Email of the owner User
+ echo("RelatedRecord Consent Owner Email: " . $owner->getEmail());
+ }
+
+ $consentCreatedBy = $consent->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($consentCreatedBy != null)
+ {
+ //Get the name of the CreatedBy User
+ echo("RelatedRecord Consent CreatedBy Name: " . $consentCreatedBy->getName());
+
+ //Get the ID of the CreatedBy User
+ echo("RelatedRecord Consent CreatedBy ID: " . $consentCreatedBy->getId());
+
+ //Get the Email of the CreatedBy User
+ echo("RelatedRecord Consent CreatedBy Email: " . $consentCreatedBy->getEmail());
+ }
+
+ $consentModifiedBy = $consent->getModifiedBy();
+
+ //Check if createdBy is not null
+ if($consentModifiedBy != null)
+ {
+ //Get the name of the ModifiedBy User
+ echo("RelatedRecord Consent ModifiedBy Name: " . $consentModifiedBy->getName());
+
+ //Get the ID of the ModifiedBy User
+ echo("RelatedRecord Consent ModifiedBy ID: " . $consentModifiedBy->getId());
+
+ //Get the Email of the ModifiedBy User
+ echo("RelatedRecord Consent ModifiedBy Email: " . $consentModifiedBy->getEmail());
+ }
+
+ echo("RelatedRecord Consent CreatedTime: " . $consent->getCreatedTime());
+
+ echo("RelatedRecord Consent ModifiedTime: " . $consent->getModifiedTime());
+
+ echo("RelatedRecord Consent ContactThroughEmail: " . $consent->getContactThroughEmail());
+
+ echo("RelatedRecord Consent ContactThroughSocial: " . $consent->getContactThroughSocial());
+
+ echo("RelatedRecord Consent ContactThroughSurvey: " . $consent->getContactThroughSurvey());
+
+ echo("RelatedRecord Consent ContactThroughPhone: " . $consent->getContactThroughPhone());
+
+ echo("RelatedRecord Consent MailSentTime: " . $consent->getMailSentTime().toString());
+
+ echo("RelatedRecord Consent ConsentDate: " . $consent->getConsentDate().toString());
+
+ echo("RelatedRecord Consent ConsentRemarks: " . $consent->getConsentRemarks());
+
+ echo("RelatedRecord Consent ConsentThrough: " . $consent->getConsentThrough());
+
+ echo("RelatedRecord Consent DataProcessingBasis: " . $consent->getDataProcessingBasis());
+
+ //To get custom values
+ echo("RelatedRecord Consent Lawful Reason: " . $consent->getKeyValue("Lawful_Reason"));
+ }
+ else
+ {
+ //Get each value in the map
+ echo($keyName . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+ }
+ }
+ }
+
+ else if($responseHandler instanceof FileBodyWrapper)
+ {
+ //Get object from response
+ $fileBodyWrapper = $responseHandler;
+
+ //Get StreamWrapper instance from the returned FileBodyWrapper instance
+ $streamWrapper = $fileBodyWrapper->getFile();
+
+ //Create a file instance with the absolute_file_path
+ $fp = fopen($destinationFolder."/".$streamWrapper->getName(), "w");
+
+ //Get stream from the response
+ $stream = $streamWrapper->getStream();
+
+ fputs($fp, $stream);
+
+ fclose($fp);
+ }
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+ }
+ }
+
+ /**
+ * Update Related Record
+ * This method is used to update the relation between the records and print the response.
+ * @param moduleAPIName - The API Name of the module to update related record.
+ * @param recordId - The ID of the record to be obtained.
+ * @param relatedListAPIName - The API name of the related list. To get the API name of the related list.
+ * @param relatedListId - The ID of the related record.
+ * @throws Exception
+ */
+ public static function updateRelatedRecord(string $moduleAPIName, string $recordId, string $relatedListAPIName, string $relatedListId)
+ {
+ //API Name of the module to update record
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$relatedListAPIName = "Products";
+ //$relatedRecordId = "3477061000004994115";
+
+ //Get instance of RelatedRecordsOperations Class that takes moduleAPIName, recordId and relatedListAPIName as parameter
+ $relatedRecordsOperations = new RelatedRecordsOperations( $relatedListAPIName, $recordId, $moduleAPIName);
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Record instances
+ $records = array();
+
+ //Get instance of Record Class
+ $record1 = new Record();
+
+ /*
+ * Call addKeyValue method that takes two arguments
+ * 1 -> A string that is the Field's API Name
+ * 2 -> Value
+ */
+
+ $record1->addKeyValue("list_price", 50.56);
+
+ //Add Record instance to the list
+ array_push($records, $record1);
+
+ //Set the list to Records in BodyWrapper instance
+ $request->setData($records);
+
+ //Call updateRecord method that takes BodyWrapper instance, relatedRecordId as parameter.
+ $response = $relatedRecordsOperations->updateRelatedRecord($relatedListId,$request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+
+ }
+ }
+
+ /**
+ * Delink Record
+ * This method is used to delete the association between modules and print the response.
+ * @param moduleAPIName - The API Name of the module to delink related record.
+ * @param recordId - The ID of the record to be obtained.
+ * @param relatedListAPIName - The API name of the related list. To get the API name of the related list.
+ * @param relatedListId - The ID of the related record.
+ * @throws Exception
+ */
+ public static function delinkRecord(string $moduleAPIName, string $recordId, string $relatedListAPIName, string $relatedListId)
+ {
+ //API Name of the module to update record
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+ //$relatedListAPIName = "Products";
+ //$relatedRecordId = "3477061000004994115";
+
+ //Get instance of RelatedRecordsOperations Class that takes moduleAPIName, recordId and relatedListAPIName as parameter
+ $relatedRecordsOperations = new RelatedRecordsOperations($relatedListAPIName,$recordId,$moduleAPIName);
+
+ //Call updateRecord method that takes relatedListId as parameter.
+ $response = $relatedRecordsOperations->delinkRecord($relatedListId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ if($response->isExpected())
+ {
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ else
+ {
+ print_r($response);
+ }
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/role/Role.php b/samples/src/com/zoho/crm/api/role/Role.php
new file mode 100644
index 0000000..6ca3da0
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/role/Role.php
@@ -0,0 +1,236 @@
+ Get Roles
+ * This method is used to retrieve the data of roles through an API request and print the response.
+ * @throws Exception
+ */
+ public static function getRoles()
+ {
+ //example, moduleAPIName = "Leads";
+
+ //Get instance of RolesOperations Class
+ $rolesOperations = new RolesOperations();
+
+ //Call getRoles method
+ $response = $rolesOperations->getRoles();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Role instances
+ $roles = $responseWrapper->getRoles();
+
+ foreach($roles as $role)
+ {
+ //Get the DisplayLabel of each Role
+ echo("Role DisplayLabel: " . $role->getDisplayLabel() . "\n");
+
+ //Get the forecastManager User instance of each Role
+ $forecastManager = $role->getForecastManager();
+
+ //Check if forecastManager is not null
+ if($forecastManager != null)
+ {
+ //Get the ID of the forecast Manager
+ echo("Role Forecast Manager User-ID: " . $forecastManager->getId() . "\n");
+
+ //Get the name of the forecast Manager
+ echo("Role Forecast Manager User-Name: " . $forecastManager->getName() . "\n");
+ }
+
+ //Get the ShareWithPeers of each Role
+ echo("Role ShareWithPeers: " . $role->getShareWithPeers() . "\n");
+
+ //Get the Name of each Role
+ echo("Role Name: " . $role->getName() . "\n");
+
+ //Get the Description of each Role
+ echo("Role Description: " . $role->getDescription() . "\n");
+
+ //Get the Id of each Role
+ echo("Role ID: " . $role->getId() . "\n");
+
+ //Get the reportingTo User instance of each Role
+ $reportingTo = $role->getReportingTo();
+
+ //Check if reportingTo is not null
+ if($reportingTo != null)
+ {
+ //Get the ID of the reportingTo User
+ echo("Role ReportingTo User-ID: " . $reportingTo->getId() . "\n");
+
+ //Get the name of the reportingTo User
+ echo("Role ReportingTo User-Name: " . $reportingTo->getName() . "\n");
+ }
+
+ //Get the AdminUser of each Role
+ echo("Role AdminUser: " . $role->getAdminUser() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Role
+ * This method is used to retrieve the data of single role through an API request and print the response.
+ * @param roleId The ID of the Role to be obtained
+ * @throws Exception
+ */
+ public static function getRole(string $roleId)
+ {
+ //example, roleId = "3477061000000003881";
+
+ //Get instance of RolesOperations Class
+ $rolesOperations = new RolesOperations();
+
+ //Call getRoles method
+ $response = $rolesOperations->getRole($roleId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Role instances
+ $roles = $responseWrapper->getRoles();
+
+ foreach($roles as $role)
+ {
+ //Get the DisplayLabel of each Role
+ echo("Role DisplayLabel: " . $role->getDisplayLabel() . "\n");
+
+ //Get the forecastManager User instance of each Role
+ $forecastManager = $role->getForecastManager();
+
+ //Check if forecastManager is not null
+ if($forecastManager != null)
+ {
+ //Get the ID of the forecast Manager
+ echo("Role Forecast Manager User-ID: " . $forecastManager->getId() . "\n");
+
+ //Get the name of the forecast Manager
+ echo("Role Forecast Manager User-Name: " . $forecastManager->getName() . "\n");
+ }
+
+ //Get the ShareWithPeers of each Role
+ echo("Role ShareWithPeers: " . $role->getShareWithPeers() . "\n");
+
+ //Get the Name of each Role
+ echo("Role Name: " . $role->getName() . "\n");
+
+ //Get the Description of each Role
+ echo("Role Description: " . $role->getDescription() . "\n");
+
+ //Get the Id of each Role
+ echo("Role ID: " . $role->getId() . "\n");
+
+ //Get the reportingTo User instance of each Role
+ $reportingTo = $role->getReportingTo();
+
+ //Check if reportingTo is not null
+ if($reportingTo != null)
+ {
+ //Get the ID of the reportingTo User
+ echo("Role ReportingTo User-ID: " . $reportingTo->getId() . "\n");
+
+ //Get the name of the reportingTo User
+ echo("Role ReportingTo User-Name: " . $reportingTo->getName() . "\n");
+ }
+
+ //Get the AdminUser of each Role
+ echo("Role AdminUser: " . $role->getAdminUser() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/sharerecords/ShareRecords.php b/samples/src/com/zoho/crm/api/sharerecords/ShareRecords.php
new file mode 100644
index 0000000..4d5d71f
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/sharerecords/ShareRecords.php
@@ -0,0 +1,593 @@
+ Get Shared Record Details
+ * This method is used to get the details of a shared record and print the response.
+ * @param moduleAPIName - The API Name of the module to get shared record details.
+ * @param recordId - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function getSharedRecordDetails(string $moduleAPIName, string $recordId)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of ShareRecordsOperations Class that takes moduleAPIName and recordId as parameter
+ $shareRecordsOperations = new ShareRecordsOperations( $recordId,$moduleAPIName);
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetSharedRecordDetailsParam::view(), "summary");
+
+ // $paramInstance->add(GetSharedRecordDetailsParam::sharedTo(), "3477061000005791024");
+
+ //Call getSharedRecordDetails method that takes paramInstance as parameter
+ $response = $shareRecordsOperations->getSharedRecordDetails($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained ShareRecord instance
+ $shareRecords = $responseWrapper->getShare();
+
+ if($shareRecords != null)
+ {
+ foreach($shareRecords as $shareRecord)
+ {
+ //Get the ShareRelatedRecords of each ShareRecord
+ echo("ShareRecord ShareRelatedRecords: " . $shareRecord->getShareRelatedRecords() . "\n");
+
+ //Get the SharedThrough instance of each ShareRecord
+ $sharedThrough = $shareRecord->getSharedThrough();
+
+ //Check if sharedThrough is not null
+ if($sharedThrough != null)
+ {
+ //Get the Module instance of each ShareRecord
+ $module = $sharedThrough->getModule();
+
+ if($module != null)
+ {
+ //Get the ID of the Module
+ echo("RelatedRecord SharedThrough Module ID: " . $module->getId() . "\n");
+
+ //Get the name of the Module
+ echo("RelatedRecord SharedThrough Module Name: " . $module->getName() . "\n");
+ }
+
+ //Get the ID of the SharedThrough
+ echo("RelatedRecord SharedThrough ID: " . $sharedThrough->getId() . "\n");
+ }
+
+ //Get the Permission of each ShareRecord
+ echo("ShareRecord Permission: " . $shareRecord->getPermission() . "\n");
+
+ //Get the shared User instance of each ShareRecord
+ $user = $shareRecord->getUser();
+
+ //Check if user is not null
+ if($user != null)
+ {
+ //Get the ID of the shared User
+ echo("ShareRecord User-ID: " . $user->getId() . "\n");
+
+ //Get the FullName of the shared User
+ echo("RelatedRecord User-FullName: " . $user->getFullName() . "\n");
+
+ //Get the Zuid of the shared User
+ echo("RelatedRecord User-Zuid: " . $user->getZuid() . "\n");
+ }
+ }
+ }
+ if($responseWrapper->getShareableUser() != null)
+ {
+ $shareableUsers = $responseWrapper->getShareableUser();
+
+ foreach($shareableUsers as $shareableUser)
+ {
+ //Get the ID of the shareable User
+ echo("ShareRecord User-ID: " . $shareableUser->getId());
+
+ //Get the FullName of the shareable User
+ echo("ShareRecord User-FullName: " . $shareableUser->getFullName());
+
+ //Get the Zuid of the shareable User
+ echo("ShareRecord User-Zuid: " . $shareableUser->getZuid());
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Share Record
+ * This method is used to share the record and print the response.
+ * @param moduleAPIName - The API Name of the module to shared record.
+ * @param recordId - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function shareRecord(string $moduleAPIName, string $recordId)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of ShareRecordsOperations Class that takes moduleAPIName and recordId as parameter
+ $shareRecordsOperations = new ShareRecordsOperations( $recordId,$moduleAPIName);
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of ShareRecord instances
+ $shareList = array();
+
+ //Get instance of ShareRecord Class
+ $share1 = new ShareRecord();
+
+ for($i = 0; $i < 1; $i++)
+ {
+ //Get instance of ShareRecord Class
+ $share1 = new ShareRecord();
+
+// Set the record is shared with or without related records.
+ $share1->setShareRelatedRecords(true);
+
+ //Set the access permission given to the user for that record.
+ $share1->setPermission("read_write");
+
+ $user = new User();
+
+ $user->setId("3477061000005791024");
+
+ //Set the users details with whom the record is shared.
+ $share1->setUser($user);
+
+ array_push($shareList, $share1);
+ }
+
+ $share1 = new ShareRecord();
+
+ $share1->setShareRelatedRecords(true);
+
+ $share1->setPermission("read_write");
+
+ $user = new User();
+
+ $user->setId("3477061000005791024");
+
+ $share1->setUser($user);
+
+ array_push($shareList, $share1);
+
+ $request->setShare($shareList);
+
+ //Call getSharedRecordDetails method that takes paramInstance as parameter
+ $response = $shareRecordsOperations->shareRecord($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getShare();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Share Permissions
+ * This method is used to update the sharing permissions of a record granted to users as Read-Write, Read-only, or grant full access.
+ * @param moduleAPIName - The API Name of the module to update share permissions.
+ * @param recordId - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function updateSharePermissions(string $moduleAPIName, string $recordId)
+ {
+ //example
+ //$moduleAPIName = "Leads";
+ //$recordId = "3477061000005177002";
+
+ //Get instance of ShareRecordsOperations Class that takes moduleAPIName and recordId as parameter
+ $shareRecordsOperations = new ShareRecordsOperations( $recordId,$moduleAPIName);
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of ShareRecord instances
+ $shareList = array();
+
+ //Get instance of ShareRecord Class
+ $share1 = new ShareRecord();
+
+ $share1->setShareRelatedRecords(true);
+
+ $share1->setPermission("full_access");
+
+ $user = new User();
+
+ $user->setId("3477061000005791024");
+
+ $share1->setUser($user);
+
+ array_push($shareList, $share1);
+
+ $request->setShare($shareList);
+
+ //Call updateSharePermissions method that takes BodyWrapper instance as parameter
+ $response = $shareRecordsOperations->updateSharePermissions($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getShare();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Revoke Shared Record
+ * This method is used to revoke access to a shared record that was shared to users and print the response.
+ * @param moduleAPIName - The API Name of the module to update share permissions.
+ * @param recordId - The ID of the record to be obtained.
+ * @throws Exception
+ */
+ public static function revokeSharedRecord(string $moduleAPIName, string $recordId)
+ {
+ //example
+ //moduleAPIName = "Leads";
+ //recordId = "3477061000005177002";
+
+ //Get instance of ShareRecordsOperations Class that takes moduleAPIName and recordId as parameter
+ $shareRecordsOperations = new ShareRecordsOperations( $recordId,$moduleAPIName);
+
+ //Call revokeSharedRecord method
+ $response = $shareRecordsOperations->revokeSharedRecord();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $deleteActionHandler = $response->getObject();
+
+ if($deleteActionHandler instanceof DeleteActionWrapper)
+ {
+ //Get the received DeleteActionWrapper instance
+ $deleteActionWrapper = $deleteActionHandler;
+
+ //Get the received DeleteActionResponse instance
+ $deleteActionResponse = $deleteActionWrapper->getShare();
+
+ //Check if the request is successful
+ if($deleteActionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $deleteActionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($deleteActionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $deleteActionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($deleteActionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $deleteActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/tags/Tag.php b/samples/src/com/zoho/crm/api/tags/Tag.php
new file mode 100644
index 0000000..95d642d
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/tags/Tag.php
@@ -0,0 +1,1469 @@
+ Get Tags
+ * This method is used to get all the tags in an organization.
+ * @param moduleAPIName - The API Name of the module to get tags.
+ * @throws Exception
+ */
+ public static function getTags(string $moduleAPIName)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetTagsParam::module(), $moduleAPIName);
+
+ // $paramInstance->add(GetTagsParam::myTags(), ""); //Displays the names of the tags created by the current user.
+
+ //Call getTags method that takes paramInstance as parameter
+ $response = $tagsOperations->getTags($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained ShareRecord instance
+ $tags = $responseWrapper->getTags();
+
+ if($tags != null)
+ {
+ foreach($tags as $tag)
+ {
+ //Get the CreatedTime of each Tag
+ echo("Tag CreatedTime: ");
+
+ print_r($tag->getCreatedTime());
+
+ echo("\n");
+
+ //Get the ModifiedTime of each Tag
+ echo("Tag ModifiedTime: ");
+
+ print_r($tag->getModifiedTime());
+
+ echo("\n");
+
+ //Get the Name of each Tag
+ echo("Tag Name: " . $tag->getName() . "\n");
+
+ //Get the modifiedBy User instance of each Tag
+ $modifiedBy = $tag->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the ID of the modifiedBy User
+ echo("Tag Modified By User-ID: " . $modifiedBy->getId() . "\n");
+
+ //Get the name of the modifiedBy User
+ echo("Tag Modified By User-Name: " . $modifiedBy->getName() . "\n");
+ }
+
+ //Get the ID of each Tag
+ echo("Tag ID: " . $tag->getId() . "\n");
+
+ //Get the createdBy User instance of each Tag
+ $createdBy = $tag->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the ID of the createdBy User
+ echo("Tag Created By User-ID: " . $createdBy->getId() . "\n");
+
+ //Get the name of the createdBy User
+ echo("Tag Created By User-Name: " . $createdBy->getName() . "\n");
+ }
+ }
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("Tag Info Count: " . $info->getCount() . "\n");
+ }
+
+ if($info->getAllowedCount() != null)
+ {
+ //Get the AllowedCount of the Info
+ echo("Tag Info AllowedCount: " . $info->getAllowedCount() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Create Tags
+ * This method is used to create new tags and print the response.
+ * @param moduleAPIName - The API Name of the module to create tags.
+ * @throws Exception
+ */
+ public static function createTags(string $moduleAPIName)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(CreateTagsParam::module(), $moduleAPIName);
+
+ //List of Tag instances
+ $tagList = array();
+
+ $tagClass = 'com\zoho\crm\api\tags\Tag';
+
+ //Get instance of Tag Class
+ $tag1 = new $tagClass();
+
+ $tag1->setName("tagName");
+
+ array_push($tagList, $tag1);
+
+ $request->setTags($tagList);
+
+ //Call createTags method that takes BodyWrapper instance and paramInstance as parameter
+ $response = $tagsOperations->createTags($request, $paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTags();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Tags
+ * This method is used to update multiple tags simultaneously and print the response.
+ * @param moduleAPIName - The API Name of the module to update tags.
+ * @throws Exception
+ */
+ public static function updateTags(string $moduleAPIName)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(UpdateTagsParam::module(), $moduleAPIName);
+
+ //List of Tag instances
+ $tagList = array();
+
+ $tagClass = 'com\zoho\crm\api\tags\Tag';
+
+ //Get instance of Tag Class
+ $tag1 = new $tagClass();
+
+ $tag1->setId("3477061000006454014");
+
+ $tag1->setName("tagName1");
+
+ array_push($tagList, $tag1);
+
+ $request->setTags($tagList);
+
+ //Call updateTags method that takes BodyWrapper instance and paramInstance as parameter
+ $response = $tagsOperations->updateTags($request, $paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTags();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Tag
+ * This method is used to update single tag and print the response.
+ * @param moduleAPIName - The API Name of the module to update tag.
+ * @param tagId - The ID of the tag to be obtained.
+ * @throws Exception
+ */
+ public static function updateTag(string $moduleAPIName, string $tagId)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(UpdateTagParam::module(), $moduleAPIName);
+
+ //List of Tag instances
+ $tagList = array();
+
+ $tagClass = 'com\zoho\crm\api\tags\Tag';
+
+ //Get instance of Tag Class
+ $tag1 = new $tagClass();
+
+ $tag1->setName("tagName13");
+
+ array_push($tagList, $tag1);
+
+ $request->setTags($tagList);
+
+ //Call updateTags method that takes BodyWrapper instance, paramInstance and tagId as parameter
+ $response = $tagsOperations->updateTag($tagId,$request, $paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTags();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Tag
+ * This method is used to delete a tag from the module and print the response.
+ * @param tagId - The ID of the tag to be obtained.
+ * @throws Exception
+ */
+ public static function deleteTag(string $tagId)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Call deleteTag method that takes tag id as parameter
+ $response = $tagsOperations->deleteTag($tagId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTags();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Merge Tag
+ * This method is used to merge tags and put all the records under the two tags into a single tag and print the response.
+ * @param tagId - The ID of the tag to be obtained.
+ * @param conflictId - - The ID of the conflict tag to be obtained.
+ * @throws Exception
+ */
+ public static function mergeTags(string $tagId, string $conflictId)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of MergeWrapper Class that will contain the request body
+ $request = new MergeWrapper();
+
+ //List of Tag ConflictWrapper
+ $tags = array();
+
+ //Get instance of ConflictWrapper Class
+ $mergeTag = new ConflictWrapper();
+
+ $mergeTag->setConflictId($conflictId);
+
+ array_push($tags, $mergeTag);
+
+ $request->setTags($tags);
+
+ //Call deleteTag method that takes MergeWrapper instance and tag id as parameter
+ $response = $tagsOperations->mergeTags($tagId,$request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTags();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Add Tags To Record
+ * This method is used to add tags to a specific record and print the response.
+ * @param moduleAPIName - The API Name of the module to add tag.
+ * @param recordId - The ID of the record to be obtained.
+ * @param tagNames - The names of the tags to be added.
+ * @throws Exception
+ */
+ public static function addTagsToRecord(string $moduleAPIName, string $recordId, array $tagNames)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($tagNames as $tagName)
+ {
+ $paramInstance->add(AddTagsToRecordParam::tagNames(), $tagName);
+ }
+
+ $paramInstance->add(AddTagsToRecordParam::overWrite(), "false");
+
+ //Call addTagsToRecord method that takes paramInstance, moduleAPIName and recordId as parameter
+ $response = $tagsOperations->addTagsToRecord($recordId, $moduleAPIName,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $recordActionHandler = $response->getObject();
+
+ if($recordActionHandler instanceof RecordActionWrapper)
+ {
+ //Get the received RecordActionWrapper instance
+ $recordActionWrapper = $recordActionHandler;
+
+ //Get the list of obtained RecordActionResponse instances
+ $actionResponses = $recordActionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($recordActionHandler instanceof APIException)
+ {
+ //Check if the request returned an exception
+ $exception = $recordActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Remove Tags From Record
+ * This method is used to delete the tag associated with a specific record and print the response.
+ * @param moduleAPIName - The API Name of the module to remove tag.
+ * @param recordId - The ID of the record to be obtained.
+ * @param tagNames - The names of the tags to be remove.
+ * @throws Exception
+ */
+ public static function removeTagsFromRecord(string $moduleAPIName, string $recordId, array $tagNames)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($tagNames as $tagName)
+ {
+ $paramInstance->add(RemoveTagsFromRecordParam::tagNames(), $tagName);
+ }
+
+ //Call removeTagsFromRecord method that takes paramInstance, moduleAPIName and recordId as parameter
+ $response = $tagsOperations->removeTagsFromRecord($recordId, $moduleAPIName,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $recordActionHandler = $response->getObject();
+
+ if($recordActionHandler instanceof RecordActionWrapper)
+ {
+ //Get the received RecordActionWrapper instance
+ $recordActionWrapper = $recordActionHandler;
+
+ //Get the list of obtained RecordActionResponse instances
+ $actionResponses = $recordActionWrapper-> getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($recordActionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $recordActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Add Tags To Multiple Records
+ * This method is used to add tags to multiple records simultaneously and print the response.
+ * @param moduleAPIName - The API Name of the module to add tags.
+ * @param recordIds - The ID of the record to be obtained.
+ * @param tagNames - The names of the tags to be add.
+ * @throws Exception
+ */
+ public static function addTagsToMultipleRecords(string $moduleAPIName, array $recordIds, array $tagNames)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($tagNames as $tagName)
+ {
+ $paramInstance->add(AddTagsToMultipleRecordsParam::tagNames(), $tagName);
+ }
+
+ foreach($recordIds as $recordId)
+ {
+ $paramInstance->add(AddTagsToMultipleRecordsParam::ids(), $recordId);
+ }
+
+ $paramInstance->add(AddTagsToMultipleRecordsParam::overWrite(), "false");
+
+ //Call addTagsToMultipleRecords method that takes paramInstance, moduleAPIName as parameter
+ $response = $tagsOperations->addTagsToMultipleRecords($moduleAPIName,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $recordActionHandler = $response->getObject();
+
+ if($recordActionHandler instanceof RecordActionWrapper)
+ {
+ //Get the received RecordActionWrapper instance
+ $recordActionWrapper = $recordActionHandler;
+
+ //Get the list of obtained RecordActionResponse instances
+ $actionResponses = $recordActionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+
+ //Check if locked count is null
+ if($recordActionWrapper->getLockedCount() != null)
+ {
+ echo("Locked Count: " . $recordActionWrapper->getLockedCount() . "\n");
+ }
+
+ //Check if success count is null
+ if($recordActionWrapper->getSuccessCount() != null)
+ {
+ echo("Success Count: " . $recordActionWrapper->getSuccessCount() . "\n");
+ }
+
+ //Check if wf scheduler is null
+ if($recordActionWrapper->getWfScheduler() != null)
+ {
+ echo("WF Scheduler: " . $recordActionWrapper->getWfScheduler() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($recordActionHandler instanceof APIException)
+ {
+ //Check if the request returned an exception
+ $exception = $recordActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Remove Tags From Multiple Records
+ * This method is used to delete the tags associated with multiple records and print the response.
+ * @param moduleAPIName - The API Name of the module to remove tags.
+ * @param recordIds - The ID of the record to be obtained.
+ * @param tagNames - The names of the tags to be remove.
+ * @throws Exception
+ */
+ public static function removeTagsFromMultipleRecords(string $moduleAPIName, array $recordIds, array $tagNames)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ $paramInstance = new ParameterMap();
+
+ foreach($tagNames as $tagName)
+ {
+ $paramInstance->add(RemoveTagsFromMultipleRecordsParam::tagNames(), $tagName);
+ }
+
+ foreach($recordIds as $recordId)
+ {
+ $paramInstance->add(RemoveTagsFromMultipleRecordsParam::ids(), $recordId);
+ }
+
+ //Call RemoveTagsFromMultipleRecordsParam method that takes paramInstance, moduleAPIName as parameter
+ $response = $tagsOperations->removeTagsFromMultipleRecords($moduleAPIName, $paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $recordActionHandler = $response->getObject();
+
+ if($recordActionHandler instanceof RecordActionWrapper)
+ {
+ //Get the received RecordActionWrapper instance
+ $recordActionWrapper = $recordActionHandler;
+
+ //Get the list of obtained RecordActionResponse instances
+ $actionResponses = $recordActionWrapper->getData();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+
+ //Check if locked count is null
+ if($recordActionWrapper->getLockedCount() != null)
+ {
+ echo("Locked Count: " . $recordActionWrapper->getLockedCount() . "\n");
+ }
+
+ //Check if success count is null
+ if($recordActionWrapper->getSuccessCount() != null)
+ {
+ echo("Success Count: " . $recordActionWrapper->getSuccessCount() . "\n");
+ }
+
+ //Check if wf scheduler is null
+ if($recordActionWrapper->getWfScheduler() != null)
+ {
+ echo("WF Scheduler: " . $recordActionWrapper->getWfScheduler() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($recordActionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $recordActionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Record Count For Tag
+ * This method is used to get the total number of records under a tag and print the response.
+ * @param moduleAPIName - The API Name of the module.
+ * @param tagId - The ID of the tag to be obtained.
+ * @throws Exception
+ */
+ public static function getRecordCountForTag(string $moduleAPIName, string $tagId)
+ {
+ //Get instance of TagsOperations Class
+ $tagsOperations = new TagsOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetRecordCountForTagParam::module(), $moduleAPIName);
+
+ //Call getRecordCountForTag method that takes paramInstance and tagId as parameter
+ $response = $tagsOperations->getRecordCountForTag($tagId,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $countHandler = $response->getObject();
+
+ if($countHandler instanceof CountWrapper)
+ {
+ //Get the received CountWrapper instance
+ $countWrapper = $countHandler;
+
+ //Get the Count of Tag
+ echo("Tag Count: " . $countWrapper->getCount() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($countHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $countHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/taxes/Tax.php b/samples/src/com/zoho/crm/api/taxes/Tax.php
new file mode 100644
index 0000000..3dc715d
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/taxes/Tax.php
@@ -0,0 +1,749 @@
+ Get Taxes
+ * This method is used to get all the Organization Taxes and print the response.
+ * @throws Exception
+ */
+ public static function getTaxes()
+ {
+ //Get instance of TaxesOperations Class
+ $taxesOperations = new TaxesOperations();
+
+ //Call getTaxes method
+ $response = $taxesOperations->getTaxes();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ ////Get the list of obtained Tax instances
+ $taxes = $responseWrapper->getTaxes();
+
+ if($taxes != null)
+ {
+ foreach($taxes as $tax)
+ {
+ //Get the DisplayLabel of each Tax
+ echo("Tax DisplayLabel: " . $tax->getDisplayLabel() . "\n");
+
+ //Get the Name of each Tax
+ echo("Tax Name: " . $tax->getName() . "\n");
+
+ //Get the ID of each Tax
+ echo("Tax ID: " . $tax->getId() . "\n");
+
+ //Get the Value of each Tax
+ echo("Tax Value: " . $tax->getValue() . "\n");
+ }
+
+ //Get the Preference instance of Tag
+ $preference = $responseWrapper->getPreference();
+
+ //Check if preference is not null
+ if($preference != null)
+ {
+ //Get the AutoPopulateTax of each Preference
+ echo("Preference AutoPopulateTax: " . $preference->getAutoPopulateTax() . "\n");
+
+ //Get the ModifyTaxRates of each Preference
+ echo("Preference ModifyTaxRates: " . $preference->getModifyTaxRates() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ }
+
+ /**
+ * Create Taxes
+ * This method is used to create Organization Taxes and print the response.
+ * @throws Exception
+ */
+ public static function createTaxes()
+ {
+ //Get instance of TaxesOperations Class
+ $taxesOperations = new TaxesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Tax instances
+ $taxList = array();
+
+ $tagClass = 'com\zoho\crm\api\taxes\Tax';
+
+ //Get instance of Tax Class
+ $tax1 = new $tagClass();
+
+ $tax1->setName("MyTax22");
+
+ $tax1->setSequenceNumber(2);
+
+ $tax1->setValue(10.0);
+
+ array_push($taxList, $tax1);
+
+ $tax1 = new $tagClass();
+
+ $tax1->setName("MyTax23");
+
+ $tax1->setValue(12.0);
+
+ array_push($taxList, $tax1);
+
+ $request->setTaxes($taxList);
+
+ //Call createTags method that takes BodyWrapper class instance as parameter
+ $response = $taxesOperations->createTaxes($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTaxes();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Taxes
+ * This method is used to update Organization Taxes and print the response.
+ * @throws Exception
+ */
+ public static function updateTaxes()
+ {
+ //Get instance of TaxesOperations Class
+ $taxesOperations = new TaxesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Tax instances
+ $taxList = array();
+
+ $taxClass = 'com\zoho\crm\api\taxes\Tax';
+
+ //Get instance of Tax Class
+ $tax1 = new $taxClass();
+
+ $tax1->setId("3477061000006499001");
+
+ $tax1->setName("MyTax1134");
+
+ $tax1->setSequenceNumber(1);
+
+ $tax1->setValue(15.0);
+
+ array_push($taxList, $tax1);
+
+ //Get instance of Tax Class
+ $tax1 = new $taxClass();
+
+ $tax1->setId("3477061000006499002");
+
+ $tax1->setValue(25.0);
+
+ array_push($taxList, $tax1);
+
+ $tax1 = new $taxClass();
+
+ $tax1->setId("3477061000000339001");
+
+ $tax1->setSequenceNumber(2);
+
+ array_push($taxList, $tax1);
+
+ $request->setTaxes($taxList);
+
+ //Call updateTaxes method that takes BodyWrapper instance as parameter
+ $response = $taxesOperations->updateTaxes($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTaxes();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Taxes
+ * This method is used to delete Organization Taxes and print the response.
+ * @param taxIds - The ID of the tax to be obtainted
+ * @throws Exception
+ */
+ public static function deleteTaxes(array $taxIds)
+ {
+ //Get instance of TaxesOperations Class
+ $taxesOperations = new TaxesOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($taxIds as $taxId)
+ {
+ $paramInstance->add(DeleteTaxesParam::ids(), $taxId);
+ }
+
+ //Call deleteTaxes method that takes paramInstance as parameter
+ $response = $taxesOperations->deleteTaxes($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTaxes();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Tax
+ * This method is used to get the Organization Tax and print the response.
+ * @param taxId - The ID of the tax to be obtainted
+ * @throws Exception
+ */
+ public static function getTax(string $taxId)
+ {
+ //Get instance of TaxesOperations Class
+ $taxesOperations = new TaxesOperations();
+
+ //Call getTax method that takes taxId as parameter
+ $response = $taxesOperations->getTax($taxId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ ////Get the list of obtained Tax instances
+ $taxes = $responseWrapper->getTaxes();
+
+ if($taxes != null)
+ {
+ foreach($taxes as $tax)
+ {
+ //Get the DisplayLabel of each Tax
+ echo("Tax DisplayLabel: " . $tax->getDisplayLabel() . "\n");
+
+ //Get the Name of each Tax
+ echo("Tax Name: " . $tax->getName() . "\n");
+
+ //Get the ID of each Tax
+ echo("Tax ID: " . $tax->getId() . "\n");
+
+ //Get the Value of each Tax
+ echo("Tax Value: " . $tax->getValue() . "\n");
+ }
+
+ //Get the Preference instance of Tag
+ $preference = $responseWrapper->getPreference();
+
+ //Check if preference is not null
+ if($preference != null)
+ {
+ //Get the AutoPopulateTax of each Preference
+ echo("Preference AutoPopulateTax: " . $preference->getAutoPopulateTax() . "\n");
+
+ //Get the ModifyTaxRates of each Preference
+ echo("Preference ModifyTaxRates: " . $preference->getModifyTaxRates() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ }
+
+ /**
+ * Delete Tax
+ * This method is used to delete Organization Tax and print the response.
+ * @param taxId - The ID of the tax to be obtainted
+ * @throws Exception
+ */
+ public static function deleteTax(string $taxId)
+ {
+ //Get instance of TaxesOperations Class
+ $taxesOperations = new TaxesOperations();
+
+ //Call deleteTaxes method that takes taxId as parameter
+ $response = $taxesOperations->deleteTax($taxId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getTaxes();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ if($successResponse->getDetails() != null)
+ {
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : ");
+
+ print_r($value);
+
+ echo("\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/territories/Territory.php b/samples/src/com/zoho/crm/api/territories/Territory.php
new file mode 100644
index 0000000..b7bbd12
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/territories/Territory.php
@@ -0,0 +1,339 @@
+ Get Territories
+ * This method is used to get the list of territories enabled for your organization and print the response.
+ * @throws Exception
+ */
+ public static function getTerritories()
+ {
+ //example, $moduleAPIName = "Leads";
+
+ //Get instance of TerritoriesOperations Class
+ $territoriesOperations = new TerritoriesOperations();
+
+ //Call getTerritories method
+ $response = $territoriesOperations->getTerritories();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Territory instances
+ $territoryList = $responseWrapper->getTerritories();
+
+ if($territoryList != null)
+ {
+ foreach($territoryList as $territory)
+ {
+ //Get the CreatedTime of each Territory
+ echo("Territory CreatedTime: " );
+
+ print_r($territory->getCreatedTime());
+
+ echo("\n");
+
+ //Get the ModifiedTime of each Territory
+ echo("Territory ModifiedTime: " );
+
+ print_r($territory->getModifiedTime());
+
+ echo("\n");
+
+ //Get the manager User instance of each Territory
+ $manager = $territory->getManager();
+
+ //Check if manager is not null
+ if($manager != null)
+ {
+ //Get the Name of the Manager
+ echo("Territory Manager User-Name: " . $manager->getName() . "\n");
+
+ //Get the ID of the Manager
+ echo("Territory Manager User-ID: " . $manager->getId() . "\n");
+ }
+
+ //Get the ParentId of each Territory
+ echo("Territory ParentId: " . $territory->getParentId() . "\n");
+
+ // Get the Criteria instance of each Territory
+ $criteria = $territory->getCriteria();
+
+ //Check if criteria is not null
+ if($criteria != null)
+ {
+ self::printCriteria($criteria);
+ }
+
+ //Get the Name of each Territory
+ echo("Territory Name: " . $territory->getName() . "\n");
+
+ //Get the modifiedBy User instance of each Territory
+ $modifiedBy = $territory->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Territory Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Territory Modified By User-ID: " . $modifiedBy->getId() . "\n");
+ }
+
+ //Get the Description of each Territory
+ echo("Territory Description: " . $territory->getDescription() . "\n");
+
+ //Get the ID of each Territory
+ echo("Territory ID: " . $territory->getId() . "\n");
+
+ //Get the createdBy User instance of each Territory
+ $createdBy = $territory->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("Territory Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Territory Created By User-ID: " . $createdBy->getId() . "\n");
+ }
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Territory
+ * This method is used to get the single territory and print the response.
+ * @param territoryId - The ID of the Territory to be obtainted
+ * @throws Exception
+ */
+ public static function getTerritory(string $territoryId)
+ {
+ //Get instance of TerritoriesOperations Class
+ $territoriesOperations = new TerritoriesOperations();
+
+ //Call getRelatedLists method
+ $response = $territoriesOperations->getTerritory($territoryId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained Territory instances
+ $territoryList = $responseWrapper->getTerritories();
+
+ if($territoryList != null)
+ {
+ foreach($territoryList as $territory)
+ {
+ //Get the CreatedTime of each Territory
+ echo("Territory CreatedTime: " );
+
+ print_r($territory->getCreatedTime());
+
+ echo("\n");
+
+ //Get the ModifiedTime of each Territory
+ echo("Territory ModifiedTime: " );
+
+ print_r($territory->getModifiedTime());
+
+ echo("\n");
+
+ //Get the manager User instance of each Territory
+ $manager = $territory->getManager();
+
+ //Check if manager is not null
+ if($manager != null)
+ {
+ //Get the Name of the Manager
+ echo("Territory Manager User-Name: " . $manager->getName() . "\n");
+
+ //Get the ID of the Manager
+ echo("Territory Manager User-ID: " . $manager->getId() . "\n");
+ }
+
+ //Get the ParentId of each Territory
+ echo("Territory ParentId: " . $territory->getParentId() . "\n");
+
+ // Get the Criteria instance of each Territory
+ $criteria = $territory->getCriteria();
+
+ //Check if criteria is not null
+ if($criteria != null)
+ {
+ self::printCriteria($criteria);
+ }
+
+ //Get the Name of each Territory
+ echo("Territory Name: " . $territory->getName() . "\n");
+
+ //Get the modifiedBy User instance of each Territory
+ $modifiedBy = $territory->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("Territory Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("Territory Modified By User-ID: " . $modifiedBy->getId() . "\n");
+ }
+
+ //Get the Description of each Territory
+ echo("Territory Description: " . $territory->getDescription() . "\n");
+
+ //Get the ID of each Territory
+ echo("Territory ID: " . $territory->getId() . "\n");
+
+ //Get the createdBy User instance of each Territory
+ $createdBy = $territory->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("Territory Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("Territory Created By User-ID: " . $createdBy->getId() . "\n");
+ }
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ private static function printCriteria($criteria)
+ {
+ if($criteria->getField() != null)
+ {
+ //Get the Field of the Criteria
+ echo("Territory Criteria Field: " . $criteria->getField() . "\n");
+ }
+
+ if($criteria->getComparator() != null)
+ {
+ //Get the Comparator of the Criteria
+ echo("Territory Criteria Comparator: " . $criteria->getComparator()->getValue() . "\n");
+ }
+
+ if($criteria->getValue() != null)
+ {
+ //Get the Value of the Criteria
+ echo("Territory Criteria Value: " . $criteria->getValue() . "\n");
+ }
+
+ // Get the List of Criteria instance of each Criteria
+ $criteriaGroup = $criteria->getGroup();
+
+ if($criteriaGroup != null)
+ {
+ foreach($criteriaGroup as $criteria1)
+ {
+ self::printCriteria($criteria1);
+ }
+ }
+
+ if($criteria->getGroupOperator() != null)
+ {
+ //Get the Group Operator of the Criteria
+ echo("Territory Criteria Group Operator: " . $criteria->getGroupOperator()->getValue() . "\n");
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/threading/multiuser/MultiThread.php b/samples/src/com/zoho/crm/api/threading/multiuser/MultiThread.php
new file mode 100644
index 0000000..90b59ab
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/threading/multiuser/MultiThread.php
@@ -0,0 +1,122 @@
+setPickListValidation($pickListValidation)->setAutoRefreshFields($autoRefreshFields)->build();
+
+ $resourcePath = "/Users/user_name/Documents/phpsdk-application";
+
+ Initializer::initialize($user1, $environment1, $token1, $tokenstore, $configInstance, $resourcePath, $logger);
+
+ $this->getRecords("Leads");
+
+ $environment2 = USDataCenter::PRODUCTION();
+
+ $user2 = new UserSignature("xyz@zoho.com");
+
+ $token2 = new OAuthToken("clientId2", "clientSecret2", "REFRESH/GRANT token", TokenType::REFRESH/GRANT, "redirectURL");
+
+ $configInstance2 = $builderInstance->setPickListValidation(false)->setAutoRefreshFields(false)->build();
+
+ Initializer::switchUser($user2, $environment2, $token2, $configInstance2);
+
+ Initializer::removeUserConfiguration($user1, $environment1);
+
+ //Throws Exception when the configuration is not present
+ try
+ {
+ Initializer::removeUserConfiguration($user1, $environment1);
+ }
+ catch(\Exception $ex)
+ {
+ print_r($ex);
+ }
+
+ $this->getRecords("Leads");
+
+ Initializer::switchUser($user1, $environment1, $token1, $configInstance);
+
+ $this->getRecords("apiName2");
+ }
+
+ public function getRecords($moduleAPIName)
+ {
+ try
+ {
+ $recordOperations = new RecordOperations();
+
+ $paramInstance = new ParameterMap();
+
+ $headerInstance = new HeaderMap();
+
+ $ifmodifiedsince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $headerInstance->add(GetRecordsHeader::IfModifiedSince(), $ifmodifiedsince);
+
+ //Call getRecords method that takes moduleAPIName, paramInstance, moduleAPIName as parameter
+ $response = $recordOperations->getRecords($moduleAPIName, $paramInstance, $headerInstance);
+
+ echo($response->getStatusCode() . "\n");
+
+ print_r($response->getObject());
+
+ echo("\n");
+ }
+ catch (\Exception $e)
+ {
+ print_r($e);
+ }
+ }
+}
+
+$obj = new MultiThread();
+
+$obj->main();
+
+?>
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/users/User.php b/samples/src/com/zoho/crm/api/users/User.php
new file mode 100644
index 0000000..200590a
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/users/User.php
@@ -0,0 +1,1358 @@
+ Get Users
+ * This method is used to retrieve the users data specified in the API request.
+ * You can specify the type of users that needs to be retrieved using the Users API.
+ * @throws Exception
+ */
+ public static function getUsers()
+ {
+ //Get instance of UsersOperations Class
+ $usersOperations = new UsersOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetUsersParam::type(), "ActiveUsers");
+
+ $paramInstance->add(GetUsersParam::page(), 1);
+
+ $paramInstance->add(GetUsersParam::perPage(), 1);
+
+ $headerInstance = new HeaderMap();
+
+ $ifmodifiedsince = date_create("2020-07-15T17:58:47+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $headerInstance->add(GetUsersHeader::IfModifiedSince(), $ifmodifiedsince);
+
+ //Call getUsers method that takes paramInstance as parameter
+ $response = $usersOperations->getUsers($paramInstance, $headerInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the list of obtained User instances
+ $users = $responseWrapper->getUsers();
+
+ foreach($users as $user)
+ {
+ //Get the Country of each User
+ echo("User Country: " . $user->getCountry() . "\n");
+
+ // Get the CustomizeInfo instance of each User
+ $customizeInfo = $user->getCustomizeInfo();
+
+ //Check if customizeInfo is not null
+ if($customizeInfo != null)
+ {
+ if($customizeInfo->getNotesDesc() != null)
+ {
+ //Get the NotesDesc of each User
+ echo("User CustomizeInfo NotesDesc: " . $customizeInfo->getNotesDesc() . "\n");
+ }
+
+ if($customizeInfo->getShowRightPanel() != null)
+ {
+ //Get the ShowRightPanel of each User
+ echo("User CustomizeInfo ShowRightPanel: " . $customizeInfo->getShowRightPanel() . "\n");
+ }
+
+ if($customizeInfo->getBcView() != null)
+ {
+ //Get the BcView of each User
+ echo("User CustomizeInfo BcView: " . $customizeInfo->getBcView() . "\n");
+ }
+
+ if($customizeInfo->getShowHome() != null)
+ {
+ //Get the ShowHome of each User
+ echo("User CustomizeInfo ShowHome: " . $customizeInfo->getShowHome() . "\n");
+ }
+
+ if($customizeInfo->getShowDetailView() != null)
+ {
+ //Get the ShowDetailView of each User
+ echo("User CustomizeInfo ShowDetailView: " . $customizeInfo->getShowDetailView() . "\n");
+ }
+
+ if($customizeInfo->getUnpinRecentItem() != null)
+ {
+ //Get the UnpinRecentItem of each User
+ echo("User CustomizeInfo UnpinRecentItem: " . $customizeInfo->getUnpinRecentItem() . "\n");
+ }
+ }
+
+ // Get the Role instance of each User
+ $role = $user->getRole();
+
+ //Check if role is not null
+ if($role != null)
+ {
+ //Get the Name of each Role
+ echo("User Role Name: " . $role->getName() . "\n");
+
+ //Get the ID of each Role
+ echo("User Role ID: " . $role->getId() . "\n");
+ }
+
+ //Get the Signature of each User
+ echo("User Signature: " . $user->getSignature() . "\n");
+
+ //Get the City of each User
+ echo("User City: " . $user->getCity() . "\n");
+
+ //Get the NameFormat of each User
+ echo("User NameFormat: " . $user->getNameFormat() . "\n");
+
+ //Get the Language of each User
+ echo("User Language: " . $user->getLanguage() . "\n");
+
+ //Get the Locale of each User
+ echo("User Locale: " . $user->getLocale() . "\n");
+
+ //Get the Microsoft of each User
+ echo("User Microsoft: " . $user->getMicrosoft() . "\n");
+
+ if($user->getPersonalAccount() != null)
+ {
+ //Get the PersonalAccount of each User
+ echo("User PersonalAccount: " . $user->getPersonalAccount() . "\n");
+ }
+
+ //Get the DefaultTabGroup of each User
+ echo("User DefaultTabGroup: " . $user->getDefaultTabGroup() . "\n");
+
+ //Get the Isonline of each User
+ echo("User Isonline: " . $user->getIsonline() . "\n");
+
+ //Get the modifiedBy User instance of each User
+ $modifiedBy = $user->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("User Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("User Modified By User-ID: " . $modifiedBy->getId() . "\n");
+ }
+
+ //Get the Street of each User
+ echo("User Street: " . $user->getStreet() . "\n");
+
+ //Get the Currency of each User
+ echo("User Currency: " . $user->getCurrency() . "\n");
+
+ //Get the Alias of each User
+ echo("User Alias: " . $user->getAlias() . "\n");
+
+ // Get the Theme instance of each User
+ $theme = $user->getTheme();
+
+ //Check if theme is not null
+ if($theme != null)
+ {
+ // Get the TabTheme instance of Theme
+ $normalTab = $theme->getNormalTab();
+
+ //Check if normalTab is not null
+ if($normalTab != null)
+ {
+ //Get the FontColor of NormalTab
+ echo("User Theme NormalTab FontColor: " . $normalTab->getFontColor() . "\n");
+
+ //Get the Name of NormalTab
+ echo("User Theme NormalTab Name: " . $normalTab->getBackground() . "\n");
+ }
+
+ // Get the TabTheme instance of Theme
+ $selectedTab = $theme->getSelectedTab();
+
+ //Check if selectedTab is not null
+ if($selectedTab != null)
+ {
+ //Get the FontColor of SelectedTab
+ echo("User Theme SelectedTab FontColor: " . $selectedTab->getFontColor() . "\n");
+
+ //Get the Name of SelectedTab
+ echo("User Theme SelectedTab Name: " . $selectedTab->getBackground() . "\n");
+ }
+
+ //Get the NewBackground of each Theme
+ echo("User Theme NewBackground: " . $theme->getNewBackground() . "\n");
+
+ //Get the Background of each Theme
+ echo("User Theme Background: " . $theme->getBackground() . "\n");
+
+ //Get the Screen of each Theme
+ echo("User Theme Screen: " . $theme->getScreen() . "\n");
+
+ //Get the Type of each Theme
+ echo("User Theme Type: " . $theme->getType() . "\n");
+ }
+
+ //Get the ID of each User
+ echo("User ID: " . $user->getId() . "\n");
+
+ //Get the State of each User
+ echo("User State: " . $user->getState() . "\n");
+
+ //Get the Fax of each User
+ echo("User Fax: " . $user->getFax() . "\n");
+
+ //Get the CountryLocale of each User
+ echo("User CountryLocale: " . $user->getCountryLocale() . "\n");
+
+ //Get the FirstName of each User
+ echo("User FirstName: " . $user->getFirstName() . "\n");
+
+ //Get the Email of each User
+ echo("User Email: " . $user->getEmail() . "\n");
+
+ //Get the reportingTo User instance of each User
+ $reportingTo = $user->getReportingTo();
+
+ //Check if reportingTo is not null
+ if($reportingTo != null)
+ {
+ //Get the Name of the reportingTo User
+ echo("User ReportingTo Name: " . $reportingTo->getName() . "\n");
+
+ //Get the ID of the reportingTo User
+ echo("User ReportingTo ID: " . $reportingTo->getId() . "\n");
+ }
+
+ //Get the DecimalSeparator of each User
+ echo("User DecimalSeparator: " . $user->getDecimalSeparator() . "\n");
+
+ //Get the Zip of each User
+ echo("User Zip: " . $user->getZip() . "\n");
+
+ //Get the CreatedTime of each User
+ echo("User CreatedTime: ");
+
+ print_r($user->getCreatedTime());
+
+ echo("\n");
+
+ //Get the Website of each User
+ echo("User Website: " . $user->getWebsite() . "\n");
+
+ //Get the ModifiedTime of each User
+ echo("User ModifiedTime: ");
+
+ print_r($user->getModifiedTime());
+
+ echo("\n");
+
+ //Get the TimeFormat of each User
+ echo("User TimeFormat: " . $user->getTimeFormat() . "\n");
+
+ //Get the Offset of each User
+ echo("User Offset: " . $user->getOffset() . "\n");
+
+ //Get the Profile instance of each User
+ $profile = $user->getProfile();
+
+ //Check if profile is not null
+ if($profile != null)
+ {
+ //Get the Name of each Profile
+ echo("User Profile Name: " . $profile->getName() . "\n");
+
+ //Get the ID of each Profile
+ echo("User Profile ID: " . $profile->getId() . "\n");
+ }
+
+ //Get the Mobile of each User
+ echo("User Mobile: " . $user->getMobile() . "\n");
+
+ //Get the LastName of each User
+ echo("User LastName: " . $user->getLastName() . "\n");
+
+ //Get the TimeZone of each User
+ echo("User TimeZone: " . $user->getTimeZone() . "\n");
+
+ //Get the createdBy User instance of each User
+ $createdBy = $user->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("User Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("User Created By User-ID: " . $createdBy->getId() . "\n");
+ }
+
+ //Get the Zuid of each User
+ echo("User Zuid: " . $user->getZuid() . "\n");
+
+ //Get the Confirm of each User
+ echo("User Confirm: " . $user->getConfirm() . "\n");
+
+ //Get the FullName of each User
+ echo("User FullName: " . $user->getFullName() . "\n");
+
+ //Get the list of obtained Territory instances
+ $territories = $user->getTerritories();
+
+ //Check if territories is not null
+ if($territories != null)
+ {
+ foreach($territories as $territory)
+ {
+ //Get the Manager of the Territory
+ echo("User Territory Manager: " . $territory->getManager() . "\n");
+
+ //Get the Name of the Territory
+ echo("User Territory Name: " . $territory->getName() . "\n");
+
+ //Get the ID of the Territory
+ echo("User Territory ID: " . $territory->getId() . "\n");
+ }
+ }
+
+ //Get the Phone of each User
+ echo("User Phone: " . $user->getPhone() . "\n");
+
+ //Get the DOB of each User
+ echo("User DOB: " . $user->getDob() . "\n");
+
+ //Get the DateFormat of each User
+ echo("User DateFormat: " . $user->getDateFormat() . "\n");
+
+ //Get the Status of each User
+ echo("User Status: " . $user->getStatus() . "\n");
+ }
+
+ //Get the Object obtained Info instance
+ $info = $responseWrapper->getInfo();
+
+ //Check if info is not null
+ if($info != null)
+ {
+ if($info->getPerPage() != null)
+ {
+ //Get the PerPage of the Info
+ echo("User Info PerPage: " . $info->getPerPage() . "\n");
+ }
+
+ if($info->getCount() != null)
+ {
+ //Get the Count of the Info
+ echo("User Info Count: " . $info->getCount() . "\n");
+ }
+
+ if($info->getPage() != null)
+ {
+ //Get the Page of the Info
+ echo("User Info Page: " . $info->getPage() . "\n");
+ }
+
+ if($info->getMoreRecords() != null)
+ {
+ //Get the MoreRecords of the Info
+ echo("User Info MoreRecords: " . $info->getMoreRecords() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Create Users
+ * This method is used to add a user to your organization and print the response.
+ * @throws Exception
+ */
+ public static function createUser()
+ {
+ //Get instance of UsersOperations Class
+ $usersOperations = new UsersOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new RequestWrapper();
+
+ //List of User instances
+ $userList = array();
+
+ $userClass = "com\zoho\crm\api\users\User";
+
+ //Get instance of User Class
+ $user1 = new $userClass();
+
+ $role = new Role();
+
+ $role->setId("3477061000000026008");
+
+ $user1->setRole($role);
+
+ $user1->setFirstName("TestUser");
+
+ $user1->setEmail("testuser@zoho.com");
+
+ $profile = new Profile();
+
+ $profile->setId("3477061000000026014");
+
+ $user1->setProfile($profile);
+
+ $user1->setLastName("12");
+
+ array_push($userList, $user1);
+
+ $request->setUsers($userList);
+
+ //Call createUser method that takes BodyWrapper class instance as parameter
+ $response = $usersOperations->createUser($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $responseWrapper->getUsers();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Users
+ * This method is used to update the details of a user of your organization and print the response.
+ * @throws Exception
+ */
+ public static function updateUsers()
+ {
+ //Get instance of UsersOperations Class
+ $usersOperations = new UsersOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of User instances
+ $userList = array();
+
+ $userClass = "com\zoho\crm\api\users\User";
+
+ //Get instance of User Class
+ $user1 = new $userClass();
+
+ $user1->setId("3477061000005791024");
+
+ $role = new Role();
+
+ $role->setId("3477061000000026008");
+
+ $user1->setRole($role);
+
+ $user1->setCountryLocale("en_US");
+
+ array_push($userList, $user1);
+
+ $user1 = new $userClass();
+
+ $user1->setId("3477061000005791024");
+
+ $role = new Role();
+
+ $role->setId("3477061000000026008");
+
+ $user1->setRole($role);
+
+ $user1->setCountryLocale("en_US");
+
+ $user1->addKeyValue("FieldAPIName", "Value");
+
+ array_push($userList, $user1);
+
+ $request->setUsers($userList);
+
+ //Call updateUsers method that takes BodyWrapper instance as parameter
+ $response = $usersOperations->updateUsers($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $responseWrapper->getUsers();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get User
+ * This method is used to get the details of any specific $user->
+ * Specify the unique id of the user in your API request to get the data for that particular $user->
+ * @param userId - The ID of the User to be obtainted
+ * @throws Exception
+ */
+ public static function getUser(string $userId)
+ {
+ //Get instance of UsersOperations Class
+ $usersOperations = new UsersOperations();
+
+ $headerInstance = new HeaderMap();
+
+ $ifmodifiedsince = date_create("2020-07-15T17:58:47+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $headerInstance->add(GetUserHeader::IfModifiedSince(), $ifmodifiedsince);
+
+ //Call getUser method that takes userId as parameter
+ $response = $usersOperations->getUser($userId,$headerInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained User instance
+ $users = $responseWrapper->getUsers();
+
+ foreach($users as $user)
+ {
+ //Get the Country of each User
+ echo("User Country: " . $user->getCountry() . "\n");
+
+ // Get the CustomizeInfo instance of each User
+ $customizeInfo = $user->getCustomizeInfo();
+
+ //Check if customizeInfo is not null
+ if($customizeInfo != null)
+ {
+ if($customizeInfo->getNotesDesc() != null)
+ {
+ //Get the NotesDesc of each User
+ echo("User CustomizeInfo NotesDesc: " . $customizeInfo->getNotesDesc() . "\n");
+ }
+
+ if($customizeInfo->getShowRightPanel() != null)
+ {
+ //Get the ShowRightPanel of each User
+ echo("User CustomizeInfo ShowRightPanel: " . $customizeInfo->getShowRightPanel() . "\n");
+ }
+
+ if($customizeInfo->getBcView() != null)
+ {
+ //Get the BcView of each User
+ echo("User CustomizeInfo BcView: " . $customizeInfo->getBcView() . "\n");
+ }
+
+ if($customizeInfo->getShowHome() != null)
+ {
+ //Get the ShowHome of each User
+ echo("User CustomizeInfo ShowHome: " . $customizeInfo->getShowHome() . "\n");
+ }
+
+ if($customizeInfo->getShowDetailView() != null)
+ {
+ //Get the ShowDetailView of each User
+ echo("User CustomizeInfo ShowDetailView: " . $customizeInfo->getShowDetailView() . "\n");
+ }
+
+ if($customizeInfo->getUnpinRecentItem() != null)
+ {
+ //Get the UnpinRecentItem of each User
+ echo("User CustomizeInfo UnpinRecentItem: " . $customizeInfo->getUnpinRecentItem() . "\n");
+ }
+ }
+
+ // Get the Role instance of each User
+ $role = $user->getRole();
+
+ //Check if role is not null
+ if($role != null)
+ {
+ //Get the Name of each Role
+ echo("User Role Name: " . $role->getName() . "\n");
+
+ //Get the ID of each Role
+ echo("User Role ID: " . $role->getId() . "\n");
+ }
+
+ //Get the Signature of each User
+ echo("User Signature: " . $user->getSignature() . "\n");
+
+ //Get the City of each User
+ echo("User City: " . $user->getCity() . "\n");
+
+ //Get the NameFormat of each User
+ echo("User NameFormat: " . $user->getNameFormat() . "\n");
+
+ //Get the Language of each User
+ echo("User Language: " . $user->getLanguage() . "\n");
+
+ //Get the Locale of each User
+ echo("User Locale: " . $user->getLocale() . "\n");
+
+ //Get the Microsoft of each User
+ echo("User Microsoft: " . $user->getMicrosoft() . "\n");
+
+ if($user->getPersonalAccount() != null)
+ {
+ //Get the PersonalAccount of each User
+ echo("User PersonalAccount: " . $user->getPersonalAccount() . "\n");
+ }
+
+ //Get the DefaultTabGroup of each User
+ echo("User DefaultTabGroup: " . $user->getDefaultTabGroup() . "\n");
+
+ //Get the Isonline of each User
+ echo("User Isonline: " . $user->getIsonline() . "\n");
+
+ //Get the modifiedBy User instance of each User
+ $modifiedBy = $user->getModifiedBy();
+
+ //Check if modifiedBy is not null
+ if($modifiedBy != null)
+ {
+ //Get the Name of the modifiedBy User
+ echo("User Modified By User-Name: " . $modifiedBy->getName() . "\n");
+
+ //Get the ID of the modifiedBy User
+ echo("User Modified By User-ID: " . $modifiedBy->getId() . "\n");
+ }
+
+ //Get the Street of each User
+ echo("User Street: " . $user->getStreet() . "\n");
+
+ //Get the Currency of each User
+ echo("User Currency: " . $user->getCurrency() . "\n");
+
+ //Get the Alias of each User
+ echo("User Alias: " . $user->getAlias() . "\n");
+
+ // Get the Theme instance of each User
+ // Get the Theme instance of each User
+ $theme = $user->getTheme();
+
+ //Check if theme is not null
+ if($theme != null)
+ {
+ // Get the TabTheme instance of Theme
+ $normalTab = $theme->getNormalTab();
+
+ //Check if normalTab is not null
+ if($normalTab != null)
+ {
+ //Get the FontColor of NormalTab
+ echo("User Theme NormalTab FontColor: " . $normalTab->getFontColor() . "\n");
+
+ //Get the Name of NormalTab
+ echo("User Theme NormalTab Name: " . $normalTab->getBackground() . "\n");
+ }
+
+ // Get the TabTheme instance of Theme
+ $selectedTab = $theme->getSelectedTab();
+
+ //Check if selectedTab is not null
+ if($selectedTab != null)
+ {
+ //Get the FontColor of SelectedTab
+ echo("User Theme SelectedTab FontColor: " . $selectedTab->getFontColor() . "\n");
+
+ //Get the Name of SelectedTab
+ echo("User Theme SelectedTab Name: " . $selectedTab->getBackground() . "\n");
+ }
+
+ //Get the NewBackground of each Theme
+ echo("User Theme NewBackground: " . $theme->getNewBackground() . "\n");
+
+ //Get the Background of each Theme
+ echo("User Theme Background: " . $theme->getBackground() . "\n");
+
+ //Get the Screen of each Theme
+ echo("User Theme Screen: " . $theme->getScreen() . "\n");
+
+ //Get the Type of each Theme
+ echo("User Theme Type: " . $theme->getType() . "\n");
+ }
+
+ //Get the ID of each User
+ echo("User ID: " . $user->getId() . "\n");
+
+ //Get the State of each User
+ echo("User State: " . $user->getState() . "\n");
+
+ //Get the Fax of each User
+ echo("User Fax: " . $user->getFax() . "\n");
+
+ //Get the CountryLocale of each User
+ echo("User CountryLocale: " . $user->getCountryLocale() . "\n");
+
+ //Get the FirstName of each User
+ echo("User FirstName: " . $user->getFirstName() . "\n");
+
+ //Get the Email of each User
+ echo("User Email: " . $user->getEmail() . "\n");
+
+ //Get the reportingTo User instance of each User
+ $reportingTo = $user->getReportingTo();
+
+ //Check if reportingTo is not null
+ if($reportingTo != null)
+ {
+ //Get the Name of the reportingTo User
+ echo("User ReportingTo Name: " . $reportingTo->getName() . "\n");
+
+ //Get the ID of the reportingTo User
+ echo("User ReportingTo ID: " . $reportingTo->getId() . "\n");
+ }
+
+ //Get the DecimalSeparator of each User
+ echo("User DecimalSeparator: " . $user->getDecimalSeparator() . "\n");
+
+ //Get the Zip of each User
+ echo("User Zip: " . $user->getZip() . "\n");
+
+ //Get the CreatedTime of each User
+ echo("User CreatedTime: ");
+
+ print_r($user->getCreatedTime());
+
+ echo("\n");
+
+ //Get the Website of each User
+ echo("User Website: " . $user->getWebsite() . "\n");
+
+ //Get the ModifiedTime of each User
+ echo("User ModifiedTime: ");
+
+ print_r($user->getModifiedTime());
+
+ echo("\n");
+
+ //Get the TimeFormat of each User
+ echo("User TimeFormat: " . $user->getTimeFormat() . "\n");
+
+ //Get the Offset of each User
+ echo("User Offset: " . $user->getOffset() . "\n");
+
+ //Get the Profile instance of each User
+ $profile = $user->getProfile();
+
+ //Check if profile is not null
+ if($profile != null)
+ {
+ //Get the Name of each Profile
+ echo("User Profile Name: " . $profile->getName() . "\n");
+
+ //Get the ID of each Profile
+ echo("User Profile ID: " . $profile->getId() . "\n");
+ }
+
+ //Get the Mobile of each User
+ echo("User Mobile: " . $user->getMobile() . "\n");
+
+ //Get the LastName of each User
+ echo("User LastName: " . $user->getLastName() . "\n");
+
+ //Get the TimeZone of each User
+ echo("User TimeZone: " . $user->getTimeZone() . "\n");
+
+ //Get the createdBy User instance of each User
+ $createdBy = $user->getCreatedBy();
+
+ //Check if createdBy is not null
+ if($createdBy != null)
+ {
+ //Get the Name of the createdBy User
+ echo("User Created By User-Name: " . $createdBy->getName() . "\n");
+
+ //Get the ID of the createdBy User
+ echo("User Created By User-ID: " . $createdBy->getId() . "\n");
+ }
+
+ //Get the Zuid of each User
+ echo("User Zuid: " . $user->getZuid() . "\n");
+
+ //Get the Confirm of each User
+ echo("User Confirm: " . $user->getConfirm() . "\n");
+
+ //Get the FullName of each User
+ echo("User FullName: " . $user->getFullName() . "\n");
+
+ //Get the list of obtained Territory instances
+ $territories = $user->getTerritories();
+
+ //Check if territories is not null
+ if($territories != null)
+ {
+ foreach($territories as $territory)
+ {
+ //Get the Manager of the Territory
+ echo("User Territory Manager: " . $territory->getManager() . "\n");
+
+ //Get the Name of the Territory
+ echo("User Territory Name: " . $territory->getName() . "\n");
+
+ //Get the ID of the Territory
+ echo("User Territory ID: " . $territory->getId() . "\n");
+ }
+ }
+
+ //Get the Phone of each User
+ echo("User Phone: " . $user->getPhone() . "\n");
+
+ //Get the DOB of each User
+ echo("User DOB: " . $user->getDob() . "\n");
+
+ //Get the DateFormat of each User
+ echo("User DateFormat: " . $user->getDateFormat() . "\n");
+
+ //Get the Status of each User
+ echo("User Status: " . $user->getStatus() . "\n");
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map4
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . ": " .$value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update User
+ * This method is used to update the details of a user of your organization and print the response.
+ * @param userId - The ID of the User to be obtainted
+ * @throws Exception
+ */
+ public static function updateUser(string $userId)
+ {
+ //Get instance of UsersOperations Class
+ $usersOperations = new UsersOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of User instances
+ $userList = array();
+
+ $userClass = "com\zoho\crm\api\users\User";
+
+ //Get instance of User Class
+ $user1 = new $userClass();
+
+ $role = new Role();
+
+ $role->setId("3477061000000026008");
+
+ $user1->setRole($role);
+
+ $user1->setCountryLocale("en_US");
+
+ array_push($userList, $user1);
+
+ $request->setUsers($userList);
+
+ //Call updateUser method that takes BodyWrapper instance and userId as parameter
+ $response = $usersOperations->updateUser($userId,$request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $responseWrapper->getUsers();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete User
+ * This method is used to delete a user from your organization and print the response.
+ * @param userId - The ID of the User to be obtainted
+ * @throws Exception
+ */
+ public static function deleteUser(string $userId)
+ {
+ //Get instance of UsersOperations Class
+ $usersOperations = new UsersOperations();
+
+ //Call deleteUser method that takes userId as parameter
+ $response = $usersOperations->deleteUser($userId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $responseWrapper->getUsers();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ if($exception->getDetails() != null)
+ {
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/variablegroups/VariableGroup.php b/samples/src/com/zoho/crm/api/variablegroups/VariableGroup.php
new file mode 100644
index 0000000..ec854ce
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/variablegroups/VariableGroup.php
@@ -0,0 +1,274 @@
+ Get Variable Groups
+ * This method is used to get the details of any variable group and print the response.
+ * @throws Exception
+ */
+ public static function getVariableGroups()
+ {
+ //Get instance of VariableGroupsOperations Class
+ $variableGroupsOperations = new VariableGroupsOperations();
+
+ //Call getVariableGroups method
+ $response = $variableGroupsOperations->getVariableGroups();
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained VariableGroup instance
+ $variableGroups = $responseWrapper->getVariableGroups();
+
+ if($variableGroups != null)
+ {
+ foreach($variableGroups as $variableGroup)
+ {
+ //Get the DisplayLabel of each VariableGroup
+ echo("VariableGroup DisplayLabel: " . $variableGroup->getDisplayLabel() . "\n");
+
+ //Get the APIName of each VariableGroup
+ echo("VariableGroup APIName: " . $variableGroup->getAPIName() . "\n");
+
+ //Get the Name of each VariableGroup
+ echo("VariableGroup Name: " . $variableGroup->getName() . "\n");
+
+ //Get the Description of each VariableGroup
+ echo("VariableGroup Description: " . $variableGroup->getDescription() . "\n");
+
+ //Get the ID of each VariableGroup
+ echo("VariableGroup ID: " . $variableGroup->getId() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Variable Group By Id
+ * This method is used to get the details of any variable group with group id and print the response.
+ * @param variableGroupId - The ID of the VariableGroup to be obtainted
+ * @throws Exception
+ */
+ public static function getVariableGroupById(string $variableGroupId)
+ {
+ //Get instance of VariableGroupsOperations Class
+ $variableGroupsOperations = new VariableGroupsOperations();
+
+ //Call getVariableGroupById method that takes variableGroupId as parameter
+ $response = $variableGroupsOperations->getVariableGroupById($variableGroupId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained VariableGroup instance
+ $variableGroups = $responseWrapper->getVariableGroups();
+
+ if($variableGroups != null)
+ {
+ foreach($variableGroups as $variableGroup)
+ {
+ //Get the DisplayLabel of each VariableGroup
+ echo("VariableGroup DisplayLabel: " . $variableGroup->getDisplayLabel() . "\n");
+
+ //Get the APIName of each VariableGroup
+ echo("VariableGroup APIName: " . $variableGroup->getAPIName() . "\n");
+
+ //Get the Name of each VariableGroup
+ echo("VariableGroup Name: " . $variableGroup->getName() . "\n");
+
+ //Get the Description of each VariableGroup
+ echo("VariableGroup Description: " . $variableGroup->getDescription() . "\n");
+
+ //Get the ID of each VariableGroup
+ echo("VariableGroup ID: " . $variableGroup->getId() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Variable Group By APIName
+ * This method is used to get the details of any variable group with group name and print the response.
+ * @param variableGroupName - The ID of the VariableGroup to be obtainted
+ * @throws Exception
+ */
+ public static function getVariableGroupByAPIName(string $variableGroupName)
+ {
+ //Get instance of VariableGroupsOperations Class
+ $variableGroupsOperations = new VariableGroupsOperations();
+
+ //Call getVariableGroupByAPIName method that takes variableGroupName as parameter
+ $response = $variableGroupsOperations->getVariableGroupByAPIName($variableGroupName);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ResponseWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained VariableGroup instance
+ $variableGroups = $responseWrapper->getVariableGroups();
+
+ if($variableGroups != null)
+ {
+ foreach($variableGroups as $variableGroup)
+ {
+ //Get the DisplayLabel of each VariableGroup
+ echo("VariableGroup DisplayLabel: " . $variableGroup->getDisplayLabel() . "\n");
+
+ //Get the APIName of each VariableGroup
+ echo("VariableGroup APIName: " . $variableGroup->getAPIName() . "\n");
+
+ //Get the Name of each VariableGroup
+ echo("VariableGroup Name: " . $variableGroup->getName() . "\n");
+
+ //Get the Description of each VariableGroup
+ echo("VariableGroup Description: " . $variableGroup->getDescription() . "\n");
+
+ //Get the ID of each VariableGroup
+ echo("VariableGroup ID: " . $variableGroup->getId() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/com/zoho/crm/api/variables/Variable.php b/samples/src/com/zoho/crm/api/variables/Variable.php
new file mode 100644
index 0000000..79f6268
--- /dev/null
+++ b/samples/src/com/zoho/crm/api/variables/Variable.php
@@ -0,0 +1,1158 @@
+ Get Variables
+ * This method is used to retrieve all the available variables through an API request and print the response.
+ * @throws Exception
+ */
+ public static function getVariables()
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetVariablesParam::group(), "General");
+
+ //Call getVariables method that takes paramInstance as parameter
+ $response = $variablesOperations->getVariables($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Variable instance
+ $variables = $responseWrapper->getVariables();
+
+ if($variables != null)
+ {
+ foreach($variables as $variable)
+ {
+ //Get the APIName of each Variable
+ echo("Variable APIName: " . $variable->getAPIName() . "\n");
+
+ //Get the Name of each Variable
+ echo("Variable Name: " . $variable->getName() . "\n");
+
+ //Get the Description of each Variable
+ echo("Variable Description: " . $variable->getDescription() . "\n");
+
+ //Get the ID of each Variable
+ echo("Variable ID: " . $variable->getId() . "\n");
+
+ //Get the Type of each Variable
+ echo("Variable Type: " . $variable->getType() . "\n");
+
+ // Get the VariableGroup instance of each Variable
+ $variableGroup = $variable->getVariableGroup();
+
+ //Check if variableGroup is not null
+ if($variableGroup != null)
+ {
+ //Get the Name of each VariableGroup
+ echo("Variable VariableGroup APIName: " . $variableGroup->getAPIName() . "\n");
+
+ //Get the ID of each VariableGroup
+ echo("Variable VariableGroup ID: " . $variableGroup->getId() . "\n");
+ }
+
+ //Get the Value of each Variable
+ echo("Variable Value: " . $variable->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Create Variables
+ * This method is used to create a new variable in CRM and print the response.
+ * @throws Exception
+ */
+ public static function createVariables()
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Variable instances
+ $variableList = array();
+
+ $variableClass = 'com\zoho\crm\api\variables\Variable';
+
+ //Get instance of Variable Class
+ $variable1 = new $variableClass();
+
+ $variable1->setName("asdasd");
+
+ $variable1->setAPIName("sdsd");
+
+ $variableGroup = new VariableGroup();
+
+ $variableGroup->setName("General");
+
+ $variableGroup->setId("3477061000003089001");
+
+ $variable1->setVariableGroup($variableGroup);
+
+ $variable1->setType("integer");
+
+ $variable1->setValue("42");
+
+ $variable1->setDescription("This denotes variable 5 description");
+
+ array_push($variableList, $variable1);
+
+ $variable1 = new $variableClass();
+
+ $variable1->setName("Variable661");
+
+ $variable1->setAPIName("Variable661");
+
+ $variableGroup = new VariableGroup();
+
+ $variableGroup->setName("General");
+
+ $variable1->setVariableGroup($variableGroup);
+
+ $variable1->setType("text");
+
+ $variable1->setValue("H2ello");
+
+ $variable1->setDescription("This denotes variable 6 description");
+
+ array_push($variableList, $variable1);
+
+ $request->setVariables($variableList);
+
+ //Call createVariables method that takes BodyWrapper instance as parameter
+ $response = $variablesOperations->createVariables($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getVariables();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Variables
+ * This method is used to update details of variables in CRM and print the response.
+ * @throws Exception
+ */
+ public static function updateVariables()
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Variable instances
+ $variableList = array();
+
+ $variableClass = 'com\zoho\crm\api\variables\Variable';
+
+ //Get instance of Variable Class
+ $variable1 = new $variableClass();
+
+ $variable1->setId("3477061000007444005");
+
+ $variable1->setValue("4763");
+ $variable1->setAPIName("er");
+
+ array_push($variableList, $variable1);
+
+ $variable1 = new $variableClass();
+
+ $variable1->setId("3477061000007444010");
+ $variable1->setAPIName("eer");
+
+ $variable1->setDescription("This is a new description");
+
+ array_push($variableList, $variable1);
+
+ $variable1 = new $variableClass();
+
+ $variable1->setId("3477061000007444012");
+
+ $variable1->setAPIName("re");
+
+ array_push($variableList, $variable1);
+
+ $request->setVariables($variableList);
+
+ //Call updateVariables method that takes BodyWrapper class instance as parameter
+ $response = $variablesOperations->updateVariables($request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getVariables();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Variables
+ * This method is used to delete details of multiple variables in CRM simultaneously and print the response.
+ * @param variableIds - The ID of the Variable to be obtainted
+ * @throws Exception
+ */
+ public static function deleteVariables(array $variableIds)
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ foreach($variableIds as $variableId)
+ {
+ $paramInstance->add(DeleteVariablesParam::ids(), $variableId);
+ }
+
+ //Call deleteVariables method that takes BodyWrapper class instance as parameter
+ $response = $variablesOperations->deleteVariables($paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getVariables();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Get Variable By Id
+ * This method is used to get the details of any specific variable.
+ * Specify the unique ID of the variable in your API request to get the data for that particular variable group.
+ * @param variableId - The ID of the Variable to be obtainted
+ * @throws Exception
+ */
+ public static function getVariableById(string $variableId)
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetVariableByIDParam::group(), "3477061000003089001");//"General"
+
+ //Call getVariableByGroupId method that takes paramInstance and variableId as parameter
+ $response = $variablesOperations->getVariableById($variableId,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Variable instance
+ $variables = $responseWrapper->getVariables();
+
+ if($variables != null)
+ {
+ foreach($variables as $variable)
+ {
+ //Get the APIName of each Variable
+ echo("Variable APIName: " . $variable->getAPIName() . "\n");
+
+ //Get the Name of each Variable
+ echo("Variable Name: " . $variable->getName() . "\n");
+
+ //Get the Description of each Variable
+ echo("Variable Description: " . $variable->getDescription() . "\n");
+
+ //Get the ID of each Variable
+ echo("Variable ID: " . $variable->getId() . "\n");
+
+ //Get the Type of each Variable
+ echo("Variable Type: " . $variable->getType() . "\n");
+
+ // Get the VariableGroup instance of each Variable
+ $variableGroup = $variable->getVariableGroup();
+
+ //Check if variableGroup is not null
+ if($variableGroup != null)
+ {
+ //Get the Name of each VariableGroup
+ echo("Variable VariableGroup APIName: " . $variableGroup->getAPIName() . "\n");
+
+ //Get the ID of each VariableGroup
+ echo("Variable VariableGroup ID: " . $variableGroup->getId() . "\n");
+ }
+
+ //Get the Value of each Variable
+ echo("Variable Value: " . $variable->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Update Variable By Id
+ * This method is used to update details of a specific variable in CRM and print the response.
+ * @param variableId - The ID of the Variable to be obtainted
+ * @throws Exception
+ */
+ public static function updateVariableById(string $variableId)
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Variable instances
+ $variableList = array();
+
+ $variableClass = 'com\zoho\crm\api\variables\Variable';
+
+ //Get instance of Variable Class
+ $variable1 = new $variableClass();
+
+ $variable1->setAPIName("TestAPIName");
+
+ array_push($variableList, $variable1);
+
+ $request->setVariables($variableList);
+
+ //Call updateVariableById method that takes BodyWrapper instance and variableId as parameter
+ $response = $variablesOperations->updateVariableById($variableId,$request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getVariables();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * Delete Variable
+ * This method is used to delete details of a specific variable in CRM and print the response.
+ * @param variableId - The ID of the Variable to be obtainted
+ * @throws Exception
+ */
+ public static function deleteVariable(string $variableId)
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Call deleteVariable method that takes variableId as parameter
+ $response = $variablesOperations->deleteVariable($variableId);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getVariables();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * This method is used to get the details of any specific variable.
+ * Specify the unique name of the variable in your API request to get the data for that particular variable group.
+ * @param variableName - The name of the Variable to be obtainted
+ * @throws Exception
+ */
+ public static function getVariableForAPIName(string $variableName)
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Get instance of ParameterMap Class
+ $paramInstance = new ParameterMap();
+
+ $paramInstance->add(GetVariableForAPINameParam::group(), "General");//"3477061000003089001"
+
+ //Call getVariableForGroupAPIName method that takes paramInstance and variableName as parameter
+ $response = $variablesOperations->getVariableForAPIName($variableName,$paramInstance);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status code " . $response->getStatusCode() . "\n");
+
+ if(in_array($response->getStatusCode(), array(204, 304)))
+ {
+ echo($response->getStatusCode() == 204? "No Content\n" : "Not Modified\n");
+
+ return;
+ }
+
+ //Get object from response
+ $responseHandler = $response->getObject();
+
+ if($responseHandler instanceof ResponseWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $responseWrapper = $responseHandler;
+
+ //Get the obtained Variable instance
+ $variables = $responseWrapper->getVariables();
+
+ if($variables != null)
+ {
+ foreach($variables as $variable)
+ {
+ //Get the APIName of each Variable
+ echo("Variable APIName: " . $variable->getAPIName() . "\n");
+
+ //Get the Name of each Variable
+ echo("Variable Name: " . $variable->getName() . "\n");
+
+ //Get the Description of each Variable
+ echo("Variable Description: " . $variable->getDescription() . "\n");
+
+ //Get the ID of each Variable
+ echo("Variable ID: " . $variable->getId() . "\n");
+
+ //Get the Type of each Variable
+ echo("Variable Type: " . $variable->getType() . "\n");
+
+ // Get the VariableGroup instance of each Variable
+ $variableGroup = $variable->getVariableGroup();
+
+ //Check if variableGroup is not null
+ if($variableGroup != null)
+ {
+ //Get the Name of each VariableGroup
+ echo("Variable VariableGroup APIName: " . $variableGroup->getAPIName() . "\n");
+
+ //Get the ID of each VariableGroup
+ echo("Variable VariableGroup ID: " . $variableGroup->getId() . "\n");
+ }
+
+ //Get the Value of each Variable
+ echo("Variable Value: " . $variable->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($responseHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $responseHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+
+ /**
+ * This method is used to update details of a specific variable in CRM and print the response.
+ * @param variableName - The name of the Variable to be obtainted
+ * @throws Exception
+ */
+ public static function updateVariableByAPIName(string $variableName)
+ {
+ //Get instance of VariablesOperations Class
+ $variablesOperations = new VariablesOperations();
+
+ //Get instance of BodyWrapper Class that will contain the request body
+ $request = new BodyWrapper();
+
+ //List of Variable instances
+ $variableList = array();
+
+ $variableClass = 'com\zoho\crm\api\variables\Variable';
+
+ //Get instance of Variable Class
+ $variable1 = new $variableClass();
+
+ $variable1->setDescription("Test update Variable By APIName");
+
+ array_push($variableList, $variable1);
+
+ $request->setVariables($variableList);
+
+ //Call updateVariableByAPIName method that takes BodyWrapper instance and variableName as parameter
+ $response = $variablesOperations->updateVariableByAPIName($variableName,$request);
+
+ if($response != null)
+ {
+ //Get the status code from response
+ echo("Status Code: " . $response->getStatusCode() . "\n");
+
+ //Get object from response
+ $actionHandler = $response->getObject();
+
+ if($actionHandler instanceof ActionWrapper)
+ {
+ //Get the received ActionWrapper instance
+ $actionWrapper = $actionHandler;
+
+ //Get the list of obtained ActionResponse instances
+ $actionResponses = $actionWrapper->getVariables();
+
+ foreach($actionResponses as $actionResponse)
+ {
+ //Check if the request is successful
+ if($actionResponse instanceof SuccessResponse)
+ {
+ //Get the received SuccessResponse instance
+ $successResponse = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $successResponse->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($successResponse->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $successResponse->getMessage()->getValue() . "\n");
+ }
+ //Check if the request returned an exception
+ else if($actionResponse instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionResponse;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ echo("Details: " );
+
+ //Get the details map
+ foreach($exception->getDetails() as $key => $value)
+ {
+ //Get each value in the map
+ echo($key . " : " . $value . "\n");
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+ //Check if the request returned an exception
+ else if($actionHandler instanceof APIException)
+ {
+ //Get the received APIException instance
+ $exception = $actionHandler;
+
+ //Get the Status
+ echo("Status: " . $exception->getStatus()->getValue() . "\n");
+
+ //Get the Code
+ echo("Code: " . $exception->getCode()->getValue() . "\n");
+
+ if($exception->getDetails() != null)
+ {
+ echo("Details: \n");
+
+ //Get the details map
+ foreach ($exception->getDetails() as $keyName => $keyValue)
+ {
+ //Get each value in the map
+ echo($keyName . ": " . $keyValue . "\n");
+ }
+ }
+
+ //Get the Message
+ echo("Message: " . $exception->getMessage()->getValue() . "\n");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/zoho/crm/api/RequestProxy.php b/src/com/zoho/crm/api/RequestProxy.php
index 4f9af3b..70d3c0e 100644
--- a/src/com/zoho/crm/api/RequestProxy.php
+++ b/src/com/zoho/crm/api/RequestProxy.php
@@ -1,5 +1,5 @@