Skip to content

Commit

Permalink
Supported process key in request body for record operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
pravesh-a committed Jul 13, 2020
1 parent 1fbaf1e commit 4cd59fd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
12 changes: 9 additions & 3 deletions src/crm/api/handler/EntityAPIHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function getRecord($param_map=array(),$header_map=array())
foreach ($header_map as $key => $value) {
if($value!==null)$this->addHeader($key, $value);
}

$this->addHeader("Content-Type", "application/json");
$responseInstance = APIRequest::getInstance($this)->getAPIResponse();
$recordDetails = $responseInstance->getResponseJSON()['data'];
Expand All @@ -52,7 +53,7 @@ public function getRecord($param_map=array(),$header_map=array())
}
}

public function createRecord($trigger, $lar_id)
public function createRecord($trigger, $lar_id,$process)
{
try {
if ($this->record->getEntityId() != NULL) {
Expand All @@ -71,6 +72,9 @@ public function createRecord($trigger, $lar_id)
if ($lar_id !== null) {
$requestBodyObj["lar_id"] = $lar_id;
}
if($process !== null && is_array($process) ){
$requestBodyObj["process"] =$process;
}

$this->requestBody = json_encode($requestBodyObj);

Expand All @@ -90,7 +94,7 @@ public function createRecord($trigger, $lar_id)
}
}

public function updateRecord($trigger)
public function updateRecord($trigger,$process)
{
try {
if ($this->record->getEntityId() == NULL) {
Expand All @@ -106,7 +110,9 @@ public function updateRecord($trigger)
if ($trigger !== null && is_array($trigger)) {
$requestBodyObj["trigger"] = $trigger;
}

if($process !== null && is_array($process) ){
$requestBodyObj["process"] =$process;
}

$this->requestBody =json_encode( $requestBodyObj);
$responseInstance = APIRequest::getInstance($this)->getAPIResponse();
Expand Down
15 changes: 12 additions & 3 deletions src/crm/api/handler/MassEntityAPIHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function getInstance($moduleInstance)
return new MassEntityAPIHandler($moduleInstance);
}

public function createRecords($records, $trigger,$lar_id)
public function createRecords($records, $trigger,$lar_id,$process)
{
if (sizeof($records) > 100) {
throw new ZCRMException(APIConstants::API_MAX_RECORDS_MSG, APIConstants::RESPONSECODE_BAD_REQUEST);
Expand All @@ -49,6 +49,9 @@ public function createRecords($records, $trigger,$lar_id)
if ($lar_id !== null) {
$requestBodyObj["lar_id"] = $lar_id;
}
if($process !== null && is_array($process) ){
$requestBodyObj["process"] =$process;
}

$this->requestBody = $requestBodyObj;

Expand Down Expand Up @@ -77,7 +80,7 @@ public function createRecords($records, $trigger,$lar_id)
}
}

public function upsertRecords($records, $trigger,$lar_id,$duplicate_check_fields)
public function upsertRecords($records, $trigger,$lar_id,$duplicate_check_fields,$process)
{
if (sizeof($records) > 100) {
throw new ZCRMException(APIConstants::API_MAX_RECORDS_MSG, APIConstants::RESPONSECODE_BAD_REQUEST);
Expand Down Expand Up @@ -106,6 +109,9 @@ public function upsertRecords($records, $trigger,$lar_id,$duplicate_check_fields
if ($lar_id !== null) {
$requestBodyObj["lar_id"] = $lar_id;
}
if($process !== null && is_array($process) ){
$requestBodyObj["process"] =$process;
}
$this->requestBody = $requestBodyObj;

// Fire Request
Expand Down Expand Up @@ -133,7 +139,7 @@ public function upsertRecords($records, $trigger,$lar_id,$duplicate_check_fields
}
}

public function updateRecords($records, $trigger)
public function updateRecords($records, $trigger,$process)
{
if (sizeof($records) > 100) {
throw new ZCRMException(APIConstants::API_MAX_RECORDS_MSG, APIConstants::RESPONSECODE_BAD_REQUEST);
Expand All @@ -155,6 +161,9 @@ public function updateRecords($records, $trigger)
if ($trigger !== null && is_array($trigger)) {
$requestBodyObj["trigger"] = $trigger;
}
if($process !== null && is_array($process) ){
$requestBodyObj["process"] =$process;
}

$this->requestBody = $requestBodyObj;

Expand Down
12 changes: 6 additions & 6 deletions src/crm/crud/ZCRMModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,9 @@ public function massUpdateRecords($entityIds, $fieldApiName, $value)
* @param string $lar_id lead assignment rule id
* @return BulkAPIResponse instance of the BulkAPIResponse class which holds the Bulk API response.
*/
public function updateRecords($records, $trigger = null)
public function updateRecords($records, $trigger = null,$process = null)
{
return MassEntityAPIHandler::getInstance($this)->updateRecords($records, $trigger);
return MassEntityAPIHandler::getInstance($this)->updateRecords($records, $trigger,$process);
}

/**
Expand All @@ -1165,9 +1165,9 @@ public function updateRecords($records, $trigger = null)
* @param string $lar_id lead assignment rule id
* @return BulkAPIResponse instance of the BulkAPIResponse class which holds the Bulk API response.
*/
public function createRecords($records, $trigger = null,$lar_id = null)
public function createRecords($records, $trigger = null,$lar_id = null,$process = null)
{
return MassEntityAPIHandler::getInstance($this)->createRecords($records, $trigger,$lar_id);
return MassEntityAPIHandler::getInstance($this)->createRecords($records, $trigger,$lar_id,$process);
}

/**
Expand All @@ -1178,9 +1178,9 @@ public function createRecords($records, $trigger = null,$lar_id = null)
* @param string $lar_id lead assignment rule id
* @return BulkAPIResponse instance of the BulkAPIResponse class which holds the Bulk API response.
*/
public function upsertRecords($records, $trigger = null,$lar_id = null,$duplicate_check_fields=null)
public function upsertRecords($records, $trigger = null,$lar_id = null,$duplicate_check_fields=null,$process = null)
{
return MassEntityAPIHandler::getInstance($this)->upsertRecords($records, $trigger,$lar_id,$duplicate_check_fields);
return MassEntityAPIHandler::getInstance($this)->upsertRecords($records, $trigger,$lar_id,$duplicate_check_fields,$process);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/crm/crud/ZCRMRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,14 +588,14 @@ public function getRecordRowNumber()
* @return APIResponse instance of the APIResponse class which holds the API response.
*
*/
public function create( $trigger = null,$lar_id = null)
public function create( $trigger = null,$lar_id = null,$process = null)
{
if (self::getEntityId() != null) {
$exception = new ZCRMException("Entity ID MUST be null for create operation.", APIConstants::RESPONSECODE_BAD_REQUEST);
$exception->setExceptionCode("ID EXIST");
throw $exception;
}
return EntityAPIHandler::getInstance($this)->createRecord($trigger ,$lar_id);
return EntityAPIHandler::getInstance($this)->createRecord($trigger ,$lar_id,$process);
}

/**
Expand All @@ -605,14 +605,14 @@ public function create( $trigger = null,$lar_id = null)
* @throws ZCRMException if Entity ID of the record is NULL
* @return APIResponse instance of the APIResponse class which holds the API response.
*/
public function update( $trigger = null)
public function update( $trigger = null,$process = null)
{
if (self::getEntityId() == null) {
$exception = new ZCRMException("Entity ID MUST NOT be null for update operation.", APIConstants::RESPONSECODE_BAD_REQUEST);
$exception->setExceptionCode("ID MISSING");
throw $exception;
}
return EntityAPIHandler::getInstance($this)->updateRecord($trigger );
return EntityAPIHandler::getInstance($this)->updateRecord($trigger,$process);
}

/**
Expand Down

0 comments on commit 4cd59fd

Please sign in to comment.