├── .gitignore ├── README.md ├── composer.json ├── samplecodes ├── bulkapi.php ├── customeview.php ├── module.php ├── organization.php ├── record.php ├── rest.php └── tagAPI.php └── src ├── crm ├── api │ ├── APIRequest.php │ ├── handler │ │ ├── APIHandler.php │ │ ├── APIHandlerInterface.php │ │ ├── EntityAPIHandler.php │ │ ├── MassEntityAPIHandler.php │ │ ├── MetaDataAPIHandler.php │ │ ├── ModuleAPIHandler.php │ │ ├── OrganizationAPIHandler.php │ │ ├── RelatedListAPIHandler.php │ │ ├── TagAPIHandler.php │ │ ├── VariableAPIHandler.php │ │ └── VariableGroupAPIHandler.php │ └── response │ │ ├── APIResponse.php │ │ ├── BulkAPIResponse.php │ │ ├── CommonAPIResponse.php │ │ ├── EntityResponse.php │ │ ├── FileAPIResponse.php │ │ └── ResponseInfo.php ├── bulkapi │ ├── handler │ │ ├── BulkAPIHandler.php │ │ ├── BulkReadAPIHandler.php │ │ └── BulkWriteAPIHandler.php │ └── response │ │ └── BulkResponse.php ├── bulkcrud │ ├── ZCRMBulkCallBack.php │ ├── ZCRMBulkCriteria.php │ ├── ZCRMBulkQuery.php │ ├── ZCRMBulkRead.php │ ├── ZCRMBulkResult.php │ ├── ZCRMBulkWrite.php │ ├── ZCRMBulkWriteFieldMapping.php │ ├── ZCRMBulkWriteFileStatus.php │ └── ZCRMBulkWriteResource.php ├── crud │ ├── ZCRMAttachment.php │ ├── ZCRMCustomView.php │ ├── ZCRMCustomViewCategory.php │ ├── ZCRMCustomViewCriteria.php │ ├── ZCRMEventParticipant.php │ ├── ZCRMField.php │ ├── ZCRMInventoryLineItem.php │ ├── ZCRMJunctionRecord.php │ ├── ZCRMLayout.php │ ├── ZCRMLeadConvertMapping.php │ ├── ZCRMLeadConvertMappingField.php │ ├── ZCRMLookupField.php │ ├── ZCRMModule.php │ ├── ZCRMModuleRelatedList.php │ ├── ZCRMModuleRelation.php │ ├── ZCRMNote.php │ ├── ZCRMOrgTax.php │ ├── ZCRMPermission.php │ ├── ZCRMPickListValue.php │ ├── ZCRMPriceBookPricing.php │ ├── ZCRMProfileCategory.php │ ├── ZCRMProfileSection.php │ ├── ZCRMRecord.php │ ├── ZCRMRelatedListProperties.php │ ├── ZCRMSection.php │ ├── ZCRMTag.php │ ├── ZCRMTax.php │ ├── ZCRMTrashRecord.php │ ├── ZCRMVariable.php │ └── ZCRMVariableGroup.php ├── exception │ ├── APIExceptionHandler.php │ └── ZCRMException.php ├── setup │ ├── org │ │ └── ZCRMOrganization.php │ ├── restclient │ │ └── ZCRMRestClient.php │ └── users │ │ ├── ZCRMProfile.php │ │ ├── ZCRMRole.php │ │ ├── ZCRMUser.php │ │ ├── ZCRMUserCustomizeInfo.php │ │ └── ZCRMUserTheme.php └── utility │ ├── APIConstants.php │ ├── CommonUtil.php │ ├── Logger.php │ ├── ZCRMConfigUtil.php │ └── ZohoHTTPConnector.php └── oauth ├── ZohoOAuth.php ├── ZohoOAuthClient.php ├── exception └── ZohoOAuthException.php ├── persistence ├── ZohoOAuthPersistenceByFile.php ├── ZohoOAuthPersistenceHandler.php └── ZohoOAuthPersistenceInterface.php └── utility ├── ZohoOAuthConstants.php ├── ZohoOAuthHTTPConnector.php ├── ZohoOAuthParams.php └── ZohoOAuthTokens.php /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .project 3 | .buildpath 4 | /vendor 5 | /.settings -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "zohocrm/php-sdk-archive", 3 | "description" : "Zoho CRM API SDK for PHP", 4 | "type" : "SDK", 5 | "homepage" : "https://github.com/zoho/zcrm-php-sdk", 6 | "authors" : [{ 7 | "name" : "Zoho CRM API Team", 8 | "email" : "support@zohocrm.com", 9 | "homepage" : "https://www.zoho.com/crm/help/customer-support.html", 10 | "role" : "Developer" 11 | } 12 | ], 13 | "require" : { 14 | "php" : ">=5.6" 15 | }, 16 | "require-dev" : { 17 | "phpunit/phpunit" : ">=5.7" 18 | }, 19 | "autoload" : { 20 | "psr-4" : { 21 | "zcrmsdk\\" : "src/" 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /samplecodes/customeview.php: -------------------------------------------------------------------------------- 1 | 10,"per_page"=>10); // key-value pair containing all the parameters - optional 20 | $header_map = array("if-modified-since"=>"2019-11-15T15:26:49+05:30");//key-value pair containing Headers to be passed -optional 21 | $response = ZCRMRestClient::getCustomViewInstance("{module_api_name}","{custom_view_id}" )->getRecords($param_map, $header_map );//to get the records($param_map - parameter map,$header_map - header map 22 | $records = $response->getData(); 23 | try { 24 | foreach ($records as $record) { 25 | echo "\n\n"; 26 | echo $record->getEntityId(); // To get record id 27 | echo $record->getModuleApiName(); // To get module api name 28 | echo $record->getLookupLabel(); // To get lookup object name 29 | $createdBy = $record->getCreatedBy(); 30 | echo $createdBy->getId(); // To get user_id who created the record 31 | echo $createdBy->getName(); // To get user name who created the record 32 | $modifiedBy = $record->getModifiedBy(); 33 | echo $modifiedBy->getId(); // To get user_id who modified the record 34 | echo $modifiedBy->getName(); // To get user name who modified the record 35 | $owner = $record->getOwner(); 36 | echo $owner->getId(); // To get record owner_id 37 | echo $owner->getName(); // To get record owner name 38 | echo $record->getCreatedTime(); // To get record created time 39 | echo $record->getModifiedTime(); // To get record modified time 40 | echo $record->getLastActivityTime(); // To get last activity time(latest modify/view time) 41 | echo $record->getFieldValue("FieldApiName"); // To get particular field value 42 | $map = $record->getData(); // To get record data as map 43 | foreach ($map as $key => $value) { 44 | if ($value instanceof ZCRMRecord) // If value is ZCRMRecord object 45 | { 46 | echo $value->getEntityId(); // to get the record id 47 | echo $value->getModuleApiName(); // to get the api name of the module 48 | echo $value->getLookupLabel(); // to get the lookup label of the record 49 | } else // If value is not ZCRMRecord object 50 | { 51 | echo $key . ":" . $value; 52 | } 53 | } 54 | /** 55 | * Fields which start with "$" are considered to be property fields * 56 | */ 57 | echo $record->getProperty('$fieldName'); // To get a particular property value 58 | $properties = $record->getAllProperties(); // To get record properties as map 59 | foreach ($properties as $key => $value) { 60 | if (is_array($value)) // If value is an array 61 | { 62 | echo "KEY::" . $key . "="; 63 | foreach ($value as $key1 => $value1) { 64 | if (is_array($value1)) { 65 | foreach ($value1 as $key2 => $value2) { 66 | echo $key2 . ":" . $value2; 67 | } 68 | } else { 69 | echo $key1 . ":" . $value1; 70 | } 71 | } 72 | } else { 73 | echo $key . ":" . $value; 74 | } 75 | } 76 | $layouts = $record->getLayout(); // To get record layout 77 | echo $layouts->getId(); // To get layout_id 78 | echo $layouts->getName(); // To get layout name 79 | 80 | $taxlists = $record->getTaxList(); // To get the tax list 81 | foreach ($taxlists as $taxlist) { 82 | echo $taxlist->getTaxName(); // To get tax name 83 | echo $taxlist->getPercentage(); // To get tax percentage 84 | echo $taxlist->getValue(); // To get tax value 85 | } 86 | $lineItems = $record->getLineItems(); // To get line_items as map 87 | foreach ($lineItems as $lineItem) { 88 | echo $lineItem->getId(); // To get line_item id 89 | echo $lineItem->getListPrice(); // To get line_item list price 90 | echo $lineItem->getQuantity(); // To get line_item quantity 91 | echo $lineItem->getDescription(); // To get line_item description 92 | echo $lineItem->getTotal(); // To get line_item total amount 93 | echo $lineItem->getDiscount(); // To get line_item discount 94 | echo $lineItem->getDiscountPercentage(); // To get line_item discount percentage 95 | echo $lineItem->getTotalAfterDiscount(); // To get line_item amount after discount 96 | echo $lineItem->getTaxAmount(); // To get line_item tax amount 97 | echo $lineItem->getNetTotal(); // To get line_item net total amount 98 | echo $lineItem->getDeleteFlag(); // To get line_item delete flag 99 | echo $lineItem->getProduct()->getEntityId(); // To get line_item product's entity id 100 | echo $lineItem->getProduct()->getLookupLabel(); // To get line_item product's lookup label 101 | $linTaxs = $lineItem->getLineTax(); // To get line_item's line_tax as array 102 | foreach ($linTaxs as $lineTax) { 103 | echo $lineTax->getTaxName(); // To get line_tax name 104 | echo $lineTax->getPercentage(); // To get line_tax percentage 105 | echo $lineTax->getValue(); // To get line_tax value 106 | } 107 | } 108 | $pricedetails = $record->getPriceDetails(); // To get the price_details array 109 | foreach ($pricedetails as $pricedetail) { 110 | echo "\n\n"; 111 | echo $pricedetail->getId(); // To get the record's price_id 112 | echo $pricedetail->getToRange(); // To get the price_detail record's to_range 113 | echo $pricedetail->getFromRange(); // To get price_detail record's from_range 114 | echo $pricedetail->getDiscount(); // To get price_detail record's discount 115 | echo "\n\n"; 116 | } 117 | $participants = $record->getParticipants(); // To get Event record's participants 118 | foreach ($participants as $participant) { 119 | echo $participant->getName(); // To get the record's participant name 120 | echo $participant->getEmail(); // To get the record's participant email 121 | echo $participant->getId(); // To get the record's participant id 122 | echo $participant->getType(); // To get the record's participant type 123 | echo $participant->isInvited(); // To check if the record's participant(s) are invited or not 124 | echo $participant->getStatus(); // To get the record's participants' status 125 | } 126 | /* End Event */ 127 | } 128 | } catch (ZCRMException $ex) { 129 | echo $ex->getMessage(); // To get ZCRMException error message 130 | echo $ex->getExceptionCode(); // To get ZCRMException error code 131 | echo $ex->getFile(); // To get the file name that throws the Exception 132 | } 133 | } 134 | } 135 | $obj=new customView(); 136 | $obj->getrecords(); -------------------------------------------------------------------------------- /src/crm/api/handler/APIHandler.php: -------------------------------------------------------------------------------- 1 | requestMethod; 24 | } 25 | 26 | public function getUrlPath() 27 | { 28 | return $this->urlPath; 29 | } 30 | 31 | public function getRequestHeaders() 32 | { 33 | return $this->requestHeaders; 34 | } 35 | 36 | public function getRequestBody() 37 | { 38 | return $this->requestBody; 39 | } 40 | 41 | public function getRequestParams() 42 | { 43 | return $this->requestParams; 44 | } 45 | 46 | public function addParam($key, $value) 47 | { 48 | if (! isset($this->requestParams[$key])) { 49 | $this->requestParams[$key] = array( 50 | $value 51 | ); 52 | } else { 53 | $valArray = $this->requestParams[$key]; 54 | array_push($valArray, $value); 55 | $this->requestParams[$key] = $valArray; 56 | } 57 | } 58 | 59 | public function addHeader($key, $value) 60 | { 61 | $this->requestHeaders[$key] = $value; 62 | } 63 | 64 | public function getRequestHeadersAsMap() 65 | { 66 | return CommonUtil . convertJSONObjectToHashMap($this->requestHeaders); 67 | } 68 | 69 | public function getRequestParamsAsMap() 70 | { 71 | return CommonUtil . convertJSONObjectToHashMap($this->requestParams); 72 | } 73 | 74 | public static function getEmptyJSONObject() 75 | { 76 | return json_decode('{}'); 77 | } 78 | 79 | /** 80 | * Set the request method 81 | * 82 | * @param String $requestMethod 83 | */ 84 | public function setRequestMethod($requestMethod) 85 | { 86 | $this->requestMethod = $requestMethod; 87 | } 88 | 89 | /** 90 | * Set the request urlPath 91 | * 92 | * @param String $urlPath 93 | */ 94 | public function setUrlPath($urlPath) 95 | { 96 | $this->urlPath = $urlPath; 97 | } 98 | 99 | /** 100 | * set the request Headers 101 | * 102 | * @param Array $requestHeaders 103 | */ 104 | public function setRequestHeaders($requestHeaders) 105 | { 106 | $this->requestHeaders = $requestHeaders; 107 | } 108 | 109 | /** 110 | * Set the request parameters 111 | * 112 | * @param Array $requestParams 113 | */ 114 | public function setRequestParams($requestParams) 115 | { 116 | $this->requestParams = $requestParams; 117 | } 118 | 119 | /** 120 | * Set the requestBody 121 | * 122 | * @param $requestBody 123 | */ 124 | public function setRequestBody($requestBody) 125 | { 126 | $this->requestBody = $requestBody; 127 | } 128 | 129 | /** 130 | * Get the API Key used in the input json data(like 'modules', 'data','layouts',..etc) 131 | * 132 | * @return String 133 | */ 134 | public function getApiKey() 135 | { 136 | return $this->apiKey; 137 | } 138 | 139 | /** 140 | * Set the API Key used in the input json data(like 'modules', 'data','layouts',..etc) 141 | * 142 | * @param String $apiKey 143 | */ 144 | public function setApiKey($apiKey) 145 | { 146 | $this->apiKey = $apiKey; 147 | } 148 | 149 | /** 150 | * Get url is bulk or not 151 | * @return boolean|Boolean 152 | */ 153 | public function isBulk() 154 | { 155 | return $this->isBulk; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/crm/api/handler/APIHandlerInterface.php: -------------------------------------------------------------------------------- 1 | urlPath="settings/variable_groups"; 23 | $this->requestMethod=APIConstants::REQUEST_METHOD_GET; 24 | $this->addHeader("Content-Type","application/json"); 25 | $this->apiKey="variable_groups"; 26 | $response=APIRequest::getInstance($this)->getBulkApiResponse(); 27 | $responseJson=$response->getResponseJson(); 28 | $data=$responseJson["variable_groups"]; 29 | $dataList=array(); 30 | foreach($data as $jsonData) 31 | { 32 | $variableGroupsIns=ZCRMVariableGroup::getInstance(); 33 | self::getVariableGroupsResAsObj($jsonData,$variableGroupsIns); 34 | array_push($dataList,$variableGroupsIns); 35 | } 36 | $response->setData($dataList); 37 | return $response; 38 | } 39 | catch(ZCRMException $exception) 40 | { 41 | APIExceptionHandler::logException($exception); 42 | throw $exception; 43 | } 44 | } 45 | 46 | private function getVariableGroupsResAsObj($jsonData,$entityInstance) 47 | { 48 | foreach($jsonData as $key=>$value) 49 | { 50 | 51 | if("id"==$key) 52 | { 53 | $entityInstance->setId($value); 54 | } 55 | else if("name"==$key) 56 | { 57 | $entityInstance->setName($value); 58 | } 59 | else if("api_name"==$key) 60 | { 61 | $entityInstance->setApiName($value); 62 | } 63 | else if("display_label"==$key) 64 | { 65 | $entityInstance->setDisplayLabel($value); 66 | } 67 | else if("description"==$key) 68 | { 69 | $entityInstance->setDescription($value); 70 | } 71 | } 72 | } 73 | 74 | public function getVariableGroup() 75 | { 76 | try{ 77 | $this->urlPath="settings/variable_groups/".$this->variable_groups->getId(); 78 | $this->requestMethod=APIConstants::REQUEST_METHOD_GET; 79 | $this->addHeader("Content-Type","application/json"); 80 | $this->apiKey="variable_groups"; 81 | $response=APIRequest::getInstance($this)->getApiResponse(); 82 | $responseJson=$response->getResponseJson(); 83 | $data=$responseJson["variable_groups"]; 84 | $jsonData=$data[0]; 85 | $variableGroupsIns=ZCRMVariableGroup::getInstance(); 86 | self::getVariableGroupResAsObj($jsonData,$variableGroupsIns); 87 | $response->setData($variableGroupsIns); 88 | return $response; 89 | } 90 | catch(ZCRMException $exception) 91 | { 92 | APIExceptionHandler::logException($exception); 93 | throw $exception; 94 | } 95 | } 96 | 97 | private function getVariableGroupResAsObj($jsonData,$entityInstance) 98 | { 99 | foreach($jsonData as $key=>$value) 100 | { 101 | 102 | if("id"==$key) 103 | { 104 | $entityInstance->setId($value); 105 | } 106 | else if("name"==$key) 107 | { 108 | $entityInstance->setName($value); 109 | } 110 | else if("api_name"==$key) 111 | { 112 | $entityInstance->setApiName($value); 113 | } 114 | else if("display_label"==$key) 115 | { 116 | $entityInstance->setDisplayLabel($value); 117 | } 118 | else if("description"==$key) 119 | { 120 | $entityInstance->setDescription($value); 121 | } 122 | } 123 | } 124 | 125 | public function setVariableGroups($variable_groups) 126 | { 127 | $this->variable_groups=$variable_groups; 128 | } 129 | } -------------------------------------------------------------------------------- /src/crm/api/response/APIResponse.php: -------------------------------------------------------------------------------- 1 | data = $data; 45 | } 46 | 47 | /** 48 | * method to get the data of the class object 49 | * 50 | * @return object data of the object 51 | */ 52 | public function getData() 53 | { 54 | return $this->data; 55 | } 56 | 57 | /** 58 | * method to Get the response status 59 | * 60 | * @return String the response status 61 | */ 62 | public function getStatus() 63 | { 64 | return $this->status; 65 | } 66 | 67 | /** 68 | * method to Set the response status 69 | * 70 | * @param String $status the response status 71 | */ 72 | public function setStatus($status) 73 | { 74 | 75 | $this->status = $status; 76 | } 77 | 78 | /** 79 | * 80 | * {@inheritdoc} 81 | * @see CommonAPIResponse::handleForFaultyResponses() 82 | */ 83 | public function handleForFaultyResponses() 84 | { 85 | $statusCode = self::getHttpStatusCode(); 86 | if (in_array($statusCode, APIExceptionHandler::getFaultyResponseCodes())) { 87 | if ($statusCode == APIConstants::RESPONSECODE_NO_CONTENT) { 88 | $exception = new ZCRMException(APIConstants::INVALID_DATA . "-" . APIConstants::INVALID_ID_MSG, $statusCode); 89 | $exception->setExceptionCode("No Content"); 90 | throw $exception; 91 | } else { 92 | $responseJSON = $this->getResponseJSON(); 93 | $exception = new ZCRMException($responseJSON[APIConstants::MESSAGE], $statusCode); 94 | $exception->setExceptionCode($responseJSON[APIConstants::CODE]); 95 | $exception->setExceptionDetails($responseJSON[APIConstants::DETAILS]); 96 | throw $exception; 97 | } 98 | } 99 | } 100 | 101 | /** 102 | * 103 | * {@inheritdoc} 104 | * @see CommonAPIResponse::processResponseData() 105 | */ 106 | public function processResponseData() 107 | { 108 | $responseJSON = $this->getResponseJSON(); 109 | if ($responseJSON == null) { 110 | return; 111 | } 112 | if (array_key_exists(APIConstants::DATA, $responseJSON)) { 113 | $responseJSON = $responseJSON[APIConstants::DATA][0]; 114 | } 115 | if (array_key_exists(APIConstants::TAGS, $responseJSON)) { 116 | $responseJSON = $responseJSON[APIConstants::TAGS][0]; 117 | } else if (array_key_exists(APIConstants::USERS, $responseJSON)) { 118 | $responseJSON = $responseJSON[APIConstants::USERS][0]; 119 | } else if (array_key_exists(APIConstants::MODULES, $responseJSON)) { 120 | $responseJSON = $responseJSON[APIConstants::MODULES]; 121 | } else if (array_key_exists(APIConstants::CUSTOM_VIEWS, $responseJSON)) { 122 | $responseJSON = $responseJSON[APIConstants::CUSTOM_VIEWS]; 123 | }else if (array_key_exists(APIConstants::TAXES, $responseJSON)) { 124 | $responseJSON = $responseJSON[APIConstants::TAXES][0]; 125 | } 126 | else if (array_key_exists("variables", $responseJSON)) { 127 | $responseJSON = $responseJSON['variables'][0]; 128 | } 129 | if (isset($responseJSON[APIConstants::STATUS]) && $responseJSON[APIConstants::STATUS] == APIConstants::STATUS_ERROR) { 130 | $exception = new ZCRMException($responseJSON[APIConstants::MESSAGE], self::getHttpStatusCode()); 131 | $exception->setExceptionCode($responseJSON[APIConstants::CODE]); 132 | $exception->setExceptionDetails($responseJSON[APIConstants::DETAILS]); 133 | throw $exception; 134 | } elseif (isset($responseJSON[APIConstants::STATUS]) && $responseJSON[APIConstants::STATUS] == APIConstants::STATUS_SUCCESS) { 135 | self::setCode($responseJSON[APIConstants::CODE]); 136 | self::setStatus($responseJSON[APIConstants::STATUS]); 137 | self::setMessage($responseJSON[APIConstants::MESSAGE]); 138 | self::setDetails($responseJSON[APIConstants::DETAILS]); 139 | } 140 | } 141 | } -------------------------------------------------------------------------------- /src/crm/api/response/BulkAPIResponse.php: -------------------------------------------------------------------------------- 1 | setInfo(); 49 | } 50 | 51 | /** 52 | * 53 | * {@inheritdoc} 54 | * @see CommonAPIResponse::handleForFaultyResponses() 55 | */ 56 | public function handleForFaultyResponses() 57 | { 58 | $statusCode = self::getHttpStatusCode(); 59 | if (in_array($statusCode, APIExceptionHandler::getFaultyResponseCodes())) { 60 | if ($statusCode == APIConstants::RESPONSECODE_NO_CONTENT) { 61 | $exception = new ZCRMException("No Content", $statusCode); 62 | $exception->setExceptionCode("NO CONTENT"); 63 | throw $exception; 64 | } 65 | else if ($statusCode == APIConstants::RESPONSECODE_NOT_MODIFIED) { 66 | $exception = new ZCRMException("Not Modified", $statusCode); 67 | $exception->setExceptionCode("NOT MODIFIED"); 68 | throw $exception; 69 | } 70 | else { 71 | $responseJSON = $this->getResponseJSON(); 72 | $exception = new ZCRMException($responseJSON[APIConstants::MESSAGE], $statusCode); 73 | $exception->setExceptionCode($responseJSON[APIConstants::CODE]); 74 | $exception->setExceptionDetails($responseJSON[APIConstants::DETAILS]); 75 | throw $exception; 76 | } 77 | } 78 | } 79 | 80 | /** 81 | * 82 | * {@inheritdoc} 83 | * @see CommonAPIResponse::processResponseData() 84 | */ 85 | public function processResponseData()//status of the response 86 | { 87 | $this->bulkEntitiesResponse = array(); 88 | $bulkResponseJSON = $this->getResponseJSON(); 89 | if (array_key_exists(APIConstants::DATA, $bulkResponseJSON)) { 90 | $recordsArray = $bulkResponseJSON[APIConstants::DATA]; 91 | foreach ($recordsArray as $record) { 92 | if ($record != null && array_key_exists(APIConstants::STATUS, $record)) { 93 | array_push($this->bulkEntitiesResponse, new EntityResponse($record)); 94 | } 95 | } 96 | } 97 | if (array_key_exists(APIConstants::TAGS, $bulkResponseJSON)) { 98 | $TagsArray = $bulkResponseJSON[APIConstants::TAGS]; 99 | foreach ($TagsArray as $Tags) { 100 | if ($Tags != null && array_key_exists(APIConstants::STATUS, $Tags)) { 101 | array_push($this->bulkEntitiesResponse, new EntityResponse($Tags)); 102 | } 103 | } 104 | } 105 | if (array_key_exists(APIConstants::TAXES, $bulkResponseJSON)) { 106 | 107 | $orgTaxesArray= $bulkResponseJSON[APIConstants::TAXES]; 108 | foreach ($orgTaxesArray as $orgTax) { 109 | if ($orgTax != null && array_key_exists(APIConstants::STATUS, $orgTax)) { 110 | array_push($this->bulkEntitiesResponse, new EntityResponse($orgTax)); 111 | } 112 | } 113 | } 114 | if (array_key_exists(APIConstants::VARIABLES, $bulkResponseJSON)) { 115 | 116 | $variables= $bulkResponseJSON[APIConstants::VARIABLES]; 117 | foreach ($variables as $variable) { 118 | if ($variable != null && array_key_exists(APIConstants::STATUS, $variable)) { 119 | array_push($this->bulkEntitiesResponse, new EntityResponse($variable)); 120 | } 121 | } 122 | } 123 | } 124 | 125 | /** 126 | * method to get the bulk data 127 | * 128 | * @return array array of data instances 129 | */ 130 | public function getData() 131 | { 132 | return $this->bulkData; 133 | } 134 | 135 | /** 136 | * method to set the bulk data 137 | * 138 | * @param array $bulkData array of data instances 139 | */ 140 | public function setData($bulkData) 141 | { 142 | $this->bulkData = $bulkData; 143 | } 144 | 145 | /** 146 | * method to Get the response status 147 | * 148 | * @return String the response status 149 | */ 150 | public function getStatus() 151 | { 152 | 153 | return $this->status; 154 | } 155 | 156 | /** 157 | * method to Set the response status 158 | * 159 | * @param String $status the response status 160 | */ 161 | public function setStatus($status) 162 | { 163 | 164 | $this->status = $status; 165 | } 166 | 167 | /** 168 | * method to get the response information 169 | * 170 | * @return ResponseInfo instance of the ResponseInfo class 171 | */ 172 | public function getInfo() 173 | { 174 | return $this->info; 175 | } 176 | 177 | /** 178 | * method to set the response information 179 | * 180 | * @param ResponseInfo $info instance of the ResponseInfo class 181 | */ 182 | public function setInfo() 183 | { 184 | if (array_key_exists(APIConstants::INFO, $this->getResponseJSON())) { 185 | $this->info = new ResponseInfo($this->getResponseJSON()[APIConstants::INFO]); 186 | } 187 | } 188 | 189 | /** 190 | * method to get the bulk entity responses 191 | * 192 | * @return array array of the instances of EntityResponse class 193 | */ 194 | public function getEntityResponses() 195 | { 196 | return $this->bulkEntitiesResponse; 197 | } 198 | } -------------------------------------------------------------------------------- /src/crm/api/response/EntityResponse.php: -------------------------------------------------------------------------------- 1 | responseJSON = $entityResponseJSON; 66 | $this->status = $entityResponseJSON[APIConstants::STATUS]; 67 | $this->message = $entityResponseJSON[APIConstants::MESSAGE]; 68 | $this->code = $entityResponseJSON[APIConstants::CODE]; 69 | if (array_key_exists(APIConstants::ACTION, $entityResponseJSON)) { 70 | $this->upsertDetails[APIConstants::ACTION] = $entityResponseJSON[APIConstants::ACTION]; 71 | } 72 | if (array_key_exists(APIConstants::DUPLICATE_FIELD, $entityResponseJSON)) { 73 | $this->upsertDetails[APIConstants::DUPLICATE_FIELD] = $entityResponseJSON[APIConstants::DUPLICATE_FIELD]; 74 | } 75 | if (array_key_exists("details", $entityResponseJSON)) { 76 | $this->details = $entityResponseJSON["details"]; 77 | } 78 | } 79 | 80 | /** 81 | * method to Get the response status like error or success 82 | * 83 | * @return String the response status 84 | */ 85 | public function getStatus() 86 | { 87 | return $this->status; 88 | } 89 | 90 | /** 91 | * method to Set the response status like error or success 92 | * 93 | * @param String $status the response status 94 | */ 95 | public function setStatus($status) 96 | { 97 | $this->status = $status; 98 | } 99 | 100 | /** 101 | * method to get the response message 102 | * 103 | * @return String the response message 104 | */ 105 | public function getMessage() 106 | { 107 | return $this->message; 108 | } 109 | 110 | /** 111 | * method to get the response message 112 | * 113 | * @param String $message the response message 114 | */ 115 | public function setMessage($message) 116 | { 117 | $this->message = $message; 118 | } 119 | 120 | /** 121 | * method to Get the response code like SUCCESS,INVALID_DATA,..etc 122 | * 123 | * @return String the response code like SUCCESS,INVALID_DATA,..etc 124 | */ 125 | public function getCode() 126 | { 127 | return $this->code; 128 | } 129 | 130 | /** 131 | * method to set the response code like SUCCESS,INVALID_DATA,..etc 132 | * 133 | * @param String $code 134 | * the response code like SUCCESS,INVALID_DATA,..etc 135 | */ 136 | public function setCode($code) 137 | { 138 | $this->code = $code; 139 | } 140 | 141 | /** 142 | * method to get the json object 143 | * 144 | * @return object the json object 145 | */ 146 | public function getResponseJSON() 147 | { 148 | return $this->responseJSON; 149 | } 150 | 151 | /** 152 | * method to get the data of the response 153 | * 154 | * @return array array of the data 155 | */ 156 | public function getData() 157 | { 158 | return $this->data; 159 | } 160 | 161 | /** 162 | * method to set the data of the response 163 | * 164 | * @param array $data array of the data 165 | */ 166 | public function setData($data) 167 | { 168 | $this->data = $data; 169 | } 170 | 171 | /** 172 | * method to get the upsert details like action,duplicate field 173 | * 174 | * @return array array containg the upsert details like action,duplicate field 175 | */ 176 | public function getUpsertDetails() 177 | { 178 | return $this->upsertDetails; 179 | } 180 | 181 | /** 182 | * method to set the details 183 | * 184 | * @param Array $details array containing the details 185 | */ 186 | public function setDetails($details) 187 | { 188 | $this->details = $details; 189 | } 190 | 191 | /** 192 | * method to get the details 193 | * 194 | * @return Array array containing the details 195 | */ 196 | public function getDetails() 197 | { 198 | return $this->details; 199 | } 200 | } -------------------------------------------------------------------------------- /src/crm/api/response/FileAPIResponse.php: -------------------------------------------------------------------------------- 1 | httpStatusCode = $httpStatusCode; 78 | if ($httpStatusCode == APIConstants::RESPONSECODE_NO_CONTENT) { 79 | $this->responseJSON = array(); 80 | $this->responseHeaders = array(); 81 | $exception = new ZCRMException(APIConstants::INVALID_ID_MSG, $httpStatusCode); 82 | $exception->setExceptionCode("No Content"); 83 | throw $exception; 84 | } 85 | list ($headers, $content) = explode("\r\n\r\n", $httpResponse, 2); 86 | $headerArray = (explode("\r\n", $headers, 50)); 87 | $headerMap = array(); 88 | foreach ($headerArray as $key) { 89 | if (strpos($key, ":") != false) { 90 | $splitArray = explode(":", $key); 91 | $headerMap[$splitArray[0]] = $splitArray[1]; 92 | } 93 | } 94 | if (in_array($httpStatusCode, APIExceptionHandler::getFaultyResponseCodes())) { 95 | $content = json_decode($content, true); 96 | $this->responseJSON = $content; 97 | $exception = new ZCRMException($content['message'], $httpStatusCode); 98 | $exception->setExceptionCode($content['code']); 99 | $exception->setExceptionDetails($content['details']); 100 | throw $exception; 101 | } else if ($httpStatusCode == APIConstants::RESPONSECODE_OK) { 102 | $this->response = $content; 103 | $this->responseJSON = array(); 104 | $this->status = APIConstants::STATUS_SUCCESS; 105 | } 106 | $this->responseHeaders = $headerMap; 107 | return $this; 108 | } 109 | 110 | /** 111 | * method to get the name of the file 112 | * 113 | * @return string the name of the file 114 | */ 115 | public function getFileName() 116 | { 117 | $contentDisp = self::getResponseHeaders()['Content-Disposition']; 118 | if($contentDisp == null) 119 | { 120 | $contentDisp = self::getResponseHeaders()['Content-disposition']; 121 | } 122 | $fileName = substr($contentDisp, strrpos($contentDisp, "'") + 1, strlen($contentDisp)); 123 | if(strpos($fileName, "=")!== false) 124 | { 125 | $fileName = substr($fileName, strrpos($fileName, "=") + 1, strlen($fileName)); 126 | $fileName = str_replace(array('\'', '"'), '', $fileName); 127 | 128 | } 129 | return $fileName; 130 | } 131 | 132 | /** 133 | * method to get the content of the file 134 | * 135 | * @return string content of the file 136 | */ 137 | public function getFileContent() 138 | { 139 | return $this->response; 140 | } 141 | 142 | /** 143 | * method to get the response 144 | * 145 | * @return String the response 146 | */ 147 | public function getResponse() 148 | { 149 | return $this->response; 150 | } 151 | 152 | /** 153 | * method to set the response 154 | * 155 | * @param String $response the reponse to be set 156 | */ 157 | public function setResponse($response) 158 | { 159 | $this->response = $response; 160 | } 161 | 162 | /** 163 | * method to get the json response object 164 | * 165 | * @return Array array of the Json response objects 166 | */ 167 | public function getResponseJSON() 168 | { 169 | return $this->responseJSON; 170 | } 171 | 172 | /** 173 | * method to set the json response objects 174 | * 175 | * @param Array $responseJSON array of the Json response objects 176 | */ 177 | public function setResponseJSON($responseJSON) 178 | { 179 | $this->responseJSON = $responseJSON; 180 | } 181 | 182 | /** 183 | * method to get the http Status Code 184 | * 185 | * @return String the http Status Code 186 | */ 187 | public function getHttpStatusCode() 188 | { 189 | return $this->httpStatusCode; 190 | } 191 | 192 | /** 193 | * method to set the http Status Code 194 | * 195 | * @param String $httpStatusCode the http Status Code 196 | */ 197 | public function setHttpStatusCode($httpStatusCode) 198 | { 199 | $this->httpStatusCode = $httpStatusCode; 200 | } 201 | 202 | /** 203 | * method to get the response headers 204 | * 205 | * @return Array array containing the response headers 206 | */ 207 | public function getResponseHeaders() 208 | { 209 | return $this->responseHeaders; 210 | } 211 | 212 | /** 213 | * method to set the response headers 214 | * 215 | * @param Array $responseHeaders array containing the response headers 216 | */ 217 | public function setResponseHeaders($responseHeaders) 218 | { 219 | $this->responseHeaders = $responseHeaders; 220 | } 221 | 222 | /** 223 | * method to get the code 224 | * 225 | * @return String the code 226 | */ 227 | public function getCode() 228 | { 229 | return $this->code; 230 | } 231 | 232 | /** 233 | * method to set the code 234 | * 235 | * @param String $code the code to be set 236 | */ 237 | public function setCode($code) 238 | { 239 | $this->code = $code; 240 | } 241 | 242 | /** 243 | * method to get the message 244 | * 245 | * @return String the message 246 | */ 247 | public function getMessage() 248 | { 249 | return $this->message; 250 | } 251 | 252 | /** 253 | * method to set the message 254 | * 255 | * @param String $message the message 256 | */ 257 | public function setMessage($message) 258 | { 259 | $this->message = $message; 260 | } 261 | 262 | /** 263 | * method to get the details 264 | * 265 | * @return Array array containing the details 266 | */ 267 | public function getDetails() 268 | { 269 | return $this->details; 270 | } 271 | 272 | /** 273 | * method to set the details 274 | * 275 | * @param Array $details array containing the details 276 | */ 277 | public function setDetails($details) 278 | { 279 | $this->details = $details; 280 | } 281 | 282 | /** 283 | * method to get the status 284 | * 285 | * @return string the status 286 | */ 287 | public function getStatus() 288 | { 289 | return $this->status; 290 | } 291 | } -------------------------------------------------------------------------------- /src/crm/api/response/ResponseInfo.php: -------------------------------------------------------------------------------- 1 | moreRecords = (bool) $reponseInfoJSON[APIConstants::MORE_RECORDS]; 54 | } 55 | if (array_key_exists(APIConstants::COUNT, $reponseInfoJSON)) { 56 | $this->recordCount = $reponseInfoJSON[APIConstants::COUNT] + 0; 57 | } 58 | if (array_key_exists(APIConstants::PAGE, $reponseInfoJSON)) { 59 | $this->pageNo = $reponseInfoJSON[APIConstants::PAGE] + 0; 60 | } 61 | if (array_key_exists(APIConstants::PER_PAGE, $reponseInfoJSON)) { 62 | $this->perPage = $reponseInfoJSON[APIConstants::PER_PAGE] + 0; 63 | } 64 | if (array_key_exists(APIConstants::ALLOWED_COUNT, $reponseInfoJSON)) { 65 | $this->tagAllowedCount = $reponseInfoJSON[APIConstants::ALLOWED_COUNT] + 0; 66 | } 67 | } 68 | 69 | /** 70 | * method to check whether more records are available or not 71 | * 72 | * @return Boolean true if more records are available otherwise false 73 | */ 74 | public function getMoreRecords() 75 | { 76 | return $this->moreRecords; 77 | } 78 | 79 | /** 80 | * method to set more records are available 81 | * 82 | * @param Boolean $moreRecords true for more records available otherwise false 83 | */ 84 | public function setMoreRecords($moreRecords) 85 | { 86 | $this->moreRecords = $moreRecords; 87 | } 88 | 89 | /** 90 | * method to get the record count 91 | * 92 | * @return int the record count 93 | */ 94 | public function getRecordCount() 95 | { 96 | return $this->recordCount; 97 | } 98 | 99 | /** 100 | * method to set the record count 101 | * 102 | * @param int $recordCount the record count 103 | */ 104 | public function setRecordCount($recordCount) 105 | { 106 | $this->recordCount = $recordCount; 107 | } 108 | 109 | /** 110 | * method to get the page number of the records 111 | * 112 | * @return int the page number of the records 113 | */ 114 | public function getPageNo() 115 | { 116 | return $this->pageNo; 117 | } 118 | 119 | /** 120 | * method to set the page number of the records 121 | * 122 | * @param int $pageNo the page number of the records 123 | */ 124 | public function setPageNo($pageNo) 125 | { 126 | $this->pageNo = $pageNo; 127 | } 128 | 129 | /** 130 | * method to get the number of records per page 131 | * 132 | * @return int the number of records per page 133 | */ 134 | public function getPerPage() 135 | { 136 | return $this->perPage; 137 | } 138 | 139 | /** 140 | * method to set the number of records per page 141 | * 142 | * @param int $perPage the number of records per page 143 | */ 144 | public function setPerPage($perPage) 145 | { 146 | $this->perPage = $perPage; 147 | } 148 | 149 | /** 150 | * method to get the allowed count of the records 151 | * 152 | * @return int the allowed count of the records 153 | */ 154 | public function getAllowedCount() 155 | { 156 | return $this->allowedCount; 157 | } 158 | 159 | /** 160 | * method to set the allowed count of the records 161 | * 162 | * @param int $allowedCount allowed count of the records 163 | */ 164 | public function setAllowedCount($allowedCount) 165 | { 166 | $this->allowedCount = $allowedCount; 167 | } 168 | } -------------------------------------------------------------------------------- /src/crm/bulkapi/response/BulkResponse.php: -------------------------------------------------------------------------------- 1 | data; 26 | } 27 | 28 | /** 29 | * @param multitype: $data 30 | */ 31 | public function setData($data) 32 | { 33 | $this->data = $data; 34 | } 35 | 36 | public function __construct($moduleAPIName, $filePointer, $checkFailedRecord,$fileType) 37 | { 38 | $this->moduleAPIName = $moduleAPIName; 39 | $this->filePointer = $filePointer; 40 | $this->checkFailedRecord = $checkFailedRecord; 41 | $this->fileType = $fileType; 42 | } 43 | 44 | public function setFieldValues($fieldValues) 45 | { 46 | if (sizeof($fieldValues) == sizeof($this->fieldAPINames)) 47 | { 48 | for($index = 0; $index < sizeof($this->fieldAPINames); $index++) 49 | { 50 | $this->fieldsvsValue[$this->fieldAPINames[$index]] = $fieldValues[$index]; 51 | } 52 | } 53 | } 54 | 55 | public function setModuleAPIName($moduleAPIName) 56 | { 57 | $this->moduleAPIName = $moduleAPIName; 58 | } 59 | 60 | public function getModuleAPIName() 61 | { 62 | return $this->moduleAPIName; 63 | } 64 | 65 | public function setFieldNames($fieldAPINames) 66 | { 67 | $this->fieldAPINames = $fieldAPINames; 68 | } 69 | 70 | public function getFieldNames() 71 | { 72 | return $this->fieldAPINames; 73 | } 74 | 75 | public function setEntityAPIHandlerIns($apiHandlerIns) 76 | { 77 | $this->apiHandlerIns = $apiHandlerIns; 78 | } 79 | 80 | public function getEntityAPIHandlerIns() 81 | { 82 | return $this->apiHandlerIns; 83 | } 84 | 85 | public function next() 86 | { 87 | return $this->apiHandlerIns->next($this->moduleAPIName, $this->fieldsvsValue, $this->rowNumber); 88 | } 89 | 90 | public function hasNext() 91 | { 92 | $this->fieldsvsValue = array(); 93 | try 94 | { 95 | if((!is_resource($this->filePointer))) 96 | { 97 | return false; 98 | } 99 | if(($fieldValues = fgetcsv($this->filePointer)) != FALSE) 100 | { 101 | if($this->fileType == "ics") 102 | { 103 | do 104 | { 105 | if(strpos($fieldValues[0],":")) 106 | { 107 | $value=explode(":", $fieldValues[0],2); 108 | if ($value[0] == "END" && count($this->fieldsvsValue) > 0 ) 109 | { 110 | $this->fieldsvsValue[$value[0]] = $value[1]; 111 | return true; 112 | } 113 | else 114 | { 115 | $this->fieldsvsValue[$value[0]] = $value[1]; 116 | } 117 | } 118 | }while((($fieldValues = fgetcsv($this->filePointer)) !== FALSE)); 119 | fclose($this->filePointer); 120 | } 121 | else if($this->checkFailedRecord) 122 | { 123 | do 124 | { 125 | $this->rowNumber++; 126 | if (in_array(APIConstants::BULK_WRITE_STATUS, $this->fieldAPINames)) 127 | { 128 | $index = array_search(APIConstants::BULK_WRITE_STATUS, $this->fieldAPINames); 129 | if (!in_array($fieldValues[$index], APIConstants::WRITE_STATUS)) 130 | { 131 | self::setFieldValues($fieldValues); 132 | return true; 133 | } 134 | } 135 | }while((($fieldValues = fgetcsv($this->filePointer)) !== FALSE)); 136 | $this->rowNumber = 0; 137 | fclose($this->filePointer); 138 | } 139 | else 140 | { 141 | if($fieldValues != null) 142 | { 143 | self::setFieldValues($fieldValues); 144 | $this->rowNumber++; 145 | return true; 146 | } 147 | else 148 | { 149 | $this->rowNumber = 0; 150 | fclose($this->filePointer); 151 | } 152 | } 153 | 154 | } 155 | return false; 156 | } 157 | catch(Exception $ex) 158 | { 159 | throw new ZCRMException($ex, APIConstants::RESPONSECODE_BAD_REQUEST); 160 | } 161 | } 162 | 163 | public function close() 164 | { 165 | $this->rowNumber = 0; 166 | fclose($this->filePointer); 167 | } 168 | 169 | public function __destruct() 170 | { 171 | $this->moduleAPIName = null; 172 | $this->fieldAPINames = null; 173 | $this->fieldValues = null; 174 | unset($this->apiHandlerIns); 175 | } 176 | } -------------------------------------------------------------------------------- /src/crm/bulkcrud/ZCRMBulkCallBack.php: -------------------------------------------------------------------------------- 1 | url = $url; 27 | $this->method = $method; 28 | } 29 | 30 | /** 31 | * Method to get the instance of the ZCRMBulkCallBack class 32 | * @param string $url 33 | * @param string $method 34 | * @return ZCRMBulkCallBack - instance 35 | */ 36 | public static function getInstance($url = null, $method = null) 37 | { 38 | return new ZCRMBulkCallBack($url, $method); 39 | } 40 | 41 | /** 42 | * Method to get a valid URL, which should allow HTTP POST method. 43 | * @return string 44 | */ 45 | public function getUrl() 46 | { 47 | return $this->url; 48 | } 49 | 50 | /** 51 | * Method to get the HTTP method of the callback url. 52 | * @return string 53 | */ 54 | public function getMethod() 55 | { 56 | return $this->method; 57 | } 58 | 59 | /** 60 | * Method to set a valid URL, which should allow HTTP POST method. 61 | * @param string $url 62 | */ 63 | public function setUrl($url) 64 | { 65 | $this->url = $url; 66 | } 67 | 68 | /** 69 | * Method to set the HTTP method of the callback url. Only HTTP POST method is supported. 70 | * @param string $method 71 | */ 72 | public function setMethod($method) 73 | { 74 | $this->method = $method; 75 | } 76 | } 77 | ?> -------------------------------------------------------------------------------- /src/crm/bulkcrud/ZCRMBulkCriteria.php: -------------------------------------------------------------------------------- 1 | apiName = $apiName; 61 | } 62 | 63 | /** 64 | * Method to get the API name of a field to be compared. 65 | * @return string 66 | */ 67 | public function getAPIName() 68 | { 69 | return $this->apiName; 70 | } 71 | 72 | /** 73 | * Method to set the value of a field to be compared. 74 | * @param string $value 75 | */ 76 | public function setValue($value) 77 | { 78 | $this->apiValue = $value; 79 | } 80 | 81 | /** 82 | * Method to get the value of a field to be compared. 83 | * @return string 84 | */ 85 | public function getValue() 86 | { 87 | return $this->apiValue; 88 | } 89 | 90 | /** 91 | * Method to set the Logical operators. 92 | * @param string $groupOperator 93 | */ 94 | public function setGroupOperator($groupOperator) 95 | { 96 | $this->groupOperator = $groupOperator; 97 | } 98 | 99 | /** 100 | * Method to get the Logical operators. 101 | * @return string 102 | */ 103 | public function getGroupOperator() 104 | { 105 | return $this->groupOperator; 106 | } 107 | 108 | /** 109 | * Method to set the comparator. 110 | * @param string $comparator 111 | */ 112 | public function setComparator($comparator) 113 | { 114 | $this->comparator = $comparator; 115 | } 116 | 117 | /** 118 | * Method to get the comparator. 119 | * @return string 120 | */ 121 | public function getComparator() 122 | { 123 | return $this->comparator; 124 | } 125 | 126 | /** 127 | * Method to set the array of criteria objects 128 | * @param string $group 129 | */ 130 | public function setGroup($group) 131 | { 132 | $this->group = $group; 133 | } 134 | 135 | /** 136 | * Method to get the array of criteria objects 137 | * @return array|string 138 | */ 139 | public function getGroup() 140 | { 141 | return $this->group; 142 | } 143 | 144 | public function setPattern($pattern) 145 | { 146 | $this->pattern = $pattern; 147 | } 148 | 149 | public function getPattern() 150 | { 151 | return $this->pattern; 152 | } 153 | 154 | public function setIndex($index) 155 | { 156 | $this->index = $index; 157 | } 158 | 159 | public function getIndex() 160 | { 161 | return $this->index; 162 | } 163 | 164 | public function setCriteria($criteria) 165 | { 166 | $this->criteria = $criteria; 167 | } 168 | 169 | public function getCriteria() 170 | { 171 | return $this->criteria; 172 | } 173 | } 174 | ?> -------------------------------------------------------------------------------- /src/crm/bulkcrud/ZCRMBulkQuery.php: -------------------------------------------------------------------------------- 1 | page = $page; 61 | } 62 | 63 | /** 64 | * Method to get index of the record to be obtained. 65 | * @return int 66 | */ 67 | public function getPage() 68 | { 69 | return $this->page; 70 | } 71 | 72 | /** 73 | * Method to set the API Name of the fields to be fetched. 74 | * @param array $fields 75 | */ 76 | public function setFields($fields) 77 | { 78 | $this->fields = $fields; 79 | } 80 | 81 | /** 82 | * Method to get the API Name of the fields to be fetched. 83 | * @return array 84 | */ 85 | public function getFields() 86 | { 87 | return $this->fields; 88 | } 89 | 90 | /** 91 | * Method to set the API Name of the module to be read. 92 | * @param string $module 93 | */ 94 | public function setModuleAPIName($module) 95 | { 96 | $this->module = $module; 97 | } 98 | 99 | /** 100 | * Method to get the API Name of the module to be read. 101 | * @return string 102 | */ 103 | public function getModuleAPIName() 104 | { 105 | return $this->module; 106 | } 107 | 108 | /** 109 | * Method to set the unique ID of the custom view whose records you want to export. 110 | * @param string $cvid 111 | */ 112 | public function setCvId($cvid) 113 | { 114 | $this->cvId = $cvid; 115 | } 116 | 117 | /** 118 | * Method to get the unique ID of the custom view whose records you want to export. 119 | * @return string 120 | */ 121 | public function getCvId() 122 | { 123 | return $this->cvId; 124 | } 125 | 126 | /** 127 | * Method to set filter the records to be exported. 128 | * @param ZCRMBulkCriteria $criteria 129 | */ 130 | public function setCriteria($criteria) 131 | { 132 | $this->criteria = $criteria; 133 | } 134 | 135 | /** 136 | * Method to get filter details the records to be exported. 137 | * @return ZCRMBulkCriteria - instance 138 | */ 139 | public function getCriteria() 140 | { 141 | return $this->criteria; 142 | } 143 | 144 | public function setCriteriaCondition($criteriaConditiona) 145 | { 146 | $this->criteriaCondition = $criteriaConditiona; 147 | } 148 | 149 | public function getCriteriaCondition() 150 | { 151 | return $this->criteriaCondition; 152 | } 153 | 154 | public function setCriteriaPattern($criteriaPattern) 155 | { 156 | $this->criteriaPattern = $criteriaPattern; 157 | } 158 | 159 | public function getCriteriaPattern() 160 | { 161 | return $this->criteriaPattern; 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/crm/bulkcrud/ZCRMBulkResult.php: -------------------------------------------------------------------------------- 1 | page = $page; 52 | } 53 | 54 | /** 55 | * Method to get the range of the number of records exported. 56 | * @return int 57 | */ 58 | public function getPage() 59 | { 60 | return $this->page; 61 | } 62 | 63 | /** 64 | * Method to set the actual number of records exported. 65 | * @param int $count 66 | */ 67 | public function setCount($count) 68 | { 69 | $this->count = $count; 70 | } 71 | 72 | /** 73 | * Method to get the actual number of records exported. 74 | * @return int 75 | */ 76 | public function getCount() 77 | { 78 | return $this->count; 79 | } 80 | 81 | /** 82 | * Method to set the url which contains the CSV file 83 | * @param string $downloadUrl 84 | */ 85 | public function setDownloadUrl($downloadUrl) 86 | { 87 | $this->downloadUrl = $downloadUrl; 88 | } 89 | 90 | /** 91 | * Method to get the url which contains the CSV file. 92 | * @return string 93 | */ 94 | public function getDownloadUrl() 95 | { 96 | return $this->downloadUrl; 97 | } 98 | 99 | /** 100 | * Method to set the number of records in each page. 101 | * @param int $perPage 102 | */ 103 | public function setPerPage($perPage) 104 | { 105 | $this->perPage = $perPage; 106 | } 107 | 108 | /** 109 | * Method to get the number of records in each page. 110 | * @return string 111 | */ 112 | public function getPerPage() 113 | { 114 | return $this->perPage; 115 | } 116 | 117 | /** 118 | * Method to set the response can be used to detect if there are any further records. 119 | * @param boolean $moreRecords 120 | */ 121 | public function setMoreRecords($moreRecords) 122 | { 123 | $this->moreRecords = $moreRecords; 124 | } 125 | 126 | /** 127 | * Method to get the response can be used to detect if there are any further records. 128 | * @return boolean 129 | */ 130 | public function getMoreRecords() 131 | { 132 | return $this->moreRecords; 133 | } 134 | } 135 | 136 | ?> -------------------------------------------------------------------------------- /src/crm/bulkcrud/ZCRMBulkWriteFieldMapping.php: -------------------------------------------------------------------------------- 1 | 33 | */ 34 | private $default_value = array(); 35 | 36 | /** 37 | * constructor to set the field API name and field index 38 | * @param string $api_name 39 | * @param int $index 40 | */ 41 | private function __construct($api_name, $index) 42 | { 43 | $this->api_name = $api_name; 44 | $this->index = $index; 45 | } 46 | 47 | /** 48 | * Method to get the instance of the ZCRMBulkWriteFieldMapping class 49 | * @param string $api_name 50 | * @param int $index 51 | * @return ZCRMBulkWriteFieldMapping - class instance 52 | */ 53 | public static function getInstance($api_name = null, $index = null) 54 | { 55 | return new ZCRMBulkWriteFieldMapping($api_name, $index); 56 | } 57 | 58 | /** 59 | * Method to set the API name of the field present in Zoho module object that you want to import. 60 | * @param string $api_name 61 | */ 62 | public function setFieldAPIName($api_name) 63 | { 64 | $this->api_name = $api_name; 65 | } 66 | 67 | /** 68 | * Method to get the field API name of the field you want to import from the module. 69 | * @return string 70 | */ 71 | public function getFieldAPIName() 72 | { 73 | return $this->api_name; 74 | } 75 | 76 | /** 77 | * Method to set the column index of the field you want to map to the CRM field. 78 | * @param int $index 79 | */ 80 | public function setIndex($index) 81 | { 82 | $this->index = $index; 83 | } 84 | 85 | /** 86 | * Method to get the column index of the field you have mapped to the CRM module. 87 | * @return number 88 | */ 89 | public function getIndex() 90 | { 91 | return $this->index; 92 | } 93 | 94 | /** 95 | * Method to set the API name of the unique field or primary field(record ID) in the module. 96 | * @param string $find_by 97 | */ 98 | public function setFindBy($find_by) 99 | { 100 | $this->find_by = $find_by; 101 | } 102 | 103 | /** 104 | * Method to get the API name of the unique field or primary field(record ID) in the module. 105 | * @return string 106 | */ 107 | public function getFindBy() 108 | { 109 | return $this->find_by; 110 | } 111 | 112 | /** 113 | * Method to set the format of field value 114 | * @param string $format 115 | */ 116 | public function setFormat($format) 117 | { 118 | $this->format = $format; 119 | } 120 | 121 | /** 122 | * Method to get the format of field value 123 | * @return string 124 | */ 125 | public function getFormat() 126 | { 127 | return $this->format; 128 | } 129 | 130 | /** 131 | * Method to set the default value with which the system replaces any partial or empty file column in the CSV file. 132 | * @param string $key 133 | * @param object $value 134 | */ 135 | public function setDefaultValue($key, $value) 136 | { 137 | $this->default_value[$key] = $value; 138 | } 139 | 140 | /** 141 | * Method to get the default value with which the system replaces any partial or empty file column in the CSV file. 142 | * @return map 143 | */ 144 | public function getDefaultValue() 145 | { 146 | return $this->default_value; 147 | } 148 | } 149 | ?> -------------------------------------------------------------------------------- /src/crm/bulkcrud/ZCRMBulkWriteFileStatus.php: -------------------------------------------------------------------------------- 1 | name = $fileName; 49 | } 50 | 51 | /** 52 | * Method to get the instance of the ZCRMBulkWriteFile class 53 | * @param string $fileName 54 | * @return ZCRMBulkWriteFileStatus - class instance 55 | */ 56 | public static function getInstance($fileName = null) 57 | { 58 | return new ZCRMBulkWriteFileStatus($fileName); 59 | } 60 | 61 | /** 62 | * Method to set the status of the bulk write job for that file. 63 | * @param string $status 64 | */ 65 | public function setStatus($status) 66 | { 67 | $this->status = $status; 68 | } 69 | 70 | /** 71 | * Method to get the status of the bulk write job for that file. 72 | * @return string 73 | */ 74 | public function getStatus() 75 | { 76 | return $this->status; 77 | } 78 | 79 | /** 80 | * Method to set the name of the CSV file which will get downloaded. 81 | * @param string $fileName 82 | */ 83 | public function setFileName($fileName) 84 | { 85 | $this->name = $fileName; 86 | } 87 | 88 | /** 89 | * Method to get the name of the CSV file which will get downloaded. 90 | * @return string 91 | */ 92 | public function getFileName() 93 | { 94 | return $this->name; 95 | } 96 | 97 | /** 98 | * Method to set the number of records added or imported. 99 | * @param int $added_count 100 | */ 101 | public function setAddedCount($added_count) 102 | { 103 | $this->added_count = $added_count; 104 | } 105 | 106 | /** 107 | * Method to get the number of records added or imported. 108 | * @return number 109 | */ 110 | public function getAddedCount() 111 | { 112 | return $this->added_count; 113 | } 114 | 115 | /** 116 | * Method to set the number of records skipped due to some issues. 117 | * @param int $skipped_count 118 | */ 119 | public function setSkippedCount($skipped_count) 120 | { 121 | $this->skipped_count = $skipped_count; 122 | } 123 | 124 | /** 125 | * Method to get the number of records skipped due to some issues. 126 | * @return number 127 | */ 128 | public function getSkippedCount() 129 | { 130 | return $this->skipped_count; 131 | } 132 | 133 | /** 134 | * Method to set the number of records updated during bulk update. 135 | * @param int $updated_count 136 | */ 137 | public function setUpdatedCount($updated_count) 138 | { 139 | $this->updated_count = $updated_count; 140 | } 141 | 142 | /** 143 | * Method to get the number of records updated during bulk update. 144 | * @return number 145 | */ 146 | public function getUpdatedCount() 147 | { 148 | return $this->updated_count; 149 | } 150 | 151 | /** 152 | * Method to set the total number of records inserted, updated, or skipped during bulk import. 153 | * @param int $total_count 154 | */ 155 | public function setTotalCount($total_count) 156 | { 157 | $this->total_count = $total_count; 158 | } 159 | 160 | /** 161 | * Method to get the total number of records inserted, updated, or skipped during bulk import. 162 | * @return number 163 | */ 164 | public function getTotalCount() 165 | { 166 | return $this->total_count; 167 | } 168 | } 169 | ?> -------------------------------------------------------------------------------- /src/crm/bulkcrud/ZCRMBulkWriteResource.php: -------------------------------------------------------------------------------- 1 | module = $moduleAPIName; 68 | $this->fileId = $fileId; 69 | } 70 | 71 | /** 72 | * Method to get the instance of the ZCRMBulkWriteResource class 73 | * @param string $moduleAPIName 74 | * @param string $file_id 75 | * @return ZCRMBulkWriteResource - class instance 76 | */ 77 | public static function getInstance($moduleAPIName = null, $file_id = null) 78 | { 79 | return new ZCRMBulkWriteResource($moduleAPIName, $file_id); 80 | } 81 | 82 | /** 83 | * Method to set status of the bulk write job for that module. 84 | * @param string $status 85 | */ 86 | public function setStatus($status) 87 | { 88 | $this->status = $status; 89 | } 90 | 91 | /** 92 | * Method to get status of the bulk write job for that module 93 | * @return string 94 | */ 95 | public function getStatus() 96 | { 97 | return $this->status; 98 | } 99 | 100 | /** 101 | * Method to set type of the module that you want to import. The value is data. 102 | * @param string $type 103 | */ 104 | public function setType($type) 105 | { 106 | $this->type = $type; 107 | } 108 | 109 | /** 110 | * Method to get type of the module that you want to import. The value is data. 111 | * @return string 112 | */ 113 | public function getType() 114 | { 115 | return $this->type; 116 | } 117 | 118 | /** 119 | * Method to set the API name of the module that is imported. 120 | * @param string $module 121 | */ 122 | public function setModuleAPIName($module) 123 | { 124 | $this->module = $module; 125 | } 126 | 127 | /** 128 | * Method to get the API name of the module that is imported. 129 | * @return string 130 | */ 131 | public function getModuleAPIName() 132 | { 133 | return $this->module; 134 | } 135 | 136 | /** 137 | * Method to get the file_id obtained from file upload API. 138 | * @return string 139 | */ 140 | public function getFileId() 141 | { 142 | return $this->fileId; 143 | } 144 | 145 | /** 146 | * Method to set the file_id obtained from file upload API. 147 | * @param string $fileId 148 | */ 149 | public function setFileId($fileId) 150 | { 151 | $this->fileId = $fileId; 152 | } 153 | 154 | /** 155 | * Method to set True - Ignores the empty values. False or empty - with empty values . The default value is false. 156 | * @param boolean $ignore_empty 157 | */ 158 | public function setIgnoreEmpty($ignore_empty) 159 | { 160 | $this->ignore_empty = $ignore_empty; 161 | } 162 | 163 | /** 164 | * Method to get True/False. 165 | * @return boolean 166 | */ 167 | public function getIgnoreEmpty() 168 | { 169 | return $this->ignore_empty; 170 | } 171 | 172 | /** 173 | * Method to set the API name of a unique field or ID of a record. 174 | * @param string $findBy 175 | */ 176 | public function setFindBy($findBy) 177 | { 178 | $this->findBy = $findBy; 179 | } 180 | 181 | /** 182 | * Method to get the API name of a unique field or ID of a record. 183 | * @return string 184 | */ 185 | public function getFindBy() 186 | { 187 | return $this->findBy; 188 | } 189 | 190 | /** 191 | * Method to set ZCRMBulkWriteFieldMapping instance 192 | * @param array $field_mappings 193 | */ 194 | public function setFieldMapping($field_mappings) 195 | { 196 | array_push($this->field_mappings,$field_mappings); 197 | } 198 | 199 | /** 200 | * Method to get the field_mappings properties table for information on field_mappings object. 201 | * @return array 202 | */ 203 | public function getFieldMapping() 204 | { 205 | return $this->field_mappings; 206 | } 207 | 208 | /** 209 | * Method to set ZCRMBulkWriteFile instance 210 | * @param ZCRMBulkWriteFileStatus $file 211 | */ 212 | public function setFileStatus($file) 213 | { 214 | $this->fileStatus = $file; 215 | } 216 | 217 | /** 218 | * Method to get the file properties table for information on file object 219 | * @return ZCRMBulkWriteFileStatus 220 | */ 221 | public function getFileStatus() 222 | { 223 | return $this->fileStatus; 224 | } 225 | 226 | /** 227 | * Method to set resource error message 228 | * @param string $message 229 | */ 230 | public function setMessage($message) 231 | { 232 | $this->message = $message; 233 | } 234 | 235 | /** 236 | * Method to get resource error message 237 | * @return string 238 | */ 239 | public function getMessage() 240 | { 241 | return $this->message; 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /src/crm/crud/ZCRMCustomViewCategory.php: -------------------------------------------------------------------------------- 1 | displayValue; 42 | } 43 | 44 | /** 45 | * Method to set the displayValue for the custom view category 46 | * 47 | * @param String $displayValue the display value 48 | */ 49 | public function setDisplayValue($displayValue) 50 | { 51 | $this->displayValue = $displayValue; 52 | } 53 | 54 | /** 55 | * Method to get the actual Value of the custom view category 56 | * 57 | * @return String the actual value 58 | */ 59 | public function getActualValue() 60 | { 61 | return $this->actualValue; 62 | } 63 | 64 | /** 65 | * Method set the actual Value for the custom view category 66 | * 67 | * @param String $actualValue the actual value 68 | */ 69 | public function setActualValue($actualValue) 70 | { 71 | $this->actualValue = $actualValue; 72 | } 73 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMCustomViewCriteria.php: -------------------------------------------------------------------------------- 1 | comparator; 59 | } 60 | 61 | /** 62 | * Method to set the custom view criteria comparator 63 | * 64 | * @param string $comparator the comparison operator 65 | */ 66 | public function setComparator($comparator) 67 | { 68 | $this->comparator = $comparator; 69 | } 70 | 71 | /** 72 | * Method to get the custom view criteria field name 73 | * 74 | * @return string field api name 75 | */ 76 | public function getField() 77 | { 78 | return $this->field; 79 | } 80 | 81 | /** 82 | * Method to set the custom view criteria field name 83 | * 84 | * @param string $field field api name 85 | */ 86 | public function setField($field) 87 | { 88 | $this->field = $field; 89 | } 90 | 91 | /** 92 | * Method to get the custom view criteria field value 93 | * 94 | * @return string field value 95 | */ 96 | public function getValue() 97 | { 98 | return $this->value; 99 | } 100 | 101 | /** 102 | * Method to set the custom view criteria field value 103 | * 104 | * @param string $value field value 105 | */ 106 | public function setValue($value) 107 | { 108 | $this->value = $value; 109 | } 110 | public function getGroup() 111 | { 112 | return $this->group; 113 | } 114 | public function getGroup_operator() 115 | { 116 | return $this->group_operator; 117 | } 118 | public function getPattern() 119 | { 120 | return $this->pattern; 121 | } 122 | public function getIndex() 123 | { 124 | return $this->index; 125 | } 126 | public function getCriteria() 127 | { 128 | return $this->criteria; 129 | } 130 | public function setGroup($group) 131 | { 132 | $this->group = $group; 133 | } 134 | public function setGroup_operator($group_operator) 135 | { 136 | $this->group_operator = $group_operator; 137 | } 138 | public function setPattern($pattern) 139 | { 140 | $this->pattern = $pattern; 141 | } 142 | public function setIndex($index) 143 | { 144 | $this->index = $index; 145 | } 146 | public function setCriteria($criteria) 147 | { 148 | $this->criteria = $criteria; 149 | } 150 | 151 | 152 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMEventParticipant.php: -------------------------------------------------------------------------------- 1 | type = $type; 58 | $this->id = $id; 59 | } 60 | 61 | /** 62 | * Method to get the instance of ZCRMEvent participant 63 | * 64 | * @param string $type participant type 65 | * @param string $id record id 66 | * @return ZCRMEventParticipant the instance of ZCRMEventParticipant class 67 | */ 68 | public static function getInstance($type, $id) 69 | { 70 | return new ZCRMEventParticipant($type, $id); 71 | } 72 | 73 | /** 74 | * Method to get the Email id of the participant 75 | * 76 | * @return String participant email id 77 | */ 78 | public function getEmail() 79 | { 80 | return $this->email; 81 | } 82 | 83 | /** 84 | * Method to set the Email id of the participant 85 | * 86 | * @param String $email participant email id 87 | */ 88 | public function setEmail($email) 89 | { 90 | $this->email = $email; 91 | } 92 | 93 | /** 94 | * Method to get the name of the participant 95 | * 96 | * @return String participant name 97 | */ 98 | public function getName() 99 | { 100 | return $this->name; 101 | } 102 | 103 | /** 104 | * Method to set the name of the participant 105 | * 106 | * @param String $name participant name 107 | */ 108 | public function setName($name) 109 | { 110 | $this->name = $name; 111 | } 112 | 113 | /** 114 | * Method to get the record id of the participant 115 | * 116 | * @return string record id of the participant 117 | */ 118 | public function getId() 119 | { 120 | return $this->id; 121 | } 122 | 123 | /** 124 | * Method to set the record id of the participant 125 | * 126 | * @param string $id record id of the participant 127 | */ 128 | public function setId($id) 129 | { 130 | $this->id = $id; 131 | } 132 | 133 | /** 134 | * Method to get the participant type 135 | * 136 | * @return String participant type 137 | */ 138 | public function getType() 139 | { 140 | return $this->type; 141 | } 142 | 143 | /** 144 | * Method to set the participant type 145 | * 146 | * @param String $type the participant type 147 | */ 148 | public function setType($type) 149 | { 150 | $this->type = $type; 151 | } 152 | 153 | /** 154 | * Method to check whether the participant is invited 155 | * 156 | * @return boolean true if invited 157 | */ 158 | public function isInvited() 159 | { 160 | return $this->isInvited; 161 | } 162 | 163 | /** 164 | * Method to set the invite status of the participant 165 | * 166 | * @param boolean $isInvited true if invited 167 | */ 168 | public function setInvited($isInvited) 169 | { 170 | $this->isInvited = $isInvited; 171 | } 172 | 173 | /** 174 | * Method to get the status of the participant 175 | * 176 | * @return String status of the participant 177 | */ 178 | public function getStatus() 179 | { 180 | return $this->status; 181 | } 182 | 183 | /** 184 | * Method to set the status of the participant 185 | * 186 | * @param String $status status of the participant 187 | */ 188 | public function setStatus($status) 189 | { 190 | $this->status = $status; 191 | } 192 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMJunctionRecord.php: -------------------------------------------------------------------------------- 1 | apiName = $apiName; 37 | $this->id = $id; 38 | } 39 | 40 | /** 41 | * methdo to get the instance of the junction record 42 | * 43 | * @param string $apiName module api name of the junction record 44 | * @param string $id junction record id 45 | * @return ZCRMJunctionRecord instance of ZCRMJunctionRecord class 46 | */ 47 | public static function getInstance($apiName, $id) 48 | { 49 | return new ZCRMJunctionRecord($apiName, $id); 50 | } 51 | 52 | /** 53 | * method to get the ID of the junction record 54 | * 55 | * @return string junction record id 56 | */ 57 | public function getId() 58 | { 59 | return $this->id; 60 | } 61 | 62 | /** 63 | * method to the module API name of the junction record 64 | * 65 | * @return String module api name 66 | */ 67 | public function getApiName() 68 | { 69 | return $this->apiName; 70 | } 71 | 72 | /** 73 | * method to get related details between the modules 74 | * 75 | * @return Array key-value pairs, key is the field api name, value is the field value 76 | * 77 | */ 78 | public function getRelatedDetails() 79 | { 80 | return $this->relatedDetails; 81 | } 82 | 83 | /** 84 | * method to set the related details between the modules 85 | * 86 | * @param string $fieldApiName field api name 87 | * @param string $value value of the field 88 | */ 89 | public function setRelatedData($fieldApiName, $value) 90 | { 91 | $this->relatedDetails[$fieldApiName] = $value; 92 | } 93 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMLeadConvertMapping.php: -------------------------------------------------------------------------------- 1 | name = $name; 37 | $this->id = $id; 38 | } 39 | 40 | /** 41 | * method to get the lead convert mapping instance 42 | * 43 | * @param string $name 44 | * @param string $id 45 | * @return ZCRMLeadConvertMapping instance of ZCRMLeadConvertMapping class 46 | */ 47 | public static function getInstance($name, $id) 48 | { 49 | return new ZCRMLeadConvertMapping($name, $id); 50 | } 51 | 52 | /** 53 | * method to get the name of the converted record 54 | * 55 | * @return String converted record name 56 | */ 57 | public function getName() 58 | { 59 | return $this->name; 60 | } 61 | 62 | /** 63 | * method to set the name of the converted record 64 | * 65 | * @param String $name converted record name 66 | */ 67 | public function setName($name) 68 | { 69 | $this->name = $name; 70 | } 71 | 72 | /** 73 | * method to get the converted record id 74 | * 75 | * @return string the converted record id 76 | */ 77 | public function getId() 78 | { 79 | return $this->id; 80 | } 81 | 82 | /** 83 | * method to set the converted record id 84 | * 85 | * @param string $id the converted record id 86 | */ 87 | public function setId($id) 88 | { 89 | $this->id = $id; 90 | } 91 | 92 | /** 93 | * methods to get the convertible fields of the record 94 | * 95 | * @return array array of ZCRMLeadConvertMappingField class instances 96 | */ 97 | public function getFields() 98 | { 99 | return $this->fields; 100 | } 101 | 102 | /** 103 | * methods to set the convertible fields of the record 104 | * 105 | * @param ZCRMLeadConvertMappingField $fieldIns instance of ZCRMLeadConvertMappingField class 106 | */ 107 | public function addFields($fieldIns) 108 | { 109 | array_push($this->fields, $fieldIns); 110 | } 111 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMLeadConvertMappingField.php: -------------------------------------------------------------------------------- 1 | apiName = $apiName; 44 | $this->id = $id; 45 | } 46 | 47 | /** 48 | * method to get the convertible field instance 49 | * 50 | * @param string $apiName api name of the convertible field 51 | * @param string $id convertible field id 52 | * @return ZCRMLeadConvertMappingField instance of the ZCRMLeadConvertMappingField class 53 | */ 54 | public static function getInstance($apiName, $id) 55 | { 56 | return new ZCRMLeadConvertMappingField($apiName, $id); 57 | } 58 | 59 | /** 60 | * method to set the convertible field api name 61 | * 62 | * @return String the convertible field api name 63 | */ 64 | public function getApiName() 65 | { 66 | return $this->apiName; 67 | } 68 | 69 | /** 70 | * method to get the convertible field api name 71 | * 72 | * @param String $apiName the convertible field api name 73 | */ 74 | public function setApiName($apiName) 75 | { 76 | $this->apiName = $apiName; 77 | } 78 | 79 | /** 80 | * method to get the convertible field id 81 | * 82 | * @return string convertible field id 83 | */ 84 | public function getId() 85 | { 86 | return $this->id; 87 | } 88 | 89 | /** 90 | * method to set the convertible field id 91 | * 92 | * @param string $id convertible field id 93 | */ 94 | public function setId($id) 95 | { 96 | $this->id = $id; 97 | } 98 | 99 | /** 100 | * method to get the field label of the convertible field 101 | * 102 | * @return String field the field label of the convertible field 103 | */ 104 | public function getFieldLabel() 105 | { 106 | return $this->fieldLabel; 107 | } 108 | 109 | /** 110 | * method to get the field label of the convertible field 111 | * 112 | * @param String $fieldLabel the field label of the convertible field 113 | */ 114 | public function setFieldLabel($fieldLabel) 115 | { 116 | $this->fieldLabel = $fieldLabel; 117 | } 118 | 119 | /** 120 | * method check whether the convertible field is required 121 | * 122 | * @return Boolean true if required otherwise false 123 | */ 124 | public function isRequired() 125 | { 126 | return $this->required; 127 | } 128 | 129 | /** 130 | * method to make the convertible field required 131 | * 132 | * @param Boolean $visible true to make the convertible field required otherwise false 133 | */ 134 | public function setRequired($visible) 135 | { 136 | $this->required = $visible; 137 | } 138 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMLookupField.php: -------------------------------------------------------------------------------- 1 | apiName = $apiName; 43 | } 44 | 45 | /** 46 | * method to get the lookup field instance 47 | * 48 | * @param string $apiName api name of the lookup field 49 | * @return ZCRMLookupField instance of ZCRMLookupField Class 50 | */ 51 | public static function getInstance($apiName) 52 | { 53 | return new ZCRMLookupField($apiName); 54 | } 55 | 56 | /** 57 | * method to set the module name of the lookup field 58 | * 59 | * @param string $module module name 60 | */ 61 | public function setModule($module) 62 | { 63 | $this->module = $module; 64 | } 65 | 66 | /** 67 | * method to get the module name of the lookup field 68 | * 69 | * @return string module name 70 | */ 71 | public function getModule() 72 | { 73 | return $this->module; 74 | } 75 | 76 | /** 77 | * method to set the display label of the lookup field 78 | * 79 | * @param string $displayLabel display label of the lookup field 80 | */ 81 | public function setDisplayLabel($displayLabel) 82 | { 83 | $this->displayLabel = $displayLabel; 84 | } 85 | 86 | /** 87 | * method to get the display label of the lookup field 88 | * 89 | * @return string display label of the lookup field 90 | */ 91 | public function getDisplayLabel() 92 | { 93 | return $this->displayLabel; 94 | } 95 | 96 | /** 97 | * method to set the lookup field id 98 | * 99 | * @param string $id lookup field id 100 | */ 101 | public function setId($id) 102 | { 103 | $this->id = $id; 104 | } 105 | 106 | /** 107 | * method to set the lookup field id 108 | * 109 | * @return string lookup field id 110 | */ 111 | public function getId() 112 | { 113 | return $this->id; 114 | } 115 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMModuleRelatedList.php: -------------------------------------------------------------------------------- 1 | apiName = $apiName; 71 | } 72 | 73 | /** 74 | * method to get the instance of module related list 75 | * 76 | * @param string $apiName api name to the list 77 | * @return ZCRMModuleRelatedList instance of the ZCRMModuleRelatedList 78 | */ 79 | public static function getInstance($apiName) 80 | { 81 | return new ZCRMModuleRelatedList($apiName); 82 | } 83 | 84 | /** 85 | * method to set the api name of the module related list 86 | * 87 | * @param string $apiName api name of the module related list 88 | */ 89 | public function setApiName($apiName) 90 | { 91 | $this->apiName = $apiName; 92 | } 93 | 94 | /** 95 | * method to get the api name of the module related list 96 | * 97 | * @return string api name of the module related list 98 | */ 99 | public function getApiName() 100 | { 101 | return $this->apiName; 102 | } 103 | 104 | /** 105 | * method to get the module api name to which this module related list is belongs 106 | * 107 | * @return string the module api name to which this module related list is belongs 108 | */ 109 | public function getModule() 110 | { 111 | return $this->module; 112 | } 113 | 114 | /** 115 | * method to set the module api name to which this module related list is belongs 116 | * 117 | * @param string $module the module api name to which this module related list is belongs 118 | */ 119 | public function setModule($module) 120 | { 121 | $this->module = $module; 122 | } 123 | 124 | /** 125 | * method to get the display Label of the module related list 126 | * 127 | * @return string display Label of the module related list 128 | */ 129 | public function getDisplayLabel() 130 | { 131 | return $this->displayLabel; 132 | } 133 | 134 | /** 135 | * method to set the display Label of the module related list 136 | * 137 | * @param string $displayLabel the module related list 138 | */ 139 | public function setDisplayLabel($displayLabel) 140 | { 141 | $this->displayLabel = $displayLabel; 142 | } 143 | 144 | /** 145 | * method to check whether the module related list is visible 146 | * 147 | * @return boolean true if the module related list is visible else false 148 | */ 149 | public function isVisible() 150 | { 151 | return $this->visible; 152 | } 153 | 154 | /** 155 | * method to set the visibility of the module related list 156 | * 157 | * @param boolean $visible true to set the module related lsit visible else false 158 | */ 159 | public function setVisible($visible) 160 | { 161 | $this->visible = $visible; 162 | } 163 | 164 | /** 165 | * method to get name of the module related list 166 | * 167 | * @return string name of the module related list 168 | */ 169 | public function getName() 170 | { 171 | return $this->name; 172 | } 173 | 174 | /** 175 | * method to set name of the module related list 176 | * 177 | * @param string $name name of the module related list 178 | */ 179 | public function setName($name) 180 | { 181 | $this->name = $name; 182 | } 183 | 184 | /** 185 | * method to get id of the module related list 186 | * 187 | * @return string id of the module related list 188 | */ 189 | public function getId() 190 | { 191 | return $this->id; 192 | } 193 | 194 | /** 195 | * method to set id of the module related list 196 | * 197 | * @param string $id id of the module related list 198 | */ 199 | public function setId($id) 200 | { 201 | $this->id = $id; 202 | } 203 | 204 | /** 205 | * method to get the href of the module related list 206 | * 207 | * @return string href of the module related list 208 | */ 209 | public function getHref() 210 | { 211 | return $this->href; 212 | } 213 | 214 | /** 215 | * method to set the href of the module related list 216 | * 217 | * @param string $href href of the module related list 218 | */ 219 | public function setHref($href) 220 | { 221 | $this->href = $href; 222 | } 223 | 224 | /** 225 | * method to get the type of the module related list 226 | * 227 | * @return string type of the module related list 228 | */ 229 | public function getType() 230 | { 231 | return $this->type; 232 | } 233 | 234 | /** 235 | * method to set the type of the module related list 236 | * 237 | * @param string $type type of the module related list 238 | */ 239 | public function setType($type) 240 | { 241 | $this->type = $type; 242 | } 243 | 244 | /** 245 | * method to set the related list properties 246 | * 247 | * @param ZCRMRelatedListProperties $relatedListDetails instance of the ZCRMRelatedListProperties class 248 | * @return ZCRMModuleRelatedList instance of the ZCRMRelatedListProperties class 249 | */ 250 | public function setRelatedListProperties($relatedListDetails) 251 | { 252 | $this->setModule($relatedListDetails['module']); 253 | $this->setDisplaylabel($relatedListDetails['display_label']); 254 | $this->setId($relatedListDetails['id']); 255 | $this->setName($relatedListDetails['name']); 256 | $this->setType($relatedListDetails['type']); 257 | $this->setHref($relatedListDetails['href']); 258 | $this->setVisible(isset($relatedListDetails['visible']) ? (boolean) $relatedListDetails['visible'] : false); 259 | return $this; 260 | } 261 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMOrgTax.php: -------------------------------------------------------------------------------- 1 | name = $taxName; 22 | $this->id = $id; 23 | } 24 | 25 | public static function getInstance($taxName, $id) 26 | { 27 | return new ZCRMOrgTax($taxName, $id); 28 | } 29 | 30 | public function setId($taxId) 31 | { 32 | $this->id = $taxId; 33 | } 34 | 35 | public function getId() 36 | { 37 | return $this->id; 38 | } 39 | 40 | public function getName() 41 | { 42 | return $this->name; 43 | } 44 | 45 | public function setName($taxName) 46 | { 47 | $this->name = $taxName; 48 | } 49 | 50 | public function getDisplayName() 51 | { 52 | return $this->displayName; 53 | } 54 | 55 | public function setDisplayName($displayName) 56 | { 57 | $this->displayName = $displayName; 58 | } 59 | 60 | public function getValue() 61 | { 62 | return $this->value; 63 | } 64 | 65 | public function setValue($value) 66 | { 67 | $this->value = $value; 68 | } 69 | 70 | public function getSequence() 71 | { 72 | return $this->sequence; 73 | } 74 | 75 | public function setSequence($sequence) 76 | { 77 | $this->sequence = $sequence; 78 | } 79 | 80 | } 81 | 82 | ?> -------------------------------------------------------------------------------- /src/crm/crud/ZCRMPermission.php: -------------------------------------------------------------------------------- 1 | name = $name; 51 | $this->id = $id; 52 | } 53 | 54 | /** 55 | * method to get the instance of the permission 56 | * 57 | * @param string $name name of the permission 58 | * @param string $id permission id 59 | * @return ZCRMPermission instance of the ZCRMPermission class 60 | */ 61 | public static function getInstance($name, $id) 62 | { 63 | return new ZCRMPermission($name, $id); 64 | } 65 | 66 | /** 67 | * method to get the display name of the permission 68 | * 69 | * @return String display name of the permission 70 | */ 71 | public function getDisplayLabel() 72 | { 73 | return $this->displayLabel; 74 | } 75 | 76 | /** 77 | * method to set the display name of the permission 78 | * 79 | * @param String $displayLabel display name of the permission 80 | */ 81 | public function setDisplayLabel($displayLabel) 82 | { 83 | $this->displayLabel = $displayLabel; 84 | } 85 | 86 | /** 87 | * method to get the name of the module to which permission belongs 88 | * 89 | * @return String name of the module to which permission belongs 90 | */ 91 | public function getModule() 92 | { 93 | return $this->module; 94 | } 95 | 96 | /** 97 | * method to set the name of the module to which permission belongs 98 | * 99 | * @param String $module name of the module to which permission belongs 100 | */ 101 | public function setModule($module) 102 | { 103 | $this->module = $module; 104 | } 105 | 106 | /** 107 | * method to get the permission id 108 | * 109 | * @return string the permission id 110 | */ 111 | public function getId() 112 | { 113 | return $this->id; 114 | } 115 | 116 | /** 117 | * method to set the permission id 118 | * 119 | * @param string $id the permission id 120 | */ 121 | public function setId($id) 122 | { 123 | $this->id = $id; 124 | } 125 | 126 | /** 127 | * method to get the name of the permission 128 | * 129 | * @return String the name of the permission 130 | */ 131 | public function getName() 132 | { 133 | return $this->name; 134 | } 135 | 136 | /** 137 | * method to set the name of the permission 138 | * 139 | * @param String $name the name of the permission 140 | */ 141 | public function setName($name) 142 | { 143 | $this->name = $name; 144 | } 145 | 146 | /** 147 | * method to check whether the permission is enabled 148 | * 149 | * @return Boolean true if the permission is enabled otherwise false 150 | */ 151 | public function isEnabled() 152 | { 153 | return $this->enabled; 154 | } 155 | 156 | /** 157 | * method to enable the permission 158 | * 159 | * @param Boolean $enabled true to enable otherwise false 160 | */ 161 | public function setEnabled($enabled) 162 | { 163 | $this->enabled = $enabled; 164 | } 165 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMPickListValue.php: -------------------------------------------------------------------------------- 1 | displayValue = $displayValue; 56 | } 57 | 58 | /** 59 | * method to get the display value of the pick list 60 | * 61 | * @return string the display value of the pick list 62 | */ 63 | public function getDisplayValue() 64 | { 65 | return $this->displayValue; 66 | } 67 | 68 | /** 69 | * method to set the sequence number of the pick list 70 | * 71 | * @param int $seqNumber the sequence number of the pick list 72 | */ 73 | public function setSequenceNumber($seqNumber) 74 | { 75 | $this->sequenceNumber = $seqNumber; 76 | } 77 | 78 | /** 79 | * method to get the sequence number of the pick list 80 | * 81 | * @return int the sequence number of the pick list 82 | */ 83 | public function getSequenceNumber() 84 | { 85 | return $this->sequenceNumber; 86 | } 87 | 88 | /** 89 | * method to get the actual value of the pick list 90 | * 91 | * @param string $actualValue the actual value of the pick list 92 | */ 93 | public function setActualValue($actualValue) 94 | { 95 | $this->actualValue = $actualValue; 96 | } 97 | 98 | /** 99 | * method to set the actual value of the pick list 100 | * 101 | * @return string the actual value of the pick list 102 | */ 103 | public function getActualValue() 104 | { 105 | return $this->actualValue; 106 | } 107 | 108 | /** 109 | * method to set the maps for pick ist value 110 | * 111 | * @param array $maps array of mappings 112 | */ 113 | public function setMaps($maps) 114 | { 115 | $this->maps = $maps; 116 | } 117 | 118 | /** 119 | * method to get maps for pick list value 120 | * 121 | * @return array array of mappings 122 | */ 123 | public function getMaps() 124 | { 125 | return $this->maps; 126 | } 127 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMPriceBookPricing.php: -------------------------------------------------------------------------------- 1 | id = $id; 43 | } 44 | 45 | /** 46 | * method to get the instance of the price book pricing 47 | * 48 | * @param string $id price book pricing id 49 | * @return ZCRMPriceBookPricing instance of the ZCRMPriceBookPricing class 50 | */ 51 | public static function getInstance($id) 52 | { 53 | return new ZCRMPriceBookPricing($id); 54 | } 55 | 56 | /** 57 | * method to get the price book pricing id 58 | * 59 | * @return string price book pricing id 60 | */ 61 | public function getId() 62 | { 63 | return $this->id; 64 | } 65 | 66 | /** 67 | * method to set the price book pricing id 68 | * 69 | * @param string $id price book pricing id 70 | */ 71 | public function setId($id) 72 | { 73 | $this->id = $id; 74 | } 75 | 76 | /** 77 | * method to get the upper limit of price book pricing 78 | * 79 | * @return Double the upper limit of price book pricing 80 | */ 81 | public function getToRange() 82 | { 83 | return $this->toRange; 84 | } 85 | 86 | /** 87 | * method to set the upper limit of price book pricing 88 | * 89 | * @param Double $toRange upper limit of price book pricing 90 | */ 91 | public function setToRange($toRange) 92 | { 93 | $this->toRange = $toRange; 94 | } 95 | 96 | /** 97 | * method to get the lower limit of price book pricing 98 | * 99 | * @return Double the upper limit of price book pricing 100 | */ 101 | public function getFromRange() 102 | { 103 | return $this->fromRange; 104 | } 105 | 106 | /** 107 | * method to set the lower limit of price book pricing 108 | * 109 | * @param Double $fromRange lower limit of price book pricing 110 | */ 111 | public function setFromRange($fromRange) 112 | { 113 | $this->fromRange = $fromRange; 114 | } 115 | 116 | /** 117 | * method to get the discount of the price book pricing 118 | * 119 | * @return Double the discount of the price book pricing 120 | */ 121 | public function getDiscount() 122 | { 123 | return $this->discount; 124 | } 125 | 126 | /** 127 | * method to set the discount of the price book pricing 128 | * 129 | * @param Double $discount the discount of the price book pricing 130 | */ 131 | public function setDiscount($discount) 132 | { 133 | $this->discount = $discount; 134 | } 135 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMProfileCategory.php: -------------------------------------------------------------------------------- 1 | name = $name; 43 | } 44 | 45 | /** 46 | * method to get the instance of the profile 47 | * 48 | * @param string $name name of the profile 49 | * @return ZCRMProfileCategory instance of the ZCRMProfileCategory class 50 | */ 51 | public static function getInstance($name) 52 | { 53 | return new ZCRMProfileCategory($name); 54 | } 55 | 56 | /** 57 | * method to get the name of the profile 58 | * 59 | * @return string the name of the profile 60 | */ 61 | public function getName() 62 | { 63 | return $this->name; 64 | } 65 | 66 | /** 67 | * method to set the name of the profile 68 | * 69 | * @param string $name the name of the profile 70 | */ 71 | public function setName($name) 72 | { 73 | $this->name = $name; 74 | } 75 | 76 | /** 77 | * method to get the module name to which the profile belongs 78 | * 79 | * @return string module name to which the profile belongs 80 | */ 81 | public function getModule() 82 | { 83 | return $this->module; 84 | } 85 | 86 | /** 87 | * method to set the module name to which the profile belongs 88 | * 89 | * @param string $module module name to which the profile belongs 90 | */ 91 | public function setModule($module) 92 | { 93 | $this->module = $module; 94 | } 95 | 96 | /** 97 | * method to get the display name of the profile 98 | * 99 | * @return string display name of the profile 100 | */ 101 | public function getDisplayLabel() 102 | { 103 | return $this->displayLabel; 104 | } 105 | 106 | /** 107 | * method to set the display name of the profile 108 | * 109 | * @param string $displayLabel display name of the profile 110 | */ 111 | public function setDisplayLabel($displayLabel) 112 | { 113 | $this->displayLabel = $displayLabel; 114 | } 115 | 116 | /** 117 | * method to get the permission Ids of the permission applied to the profile 118 | * 119 | * @return array array of the the permission Ids of the permission applied to the profile 120 | */ 121 | public function getPermissionIds() 122 | { 123 | return $this->permissionIds; 124 | } 125 | 126 | /** 127 | * method to set the permission Ids of the permission applied to the profile 128 | * 129 | * @param array $permissionIds array of the the permission Ids of the permission applied to the profile 130 | */ 131 | public function setPermissionIds($permissionIds) 132 | { 133 | $this->permissionIds = $permissionIds; 134 | } 135 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMProfileSection.php: -------------------------------------------------------------------------------- 1 | name = $name; 29 | } 30 | 31 | /** 32 | * method to get the instance of the profile section 33 | * 34 | * @param string $name name of the profile section 35 | * @return ZCRMProfileSection instance of the ZCRMProfileSection 36 | */ 37 | public static function getInstance($name) 38 | { 39 | return new ZCRMProfileSection($name); 40 | } 41 | 42 | /** 43 | * method to get the name of profile section 44 | * 45 | * @return string the name of the profile section 46 | */ 47 | public function getName() 48 | { 49 | return $this->name; 50 | } 51 | 52 | /** 53 | * method to set the name of profile section 54 | * 55 | * @param array $name the name of the profile section 56 | */ 57 | public function setName($name) 58 | { 59 | $this->name = $name; 60 | } 61 | 62 | /** 63 | * method to get the categories to the profile section 64 | * 65 | * @return array array of ZCRMProfileCategory class instances 66 | */ 67 | public function getCategories() 68 | { 69 | return $this->categories; 70 | } 71 | 72 | /** 73 | * method to add the category to the profile section 74 | * 75 | * @param array $categoryIns ZCRMProfileCategory class instance 76 | */ 77 | public function addCategory($categoryIns) 78 | { 79 | array_push($this->categories, $categoryIns); 80 | } 81 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMRelatedListProperties.php: -------------------------------------------------------------------------------- 1 | sortBy; 49 | } 50 | 51 | /** 52 | * method to set the field api name based on which the properties should be sorted 53 | * 54 | * @param string $sortBy field api name 55 | */ 56 | public function setSortBy($sortBy) 57 | { 58 | $this->sortBy = $sortBy; 59 | } 60 | 61 | /** 62 | * method to get the sort order 63 | * 64 | * @return string ascending "asc", descending "desc" 65 | */ 66 | public function getSortOrder() 67 | { 68 | return $this->sortOrder; 69 | } 70 | 71 | /** 72 | * method to set the sort order 73 | * 74 | * @param string $sortOrder ascending "asc", descending "desc" 75 | */ 76 | public function setSortOrder($sortOrder) 77 | { 78 | $this->sortOrder = $sortOrder; 79 | } 80 | 81 | /** 82 | * method to get the fields api names 83 | * 84 | * @return array array of the field api names 85 | */ 86 | public function getFields() 87 | { 88 | return $this->fields; 89 | } 90 | 91 | /** 92 | * method to set the fields api names 93 | * 94 | * @param array $fields array of the field api names 95 | */ 96 | public function setFields($fields) 97 | { 98 | $this->fields = $fields; 99 | } 100 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMSection.php: -------------------------------------------------------------------------------- 1 | name = $name; 50 | } 51 | 52 | /** 53 | * method to get the instance of the section 54 | * 55 | * @param string $name section name 56 | * @return ZCRMSection instance of the ZCRMSection class 57 | */ 58 | public static function getInstance($name) 59 | { 60 | return new ZCRMSection($name); 61 | } 62 | 63 | /** 64 | * method to set the section name 65 | * 66 | * @param string $name section name 67 | */ 68 | public function setName($name) 69 | { 70 | $this->name = $name; 71 | } 72 | 73 | /** 74 | * method to get the section name 75 | * 76 | * @return string section name 77 | */ 78 | public function getName() 79 | { 80 | return $this->name; 81 | } 82 | 83 | /** 84 | * method to set the section display name 85 | * 86 | * @param string $displayName section display name 87 | */ 88 | public function setDisplayName($displayName) 89 | { 90 | $this->displayName = $displayName; 91 | } 92 | 93 | /** 94 | * method to get the section display name 95 | * 96 | * @return string section display name 97 | */ 98 | public function getDisplayName() 99 | { 100 | return $this->displayName; 101 | } 102 | 103 | /** 104 | * method to set the column count of the section 105 | * 106 | * @param int $count section column count 107 | */ 108 | public function setColumnCount($count) 109 | { 110 | $this->columnCount = $count; 111 | } 112 | 113 | /** 114 | * method to get the column count of the section 115 | * 116 | * @return int section column count 117 | */ 118 | public function getColumnCount() 119 | { 120 | return $this->columnCount; 121 | } 122 | 123 | /** 124 | * method to set the sequence number of the section 125 | * 126 | * @param int $seqNumber section sequence number 127 | */ 128 | public function setSequenceNumber($seqNumber) 129 | { 130 | $this->sequenceNumber = $seqNumber; 131 | } 132 | 133 | /** 134 | * method to get the sequence number of the section 135 | * 136 | * @return int section sequence number 137 | */ 138 | public function getSequenceNumber() 139 | { 140 | return $this->sequenceNumber; 141 | } 142 | 143 | /** 144 | * method to set the fields of the section 145 | * 146 | * @param array $fields array of ZCRMField instances 147 | */ 148 | public function setFields($fields) 149 | { 150 | $this->fields = $fields; 151 | } 152 | 153 | /** 154 | * method to get the fields of the section 155 | * 156 | * @return array array of ZCRMField instances 157 | */ 158 | public function getFields() 159 | { 160 | return $this->fields; 161 | } 162 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMTax.php: -------------------------------------------------------------------------------- 1 | taxName = $taxName; 42 | } 43 | 44 | /** 45 | * method to get the instance of the tax 46 | * 47 | * @param string $taxName tax name 48 | * @return ZCRMTax ZCRMTax class instance 49 | */ 50 | public static function getInstance($taxName) 51 | { 52 | return new ZCRMTax($taxName); 53 | } 54 | 55 | /** 56 | * method to get the tax name 57 | * 58 | * @return String the tax name 59 | */ 60 | public function getTaxName() 61 | { 62 | return $this->taxName; 63 | } 64 | 65 | /** 66 | * method to set the tax name 67 | * 68 | * @param String $taxName the tax name 69 | */ 70 | public function setTaxName($taxName) 71 | { 72 | $this->taxName = $taxName; 73 | } 74 | 75 | /** 76 | * method to get the tax percentage 77 | * 78 | * @return Double the tax percentage 79 | */ 80 | public function getPercentage() 81 | { 82 | return $this->percentage; 83 | } 84 | 85 | /** 86 | * method to set the tax percentage 87 | * 88 | * @param Double $percentage the tax percentage 89 | */ 90 | public function setPercentage($percentage) 91 | { 92 | $this->percentage = $percentage; 93 | } 94 | 95 | /** 96 | * method to get the tax value 97 | * 98 | * @return Double the tax value 99 | */ 100 | public function getValue() 101 | { 102 | return $this->value; 103 | } 104 | 105 | /** 106 | * method to set the tax value 107 | * 108 | * @param Double $value the tax value 109 | */ 110 | public function setValue($value) 111 | { 112 | $this->value = $value; 113 | } 114 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMTrashRecord.php: -------------------------------------------------------------------------------- 1 | type = $type; 60 | $this->entityId = $id; 61 | } 62 | 63 | /** 64 | * method to get the instance of the trash record 65 | * 66 | * @param string $type trash record type 67 | * @param string $id trash record id (default is null) 68 | * @return ZCRMTrashRecord instance of the ZCRMTrashRecord 69 | */ 70 | public static function getInstance($type, $id = null) 71 | { 72 | return new ZCRMTrashRecord($type, $id); 73 | } 74 | 75 | /** 76 | * method to get the trash record id 77 | * 78 | * @return string trash record id 79 | */ 80 | public function getEntityId() 81 | { 82 | return $this->entityId; 83 | } 84 | 85 | /** 86 | * method to set the trash record id 87 | * 88 | * @param string $entityId trash record id 89 | */ 90 | public function setEntityId($entityId) 91 | { 92 | $this->entityId = $entityId; 93 | } 94 | 95 | /** 96 | * method to get the trash record display name 97 | * 98 | * @return String trash record display name 99 | */ 100 | public function getDisplayName() 101 | { 102 | return $this->displayName; 103 | } 104 | 105 | /** 106 | * method to set the trash record display name 107 | * 108 | * @param String $displayName trash record display name 109 | */ 110 | public function setDisplayName($displayName) 111 | { 112 | $this->displayName = $displayName; 113 | } 114 | 115 | /** 116 | * method to get the trash record type 117 | * 118 | * @return String trash record type 119 | */ 120 | public function getType() 121 | { 122 | return $this->type; 123 | } 124 | 125 | /** 126 | * method to set the trash record type 127 | * 128 | * @param String $type trash record type 129 | */ 130 | public function setType($type) 131 | { 132 | $this->type = $type; 133 | } 134 | 135 | /** 136 | * method to get the delete time of the trash record 137 | * 138 | * @return string delete time of the trash record 139 | */ 140 | public function getDeletedTime() 141 | { 142 | return $this->deletedTime; 143 | } 144 | 145 | /** 146 | * method to set the delete time of the trash record 147 | * 148 | * @param string $deletedTime delete time of the trash record 149 | */ 150 | public function setDeletedTime($deletedTime) 151 | { 152 | $this->deletedTime = $deletedTime; 153 | } 154 | 155 | /** 156 | * method to get the creator of the trashed record 157 | * 158 | * @return ZCRMUser instance of the ZCRMUser calss 159 | */ 160 | public function getCreatedBy() 161 | { 162 | return $this->createdBy; 163 | } 164 | 165 | /** 166 | * method to set the creator of the trashed record 167 | * 168 | * @param ZCRMUser $createdBy creator of the trashed record 169 | */ 170 | public function setCreatedBy($createdBy) 171 | { 172 | $this->createdBy = $createdBy; 173 | } 174 | 175 | /** 176 | * method to get the deletor of the trashed record 177 | * 178 | * @return ZCRMUser deletor of the trashed record 179 | */ 180 | public function getDeletedBy() 181 | { 182 | return $this->deletedBy; 183 | } 184 | 185 | /** 186 | * method to set the deletor of the trashed record 187 | * 188 | * @param ZCRMUser $deletedBy deletor of the trashed record 189 | */ 190 | public function setDeletedBy($deletedBy) 191 | { 192 | $this->deletedBy = $deletedBy; 193 | } 194 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMVariable.php: -------------------------------------------------------------------------------- 1 | id; 18 | } 19 | public function setId($id) 20 | { 21 | $this->id=$id; 22 | } 23 | public function getName() 24 | { 25 | return $this->name; 26 | } 27 | public function setName($name) 28 | { 29 | $this->name=$name; 30 | } 31 | public function getApiName() 32 | { 33 | return $this->api_name; 34 | } 35 | public function setApiName($api_name) 36 | { 37 | $this->api_name=$api_name; 38 | } 39 | public function getType() 40 | { 41 | return $this->type; 42 | } 43 | public function setType($type) 44 | { 45 | $this->type=$type; 46 | } 47 | public function getValue() 48 | { 49 | return $this->value; 50 | } 51 | public function setValue($value) 52 | { 53 | $this->value=$value; 54 | } 55 | public function getVariableGroup() 56 | { 57 | return $this->variable_group; 58 | } 59 | public function setVariableGroup($variable_group) 60 | { 61 | $this->variable_group=$variable_group; 62 | } 63 | public function getDescription() 64 | { 65 | return $this->description; 66 | } 67 | public function setDescription($description) 68 | { 69 | $this->description=$description; 70 | } 71 | public static function getInstance() 72 | { 73 | return new ZCRMVariable(); 74 | } 75 | public function getVariable($group) 76 | { 77 | $instance = VariableAPIHandler::getInstance(); 78 | $instance->setVariables($this); 79 | return $instance->getVariable($group); 80 | } 81 | public function updateVariable() 82 | { 83 | $instance = VariableAPIHandler::getInstance(); 84 | $instance->setVariables($this); 85 | return $instance->updateVariable(); 86 | } 87 | public function deleteVariable() 88 | { 89 | $instance = VariableAPIHandler::getInstance(); 90 | $instance->setVariables($this); 91 | return $instance->deleteVariable(); 92 | } 93 | } -------------------------------------------------------------------------------- /src/crm/crud/ZCRMVariableGroup.php: -------------------------------------------------------------------------------- 1 | id; 16 | } 17 | public function setId($id) 18 | { 19 | $this->id=$id; 20 | } 21 | public function getName() 22 | { 23 | return $this->name; 24 | } 25 | public function setName($name) 26 | { 27 | $this->name=$name; 28 | } 29 | public function getApiName() 30 | { 31 | return $this->api_name; 32 | } 33 | public function setApiName($api_name) 34 | { 35 | $this->api_name=$api_name; 36 | } 37 | public function getDisplayLabel() 38 | { 39 | return $this->display_label; 40 | } 41 | public function setDisplayLabel($display_label) 42 | { 43 | $this->display_label=$display_label; 44 | } 45 | public function getDescription() 46 | { 47 | return $this->description; 48 | } 49 | public function setDescription($description) 50 | { 51 | $this->description=$description; 52 | } 53 | public static function getInstance() 54 | { 55 | return new ZCRMVariableGroup(); 56 | } 57 | public function getVariableGroup() 58 | { 59 | $instance = VariableGroupAPIHandler::getInstance(); 60 | $instance->setVariableGroups($this); 61 | return $instance->getVariableGroup(); 62 | } 63 | } -------------------------------------------------------------------------------- /src/crm/exception/APIExceptionHandler.php: -------------------------------------------------------------------------------- 1 | getMessage()}' in {$e->getFile()}({$e->getLine()})\nTrace::" . $e->getTraceAsString(); 13 | $message = $e->getMessage() . ";;Trace::" . $e->getTraceAsString(); 14 | Logger::err($msg); 15 | } 16 | 17 | public static function getFaultyResponseCodes() 18 | { 19 | return array( 20 | APIConstants::RESPONSECODE_NO_CONTENT, 21 | APIConstants::RESPONSECODE_NOT_MODIFIED, 22 | APIConstants::RESPONSECODE_NOT_FOUND, 23 | APIConstants::RESPONSECODE_AUTHORIZATION_ERROR, 24 | APIConstants::RESPONSECODE_BAD_REQUEST, 25 | APIConstants::RESPONSECODE_FORBIDDEN, 26 | APIConstants::RESPONSECODE_INTERNAL_SERVER_ERROR, 27 | APIConstants::RESPONSECODE_METHOD_NOT_ALLOWED, 28 | APIConstants::RESPONSECODE_MOVED_PERMANENTLY, 29 | APIConstants::RESPONSECODE_MOVED_TEMPORARILY, 30 | APIConstants::RESPONSECODE_REQUEST_ENTITY_TOO_LARGE, 31 | APIConstants::RESPONSECODE_TOO_MANY_REQUEST, 32 | APIConstants::RESPONSECODE_UNSUPPORTED_MEDIA_TYPE 33 | ); 34 | // return array(200,201,202,204,301,302,400,401,403,404,405,413,415,429,500); 35 | } 36 | } -------------------------------------------------------------------------------- /src/crm/exception/ZCRMException.php: -------------------------------------------------------------------------------- 1 | message}' in {$this->file}({$this->line})\n" . "{$this->getTraceAsString()}"; 39 | } 40 | 41 | /** 42 | * exceptionCode 43 | * 44 | * @return String 45 | */ 46 | public function getExceptionCode() 47 | { 48 | return $this->exceptionCode; 49 | } 50 | 51 | /** 52 | * exceptionCode 53 | * 54 | * @param String $exceptionCode 55 | */ 56 | public function setExceptionCode($exceptionCode) 57 | { 58 | $this->exceptionCode = $exceptionCode; 59 | } 60 | 61 | /** 62 | * To get the Exception details if any 63 | * 64 | * @return array with exception details 65 | */ 66 | public function getExceptionDetails() 67 | { 68 | return $this->exceptionDetails; 69 | } 70 | 71 | /** 72 | * To set the Exception details if any 73 | * 74 | * @param array with exception details 75 | */ 76 | public function setExceptionDetails($exceptionDetails) 77 | { 78 | $this->exceptionDetails = $exceptionDetails; 79 | } 80 | } -------------------------------------------------------------------------------- /src/crm/setup/restclient/ZCRMRestClient.php: -------------------------------------------------------------------------------- 1 | getAllModules(); 52 | } 53 | 54 | /** 55 | * method to get the module of the rest client 56 | * 57 | * @param string $moduleName api name of the module 58 | * @return APIResponse instance of the APIResponse class containing the api response 59 | */ 60 | public function getModule($moduleName) 61 | { 62 | return MetaDataAPIHandler::getInstance()->getModule($moduleName); 63 | } 64 | 65 | /** 66 | * method to get the organization of the rest client 67 | * 68 | * @return ZCRMOrganization instance of the ZCRMOrganization class 69 | */ 70 | public function getOrganizationInstance() 71 | { 72 | return ZCRMOrganization::getInstance(); 73 | } 74 | /** 75 | * method to get the Custom view of the organisation 76 | * 77 | * @return ZCRMCustomView instance of the ZCRMCustomView class 78 | */ 79 | public function getCustomViewInstance($moduleAPIName,$id) 80 | { 81 | return ZCRMCustomView::getInstance($moduleAPIName,$id ); 82 | } 83 | 84 | /** 85 | * method to get the module of the rest client 86 | * 87 | * @param string $moduleAPIName module api name 88 | * @return ZCRMModule instance of the ZCRMModule class 89 | */ 90 | public function getModuleInstance($moduleAPIName) 91 | { 92 | return ZCRMModule::getInstance($moduleAPIName); 93 | } 94 | 95 | /** 96 | * method to get the record of the client 97 | * 98 | * @param string $moduleAPIName module api name 99 | * @param string $entityId record id 100 | * @return ZCRMRecord instance of the ZCRMRecord class 101 | */ 102 | public function getRecordInstance($moduleAPIName, $entityId) 103 | { 104 | return ZCRMRecord::getInstance($moduleAPIName, $entityId); 105 | } 106 | 107 | /** 108 | * method to get the current user of the rest client 109 | * 110 | * @return APIResponse instance of the APIResponse class containing the api response 111 | */ 112 | public function getCurrentUser() 113 | { 114 | return OrganizationAPIHandler::getInstance()->getCurrentUser(); 115 | } 116 | 117 | /** 118 | * method to get the current user email id 119 | * 120 | * @return string currrent user email id 121 | */ 122 | public static function getCurrentUserEmailID() 123 | { 124 | return self::$CurrentUserEmailID; 125 | } 126 | 127 | /** 128 | * method to get the organization details of the rest client 129 | * 130 | * @return APIResponse instance of the APIResponse class containing the api response 131 | */ 132 | public static function getOrganizationDetails() 133 | { 134 | return OrganizationAPIHandler::getInstance()->getOrganizationDetails(); 135 | } 136 | 137 | /** 138 | * Method to get the bulk read instance 139 | * @param string $moduleName 140 | * @param string $jobId 141 | * @return ZCRMBulkRead - class instance 142 | */ 143 | public function getBulkReadInstance($moduleName = null, $jobId = null) 144 | { 145 | return ZCRMBulkRead::getInstance($moduleName, $jobId); 146 | } 147 | 148 | /** 149 | * Method to get the bulk write instance 150 | * @param string $operation - bulk write operation (insert or update) 151 | * @param string $jobId - bulk write job id 152 | * @param string $moduleAPIName - bulk write module api name 153 | * @return ZCRMBulkWrite - class instance 154 | */ 155 | public function getBulkWriteInstance($operation = null, $jobId = null, $moduleAPIName = null) 156 | { 157 | return ZCRMBulkWrite::getInstance($operation, $jobId, $moduleAPIName); 158 | } 159 | } -------------------------------------------------------------------------------- /src/crm/setup/users/ZCRMRole.php: -------------------------------------------------------------------------------- 1 | id = $roleId; 51 | $this->name = $roleName; 52 | } 53 | 54 | /** 55 | * method to get the instance of the role 56 | * 57 | * @param string $roleId role id 58 | * @param string $roleName role name 59 | * @return ZCRMRole instance of the ZCRMRole class 60 | */ 61 | public static function getInstance($roleId, $roleName) 62 | { 63 | return new ZCRMRole($roleId, $roleName); 64 | } 65 | 66 | /** 67 | * metho to get the Name of the Role 68 | * 69 | * @return String Role name 70 | */ 71 | public function getName() 72 | { 73 | return $this->name; 74 | } 75 | 76 | /** 77 | * method to set the Role name 78 | * 79 | * @param String $name the Role name 80 | */ 81 | public function setName($name) 82 | { 83 | $this->name = $name; 84 | } 85 | 86 | /** 87 | * method to get the Id of the Role 88 | * 89 | * @return string Id of the Role 90 | */ 91 | public function getId() 92 | { 93 | return $this->id; 94 | } 95 | 96 | /** 97 | * method to Set the Id of the Role 98 | * 99 | * @param string $id Id of the Role 100 | */ 101 | public function setId($id) 102 | { 103 | $this->id = $id; 104 | } 105 | 106 | /** 107 | * method to get the Reporting to role 108 | * 109 | * @return ZCRMUser instance of ZCRMUser class 110 | */ 111 | public function getReportingTo() 112 | { 113 | return $this->reportingTo; 114 | } 115 | 116 | /** 117 | * methdo to Set the Reporting to role 118 | * 119 | * @param ZCRMUser $reportingTo instance of ZCRMUser class 120 | */ 121 | public function setReportingTo($reportingTo) 122 | { 123 | $this->reportingTo = $reportingTo; 124 | } 125 | 126 | /** 127 | * method to get the Role label 128 | * 129 | * @return String the Role label 130 | */ 131 | public function getDisplayLabel() 132 | { 133 | return $this->label; 134 | } 135 | 136 | /** 137 | * method to Set the Role label 138 | * 139 | * @param String $label the Role label 140 | */ 141 | public function setDisplayLabel($label) 142 | { 143 | $this->label = $label; 144 | } 145 | 146 | /** 147 | * method to check whether the role is Admin role or not 148 | * 149 | * @return boolean true if the admin role otherwise false 150 | */ 151 | public function isAdminRole() 152 | { 153 | return $this->isAdmin; 154 | } 155 | 156 | /** 157 | * method to Set the role as Admin role 158 | * 159 | * @param boolean $isAdmin true to set as admin role otherwise false 160 | */ 161 | public function setAdminRole($isAdmin) 162 | { 163 | $this->isAdmin = $isAdmin; 164 | } 165 | } -------------------------------------------------------------------------------- /src/crm/setup/users/ZCRMUserCustomizeInfo.php: -------------------------------------------------------------------------------- 1 | notesDesc; 70 | } 71 | 72 | /** 73 | * method to set the notes description 74 | * 75 | * @param String $notesDesc the notes desc 76 | */ 77 | public function setNotesDesc($notesDesc) 78 | { 79 | $this->notesDesc = $notesDesc; 80 | } 81 | 82 | /** 83 | * method to check whether right panel is shown 84 | * 85 | * @return boolean true if the right panel is shown else false 86 | */ 87 | public function isToShowRightPanel() 88 | { 89 | return $this->isToShowRightPanel; 90 | } 91 | 92 | /** 93 | * method to show right panel 94 | * 95 | * @param boolean $isToShowRightPanel true to show right panel otherwise false 96 | */ 97 | public function setIsToShowRightPanel($isToShowRightPanel) 98 | { 99 | $this->isToShowRightPanel = $isToShowRightPanel; 100 | } 101 | 102 | /** 103 | * method to check whether business card view is shown 104 | * 105 | * @return boolean true if the business card view is shown else false 106 | */ 107 | public function isBcView() 108 | { 109 | return $this->isBcView; 110 | } 111 | 112 | /** 113 | * method to show bcview 114 | * 115 | * @param boolean $isBcView true to show business card view otherwise false 116 | */ 117 | public function setBcView($isBcView) 118 | { 119 | $this->isBcView = $isBcView; 120 | } 121 | 122 | /** 123 | * method to check whether home is shown 124 | * 125 | * @return boolean true if the home is shown else false 126 | */ 127 | public function isToShowHome() 128 | { 129 | return $this->isToShowHome; 130 | } 131 | 132 | /** 133 | * method to show home 134 | * 135 | * @param boolean $isToShowHome true to show home otherwise false 136 | */ 137 | public function setIsToShowHome($isToShowHome) 138 | { 139 | $this->isToShowHome = $isToShowHome; 140 | } 141 | 142 | /** 143 | * method to check whether detail view is shown 144 | * 145 | * @return boolean true if the detailed view is shown else false 146 | */ 147 | public function isToShowDetailView() 148 | { 149 | return $this->isToShowDetailView; 150 | } 151 | 152 | /** 153 | * method to show detail view 154 | * 155 | * @param boolean $isToShowDetailView true to show detail view otherwise false 156 | */ 157 | public function setIsToShowDetailView($isToShowDetailView) 158 | { 159 | $this->isToShowDetailView = $isToShowDetailView; 160 | } 161 | 162 | /** 163 | * method get the recent unpinned item 164 | * 165 | * @return string the recent unpinned item 166 | */ 167 | public function getUnpinRecentItem() 168 | { 169 | return $this->unpinRecentItem; 170 | } 171 | 172 | /** 173 | * method set the recent unpinned item 174 | * 175 | * @param string $unpinRecentItem the recent unpinned item 176 | */ 177 | public function setUnpinRecentItem($unpinRecentItem) 178 | { 179 | $this->unpinRecentItem = $unpinRecentItem; 180 | } 181 | } -------------------------------------------------------------------------------- /src/crm/setup/users/ZCRMUserTheme.php: -------------------------------------------------------------------------------- 1 | normalTabFontColor; 61 | } 62 | 63 | /** 64 | * method to set the normal Tab Font Color 65 | * 66 | * @param String $normalTabFontColor the normal Tab Font Color 67 | */ 68 | public function setNormalTabFontColor($normalTabFontColor) 69 | { 70 | $this->normalTabFontColor = $normalTabFontColor; 71 | } 72 | 73 | /** 74 | * method to get the normal Tab Background 75 | * 76 | * @return String the normal Tab Background 77 | */ 78 | public function getNormalTabBackground() 79 | { 80 | return $this->normalTabBackground; 81 | } 82 | 83 | /** 84 | * method to set the normal Tab Background 85 | * 86 | * @param String $normalTabBackground the normal Tab Background 87 | */ 88 | public function setNormalTabBackground($normalTabBackground) 89 | { 90 | $this->normalTabBackground = $normalTabBackground; 91 | } 92 | 93 | /** 94 | * method to get the selected Tab Font Color 95 | * 96 | * @return String the selected Tab Font Color 97 | */ 98 | public function getSelectedTabFontColor() 99 | { 100 | return $this->selectedTabFontColor; 101 | } 102 | 103 | /** 104 | * method to set the selected Tab Font Color 105 | * 106 | * @param String $selectedTabFontColor the selected Tab Font Color 107 | */ 108 | public function setSelectedTabFontColor($selectedTabFontColor) 109 | { 110 | $this->selectedTabFontColor = $selectedTabFontColor; 111 | } 112 | 113 | /** 114 | * method to get the selected Tab Background 115 | * 116 | * @return String the selected Tab Background 117 | */ 118 | public function getSelectedTabBackground() 119 | { 120 | return $this->selectedTabBackground; 121 | } 122 | 123 | /** 124 | * method to set the selected Tab Background 125 | * 126 | * @param String $selectedTabBackground the selected Tab Background 127 | */ 128 | public function setSelectedTabBackground($selectedTabBackground) 129 | { 130 | $this->selectedTabBackground = $selectedTabBackground; 131 | } 132 | } -------------------------------------------------------------------------------- /src/crm/utility/APIConstants.php: -------------------------------------------------------------------------------- 1 | getAccessToken($currentUserEmail); 105 | } 106 | 107 | public static function getAllConfigs() 108 | { 109 | return self::$configProperties; 110 | } 111 | } -------------------------------------------------------------------------------- /src/crm/utility/ZohoHTTPConnector.php: -------------------------------------------------------------------------------- 1 | 0) { 43 | $url = self::getUrl() . "?" . self::getUrlParamsAsString(self::getRequestParamsMap()); 44 | curl_setopt($curl_pointer, CURLOPT_URL, $url); 45 | 46 | } else { 47 | curl_setopt($curl_pointer, CURLOPT_URL, self::getUrl()); 48 | 49 | } 50 | curl_setopt($curl_pointer, CURLOPT_RETURNTRANSFER, true); 51 | curl_setopt($curl_pointer, CURLOPT_HEADER, 1); 52 | curl_setopt($curl_pointer, CURLOPT_USERAGENT, $this->userAgent); 53 | curl_setopt($curl_pointer, CURLOPT_HTTPHEADER, self::getRequestHeadersAsArray()); 54 | curl_setopt($curl_pointer, CURLOPT_CUSTOMREQUEST, APIConstants::REQUEST_METHOD_GET); 55 | 56 | if ($this->requestType === APIConstants::REQUEST_METHOD_POST) { 57 | curl_setopt($curl_pointer, CURLOPT_CUSTOMREQUEST, APIConstants::REQUEST_METHOD_POST); 58 | curl_setopt($curl_pointer, CURLOPT_POST, true); 59 | curl_setopt($curl_pointer, CURLOPT_POSTFIELDS, $this->isBulkRequest ? json_encode(self::getRequestBody()) : self::getRequestBody()); 60 | } else if ($this->requestType === APIConstants::REQUEST_METHOD_PUT) { 61 | curl_setopt($curl_pointer, CURLOPT_CUSTOMREQUEST, APIConstants::REQUEST_METHOD_PUT); 62 | curl_setopt($curl_pointer, CURLOPT_POSTFIELDS, $this->isBulkRequest ? json_encode(self::getRequestBody()) : self::getRequestBody()); 63 | } else if ($this->requestType === APIConstants::REQUEST_METHOD_DELETE) { 64 | curl_setopt($curl_pointer, CURLOPT_CUSTOMREQUEST, APIConstants::REQUEST_METHOD_DELETE); 65 | } 66 | $result = curl_exec($curl_pointer); 67 | $responseInfo = curl_getinfo($curl_pointer); 68 | curl_close($curl_pointer); 69 | 70 | return array( 71 | $result, 72 | $responseInfo 73 | ); 74 | } 75 | 76 | public function downloadFile() 77 | { 78 | $curl_pointer = curl_init(); 79 | curl_setopt($curl_pointer, CURLOPT_URL, self::getUrl()); 80 | curl_setopt($curl_pointer, CURLOPT_RETURNTRANSFER, true); 81 | curl_setopt($curl_pointer, CURLOPT_HEADER, 1); 82 | curl_setopt($curl_pointer, CURLOPT_USERAGENT, $this->userAgent); 83 | curl_setopt($curl_pointer, CURLOPT_HTTPHEADER, self::getRequestHeadersAsArray()); 84 | // curl_setopt($curl_pointer,CURLOPT_SSLVERSION,3); 85 | $result = curl_exec($curl_pointer); 86 | $responseInfo = curl_getinfo($curl_pointer); 87 | curl_close($curl_pointer); 88 | return array( 89 | $result, 90 | $responseInfo 91 | ); 92 | } 93 | 94 | public function getUrl() 95 | { 96 | return $this->url; 97 | } 98 | 99 | public function setUrl($url) 100 | { 101 | $this->url = $url; 102 | } 103 | 104 | public function addParam($key, $value) 105 | { 106 | if ($this->requestParams[$key] == null) { 107 | $this->requestParams[$key] = array( 108 | $value 109 | ); 110 | } else { 111 | $valArray = $this->requestParams[$key]; 112 | array_push($valArray, $value); 113 | $this->requestParams[$key] = $valArray; 114 | } 115 | } 116 | 117 | public function addHeader($key, $value) 118 | { 119 | if ($this->requestHeaders[$key] == null) { 120 | $this->requestHeaders[$key] = array( 121 | $value 122 | ); 123 | } else { 124 | $valArray = $this->requestHeaders[$key]; 125 | array_push($valArray, $value); 126 | $this->requestHeaders[$key] = $valArray; 127 | } 128 | } 129 | 130 | public function getUrlParamsAsString($urlParams) 131 | { 132 | $params_as_string = ""; 133 | foreach ($urlParams as $key => $valueArray) { 134 | foreach ($valueArray as $value) { 135 | $params_as_string = $params_as_string . $key . "=" . urlencode($value) . "&"; 136 | $this->requestParamCount ++; 137 | } 138 | } 139 | $params_as_string = rtrim($params_as_string, "&"); 140 | $params_as_string = str_replace(PHP_EOL, '', $params_as_string); 141 | 142 | return $params_as_string; 143 | } 144 | 145 | public function setRequestHeadersMap($headers) 146 | { 147 | $this->requestHeaders = $headers; 148 | } 149 | 150 | public function getRequestHeadersMap() 151 | { 152 | return $this->requestHeaders; 153 | } 154 | 155 | public function setRequestParamsMap($params) 156 | { 157 | $this->requestParams = $params; 158 | } 159 | 160 | public function getRequestParamsMap() 161 | { 162 | return $this->requestParams; 163 | } 164 | 165 | public function setRequestBody($reqBody) 166 | { 167 | $this->requestBody = $reqBody; 168 | } 169 | 170 | public function getRequestBody() 171 | { 172 | return $this->requestBody; 173 | } 174 | 175 | public function setRequestType($reqType) 176 | { 177 | $this->requestType = $reqType; 178 | } 179 | 180 | public function getRequestType() 181 | { 182 | return $this->requestType; 183 | } 184 | 185 | public function getRequestHeadersAsArray() 186 | { 187 | $headersArray = array(); 188 | $headersMap = self::getRequestHeadersMap(); 189 | foreach ($headersMap as $key => $value) { 190 | $headersArray[] = $key . ":" . $value; 191 | } 192 | 193 | return $headersArray; 194 | } 195 | 196 | /** 197 | * Get the API Key used in the input json data(like 'modules', 'data','layouts',..etc) 198 | * 199 | * @return String 200 | */ 201 | public function getApiKey() 202 | { 203 | return $this->apiKey; 204 | } 205 | 206 | /** 207 | * Set the API Key used in the input json data(like 'modules', 'data','layouts',..etc) 208 | * 209 | * @param String $apiKey 210 | */ 211 | public function setApiKey($apiKey) 212 | { 213 | $this->apiKey = $apiKey; 214 | } 215 | 216 | /** 217 | * isBulkRequest 218 | * 219 | * @return bool 220 | */ 221 | public function isBulkRequest() 222 | { 223 | return $this->isBulkRequest; 224 | } 225 | 226 | /** 227 | * isBulkRequest 228 | * 229 | * @param 230 | * $isBulkRequest 231 | */ 232 | public function setBulkRequest($isBulkRequest) 233 | { 234 | $this->isBulkRequest = $isBulkRequest; 235 | } 236 | } -------------------------------------------------------------------------------- /src/oauth/ZohoOAuth.php: -------------------------------------------------------------------------------- 1 | setAccessType(self::getConfigValue(ZohoOAuthConstants::ACCESS_TYPE)); 38 | $oAuthParams->setClientId(self::getConfigValue(ZohoOAuthConstants::CLIENT_ID)); 39 | $oAuthParams->setClientSecret(self::getConfigValue(ZohoOAuthConstants::CLIENT_SECRET)); 40 | $oAuthParams->setRedirectURL(self::getConfigValue(ZohoOAuthConstants::REDIRECT_URL)); 41 | ZohoOAuthClient::getInstance($oAuthParams); 42 | } 43 | 44 | private static function setConfigValues($configuration) 45 | { 46 | $config_keys = array( 47 | ZohoOAuthConstants::CLIENT_ID, 48 | ZohoOAuthConstants::CLIENT_SECRET, 49 | ZohoOAuthConstants::REDIRECT_URL, 50 | ZohoOAuthConstants::ACCESS_TYPE, 51 | ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS, 52 | ZohoOAuthConstants::IAM_URL, 53 | ZohoOAuthConstants::TOKEN_PERSISTENCE_PATH, 54 | ZohoOAuthConstants::DATABASE_PORT, 55 | ZohoOAuthConstants::DATABASE_PASSWORD, 56 | ZohoOAuthConstants::DATABASE_USERNAME, 57 | ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_NAME, 58 | ZohoOAuthConstants::HOST_ADDRESS 59 | ); 60 | 61 | if (! array_key_exists(ZohoOAuthConstants::ACCESS_TYPE, $configuration) || $configuration[ZohoOAuthConstants::ACCESS_TYPE] == "") { 62 | self::$configProperties[ZohoOAuthConstants::ACCESS_TYPE] = "offline"; 63 | } 64 | if (! array_key_exists(ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS, $configuration) || $configuration[ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS] == "") { 65 | self::$configProperties[ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS] = "ZohoOAuthPersistenceHandler"; 66 | } 67 | if (! array_key_exists(ZohoOAuthConstants::IAM_URL, $configuration) || $configuration[ZohoOAuthConstants::IAM_URL] == "") { 68 | self::$configProperties[ZohoOAuthConstants::IAM_URL] = "https://accounts.zoho.com"; 69 | } 70 | 71 | foreach ($config_keys as $key) { 72 | if (array_key_exists($key, $configuration)) 73 | self::$configProperties[$key] = $configuration[$key]; 74 | } 75 | } 76 | 77 | public static function getConfigValue($key) 78 | { 79 | return isset(self::$configProperties[$key])?self::$configProperties[$key]:""; 80 | } 81 | 82 | public static function getAllConfigs() 83 | { 84 | return self::$configProperties; 85 | } 86 | 87 | public static function getIAMUrl() 88 | { 89 | return self::getConfigValue(ZohoOAuthConstants::IAM_URL); 90 | } 91 | 92 | public static function getGrantURL() 93 | { 94 | return self::getIAMUrl() . "/oauth/v2/auth"; 95 | } 96 | 97 | public static function getTokenURL() 98 | { 99 | return self::getIAMUrl() . "/oauth/v2/token"; 100 | } 101 | 102 | public static function getRefreshTokenURL() 103 | { 104 | return self::getIAMUrl() . "/oauth/v2/token"; 105 | } 106 | 107 | public static function getRevokeTokenURL() 108 | { 109 | return self::getIAMUrl() . "/oauth/v2/token/revoke"; 110 | } 111 | 112 | public static function getUserInfoURL() 113 | { 114 | return self::getIAMUrl() . "/oauth/user/info"; 115 | } 116 | 117 | public static function getClientID() 118 | { 119 | return self::getConfigValue(ZohoOAuthConstants::CLIENT_ID); 120 | } 121 | 122 | public static function getClientSecret() 123 | { 124 | return self::getConfigValue(ZohoOAuthConstants::CLIENT_SECRET); 125 | } 126 | 127 | public static function getRedirectURL() 128 | { 129 | return self::getConfigValue(ZohoOAuthConstants::REDIRECT_URL); 130 | } 131 | 132 | public static function getAccessType() 133 | { 134 | return self::getConfigValue(ZohoOAuthConstants::ACCESS_TYPE); 135 | } 136 | 137 | public static function getPersistenceHandlerInstance() 138 | { 139 | try { 140 | if(ZohoOAuth::getConfigValue("token_persistence_path")!=""){ 141 | return new ZohoOAuthPersistenceByFile() ; 142 | } 143 | else if(self::$configProperties[ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS] == "ZohoOAuthPersistenceHandler"){ 144 | return new ZohoOAuthPersistenceHandler(); 145 | } 146 | else{ 147 | require_once realpath(self::$configProperties[ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS]); 148 | $str=self::$configProperties[ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS_NAME]; 149 | return new $str(); 150 | } 151 | } catch (Exception $ex) { 152 | throw new ZohoOAuthException($ex); 153 | } 154 | } 155 | 156 | public static function getClientInstance() 157 | { 158 | if (ZohoOAuthClient::getInstanceWithOutParam() == null) { 159 | throw new ZohoOAuthException("ZCRMRestClient::initialize(\$configMap) must be called before this."); 160 | 161 | } 162 | return ZohoOAuthClient::getInstanceWithOutParam(); 163 | } 164 | } -------------------------------------------------------------------------------- /src/oauth/ZohoOAuthClient.php: -------------------------------------------------------------------------------- 1 | zohoOAuthParams = $params; 21 | } 22 | 23 | public static function getInstance($params) 24 | { 25 | self::$zohoOAuthClient = new ZohoOAuthClient($params); 26 | return self::$zohoOAuthClient; 27 | } 28 | 29 | public static function getInstanceWithOutParam() 30 | { 31 | return self::$zohoOAuthClient; 32 | } 33 | 34 | public function getAccessToken($userEmailId) 35 | { 36 | $persistence = ZohoOAuth::getPersistenceHandlerInstance(); 37 | try { 38 | $tokens = $persistence->getOAuthTokens($userEmailId); 39 | } catch (ZohoOAuthException $ex) { 40 | Logger::severe("Exception while retrieving tokens from persistence - " . $ex); 41 | throw $ex; 42 | } 43 | try { 44 | return $tokens->getAccessToken(); 45 | } catch (ZohoOAuthException $ex) { 46 | Logger::info("Access Token has expired. Hence refreshing."); 47 | $tokens = self::refreshAccessToken($tokens->getRefreshToken(), $userEmailId); 48 | return $tokens->getAccessToken(); 49 | } 50 | } 51 | 52 | public function generateAccessToken($grantToken) 53 | { 54 | if ($grantToken == null) { 55 | throw new ZohoOAuthException("Grant Token is not provided."); 56 | } 57 | try { 58 | $conn = self::getZohoConnector(ZohoOAuth::getTokenURL()); 59 | $conn->addParam(ZohoOAuthConstants::GRANT_TYPE, ZohoOAuthConstants::GRANT_TYPE_AUTH_CODE); 60 | $conn->addParam(ZohoOAuthConstants::CODE, $grantToken); 61 | $resp = $conn->post(); 62 | $responseJSON = self::processResponse($resp); 63 | if (array_key_exists(ZohoOAuthConstants::ACCESS_TOKEN, $responseJSON)) { 64 | $tokens = self::getTokensFromJSON($responseJSON); 65 | $tokens->setUserEmailId(self::getUserEmailIdFromIAM($tokens->getAccessToken())); 66 | ZohoOAuth::getPersistenceHandlerInstance()->saveOAuthData($tokens); 67 | return $tokens; 68 | } else { 69 | throw new ZohoOAuthException("Exception while fetching access token from grant token - " . $resp); 70 | } 71 | } catch (ZohoOAuthException $ex) { 72 | throw new ZohoOAuthException($ex); 73 | } 74 | } 75 | 76 | public function generateAccessTokenFromRefreshToken($refreshToken, $userEmailId) 77 | { 78 | self::refreshAccessToken($refreshToken, $userEmailId); 79 | } 80 | 81 | public function refreshAccessToken($refreshToken, $userEmailId) 82 | { 83 | 84 | if ($refreshToken == null) { 85 | throw new ZohoOAuthException("Refresh token is not provided."); 86 | } 87 | try { 88 | $conn = self::getZohoConnector(ZohoOAuth::getRefreshTokenURL()); 89 | $conn->addParam(ZohoOAuthConstants::GRANT_TYPE, ZohoOAuthConstants::GRANT_TYPE_REFRESH); 90 | $conn->addParam(ZohoOAuthConstants::REFRESH_TOKEN, $refreshToken); 91 | $response = $conn->post(); 92 | $responseJSON = self::processResponse($response); 93 | if (array_key_exists(ZohoOAuthConstants::ACCESS_TOKEN, $responseJSON)) { 94 | $tokens = self::getTokensFromJSON($responseJSON); 95 | $tokens->setRefreshToken($refreshToken); 96 | $tokens->setUserEmailId($userEmailId); 97 | ZohoOAuth::getPersistenceHandlerInstance()->saveOAuthData($tokens); 98 | return $tokens; 99 | } else { 100 | throw new ZohoOAuthException("Exception while fetching access token from refresh token - " . $response); 101 | } 102 | } catch (ZohoOAuthException $ex) { 103 | throw new ZohoOAuthException($ex); 104 | } 105 | } 106 | 107 | private function getZohoConnector($url) 108 | { 109 | $zohoHttpCon = new ZohoOAuthHTTPConnector(); 110 | $zohoHttpCon->setUrl($url); 111 | $zohoHttpCon->addParam(ZohoOAuthConstants::CLIENT_ID, $this->zohoOAuthParams->getClientId()); 112 | $zohoHttpCon->addParam(ZohoOAuthConstants::CLIENT_SECRET, $this->zohoOAuthParams->getClientSecret()); 113 | $zohoHttpCon->addParam(ZohoOAuthConstants::REDIRECT_URL, $this->zohoOAuthParams->getRedirectURL()); 114 | return $zohoHttpCon; 115 | } 116 | 117 | private function getTokensFromJSON($responseObj) 118 | { 119 | $oAuthTokens = new ZohoOAuthTokens(); 120 | $expiresIn = $responseObj[ZohoOAuthConstants::EXPIRES_IN]; 121 | if(!array_key_exists(ZohoOAuthConstants::EXPIRES_IN_SEC,$responseObj)){ 122 | $expiresIn=$expiresIn*1000; 123 | } 124 | $oAuthTokens->setExpiryTime($oAuthTokens->getCurrentTimeInMillis() + $expiresIn); 125 | $accessToken = $responseObj[ZohoOAuthConstants::ACCESS_TOKEN]; 126 | $oAuthTokens->setAccessToken($accessToken); 127 | if (array_key_exists(ZohoOAuthConstants::REFRESH_TOKEN, $responseObj)) { 128 | $refreshToken = $responseObj[ZohoOAuthConstants::REFRESH_TOKEN]; 129 | $oAuthTokens->setRefreshToken($refreshToken); 130 | } 131 | return $oAuthTokens; 132 | } 133 | 134 | /** 135 | * zohoOAuthParams 136 | * 137 | * @return 138 | */ 139 | public function getZohoOAuthParams() 140 | { 141 | return $this->zohoOAuthParams; 142 | } 143 | 144 | /** 145 | * zohoOAuthParams 146 | * 147 | * @param $zohoOAuthParams 148 | */ 149 | public function setZohoOAuthParams($zohoOAuthParams) 150 | { 151 | $this->zohoOAuthParams = $zohoOAuthParams; 152 | } 153 | 154 | public function getUserEmailIdFromIAM($accessToken) 155 | { 156 | $connector = new ZohoOAuthHTTPConnector(); 157 | $connector->setUrl(ZohoOAuth::getUserInfoURL()); 158 | $connector->addHeadder(ZohoOAuthConstants::AUTHORIZATION, ZohoOAuthConstants::OAUTH_HEADER_PREFIX . $accessToken); 159 | $apiResponse = $connector->get(); 160 | $jsonResponse = self::processResponse($apiResponse); 161 | if(!array_key_exists("Email", $jsonResponse)){ 162 | throw new ZohoOAuthException("Exception while fetching UserID from access token, Make sure AAAserver.profile.Read scope is included while generating the Grant token " . $jsonResponse); 163 | } 164 | return $jsonResponse['Email']; 165 | } 166 | 167 | public function processResponse($apiResponse) 168 | { 169 | list ($headers, $content) = explode("\r\n\r\n", $apiResponse, 2); 170 | $jsonResponse = json_decode($content, true); 171 | 172 | return $jsonResponse; 173 | } 174 | } -------------------------------------------------------------------------------- /src/oauth/exception/ZohoOAuthException.php: -------------------------------------------------------------------------------- 1 | message}' in {$this->file}({$this->line})\n" . "{$this->getTraceAsString()}"; 35 | } 36 | } -------------------------------------------------------------------------------- /src/oauth/persistence/ZohoOAuthPersistenceByFile.php: -------------------------------------------------------------------------------- 1 | getUserEmailId()); 24 | $content = file_get_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt" ); 25 | if ($content == "") { 26 | $arr = array(); 27 | } else { 28 | $arr = unserialize($content); 29 | } 30 | array_push($arr, $zohoOAuthTokens); 31 | $serialized = serialize($arr); 32 | file_put_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt",$serialized ); 33 | } catch (Exception $ex) { 34 | Logger::severe("Exception occured while Saving OAuthTokens to file(file::ZohoOAuthPersistenceByFile)({$ex->getMessage()})\n{$ex}"); 35 | throw $ex; 36 | } 37 | } 38 | 39 | public function getOAuthTokens($userEmailId) 40 | { 41 | try { 42 | $serialized = file_get_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt" ); 43 | if (! isset($serialized) || $serialized == "") { 44 | throw new ZohoOAuthException("No Tokens exist for the given user-identifier,Please generate and try again."); 45 | } 46 | $arr = unserialize($serialized); 47 | $tokens = new ZohoOAuthTokens(); 48 | $isValidUser = false; 49 | foreach ($arr as $eachObj) { 50 | if ($userEmailId === $eachObj->getUserEmailId()) { 51 | $tokens = $eachObj; 52 | $isValidUser = true; 53 | break; 54 | } 55 | } 56 | if (! $isValidUser) { 57 | throw new ZohoOAuthException("No Tokens exist for the given user-identifier,Please generate and try again."); 58 | } 59 | 60 | return $tokens; 61 | } catch (ZohoOAuthException $e) { 62 | throw $e; 63 | } catch (Exception $ex) { 64 | Logger::severe("Exception occured while fetching OAuthTokens from file(file::ZohoOAuthPersistenceByFile)({$ex->getMessage()})\n{$ex}"); 65 | throw $ex; 66 | } 67 | } 68 | 69 | public function deleteOAuthTokens($userEmailId) 70 | { 71 | try { 72 | $serialized = file_get_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt" ); 73 | if (! isset($serialized) || $serialized == "") { 74 | return; 75 | } 76 | $arr = unserialize($serialized); 77 | $found = false; 78 | $i = - 1; 79 | foreach ($arr as $i => $eachObj) { 80 | if ($userEmailId === $eachObj->getUserEmailId()) { 81 | $found = true; 82 | break; 83 | } 84 | } 85 | if ($found) { 86 | unset($arr[$i]); 87 | $arr = array_values(array_filter($arr)); 88 | } 89 | $serialized = serialize($arr); 90 | file_put_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt",$serialized ); 91 | } catch (Exception $ex) { 92 | Logger::severe("Exception occured while Saving OAuthTokens to file(file::ZohoOAuthPersistenceByFile)({$ex->getMessage()})\n{$ex}"); 93 | throw $ex; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/oauth/persistence/ZohoOAuthPersistenceHandler.php: -------------------------------------------------------------------------------- 1 | getUserEmailId()); 19 | $db_link = self::getMysqlConnection(); 20 | $query = "INSERT INTO oauthtokens(useridentifier,accesstoken,refreshtoken,expirytime) VALUES('" . $zohoOAuthTokens->getUserEmailId() . "','" . $zohoOAuthTokens->getAccessToken() . "','" . $zohoOAuthTokens->getRefreshToken() . "'," . $zohoOAuthTokens->getExpiryTime() . ")"; 21 | 22 | $result = mysqli_query($db_link, $query); 23 | if (! $result) { 24 | Logger::severe("OAuth token insertion failed: (" . $db_link->errno . ") " . $db_link->error); 25 | } 26 | } catch (Exception $ex) { 27 | Logger::severe("Exception occured while inserting OAuthTokens into DB(file::ZohoOAuthPersistenceHandler)({$ex->getMessage()})\n{$ex}"); 28 | } finally { 29 | if ($db_link != null) { 30 | $db_link->close(); 31 | } 32 | } 33 | } 34 | 35 | public function getOAuthTokens($userEmailId) 36 | { 37 | $db_link = null; 38 | $oAuthTokens = new ZohoOAuthTokens(); 39 | try { 40 | $db_link = self::getMysqlConnection(); 41 | $query = "SELECT * FROM oauthtokens where useridentifier='" . $userEmailId . "'"; 42 | $resultSet = mysqli_query($db_link, $query); 43 | if (! $resultSet) { 44 | Logger::severe("Getting result set failed: (" . $db_link->errno . ") " . $db_link->error); 45 | throw new ZohoOAuthException("No Tokens exist for the given user-identifier,Please generate and try again."); 46 | } else { 47 | while ($row = mysqli_fetch_row($resultSet)) { 48 | $oAuthTokens->setExpiryTime($row[3]); 49 | $oAuthTokens->setRefreshToken($row[2]); 50 | $oAuthTokens->setAccessToken($row[1]); 51 | $oAuthTokens->setUserEmailId($row[0]); 52 | break; 53 | } 54 | } 55 | } catch (Exception $ex) { 56 | Logger::severe("Exception occured while getting OAuthTokens from DB(file::ZohoOAuthPersistenceHandler)({$ex->getMessage()})\n{$ex}"); 57 | } finally { 58 | if ($db_link != null) { 59 | $db_link->close(); 60 | } 61 | } 62 | return $oAuthTokens; 63 | } 64 | 65 | public function deleteOAuthTokens($userEmailId) 66 | { 67 | $db_link = null; 68 | try { 69 | $db_link = self::getMysqlConnection(); 70 | $query = "DELETE FROM oauthtokens where useridentifier='" . $userEmailId . "'"; 71 | $resultSet = mysqli_query($db_link, $query); 72 | if (! $resultSet) { 73 | Logger::severe("Deleting oauthtokens failed: (" . $db_link->errno . ") " . $db_link->error); 74 | } 75 | } catch (Exception $ex) { 76 | Logger::severe("Exception occured while Deleting OAuthTokens from DB(file::ZohoOAuthPersistenceHandler)({$ex->getMessage()})\n{$ex}"); 77 | } finally { 78 | if ($db_link != null) { 79 | $db_link->close(); 80 | } 81 | } 82 | } 83 | 84 | public function getMysqlConnection() 85 | { 86 | $mysqli_con = new \mysqli(ZohoOAuth::getConfigValue(ZohoOAuthConstants::HOST_ADDRESS).":". ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PORT), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_USERNAME), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_PASSWORD), ZohoOAuth::getConfigValue(ZohoOAuthConstants::DATABASE_NAME)); 87 | if ($mysqli_con->connect_errno) { 88 | Logger::severe("Failed to connect to MySQL: (" . $mysqli_con->connect_errno . ") " . $mysqli_con->connect_error); 89 | echo "Failed to connect to MySQL: (" . $mysqli_con->connect_errno . ") " . $mysqli_con->connect_error; 90 | } 91 | return $mysqli_con; 92 | } 93 | } -------------------------------------------------------------------------------- /src/oauth/persistence/ZohoOAuthPersistenceInterface.php: -------------------------------------------------------------------------------- 1 | requestParams)); 21 | curl_setopt($curl_pointer, CURLOPT_RETURNTRANSFER, true); 22 | curl_setopt($curl_pointer, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); 23 | curl_setopt($curl_pointer, CURLOPT_HTTPHEADER, self::getRequestHeadersAsArray()); 24 | curl_setopt($curl_pointer, CURLOPT_POST, $this->requestParamCount); 25 | curl_setopt($curl_pointer, CURLOPT_CUSTOMREQUEST, ZohoOAuthConstants::REQUEST_METHOD_POST); 26 | $result = curl_exec($curl_pointer); 27 | curl_close($curl_pointer); 28 | 29 | return $result; 30 | } 31 | 32 | public function get() 33 | { 34 | $curl_pointer = curl_init(); 35 | $url = self::getUrl() . "?" . http_build_query($this->requestParams); 36 | curl_setopt($curl_pointer, CURLOPT_URL, $url); 37 | curl_setopt($curl_pointer, CURLOPT_HEADER, 1); 38 | curl_setopt($curl_pointer, CURLOPT_RETURNTRANSFER, true); 39 | curl_setopt($curl_pointer, CURLOPT_HTTPHEADER, self::getRequestHeadersAsArray()); 40 | curl_setopt($curl_pointer, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); 41 | curl_setopt($curl_pointer, CURLOPT_CUSTOMREQUEST, ZohoOAuthConstants::REQUEST_METHOD_GET); 42 | $result = curl_exec($curl_pointer); 43 | curl_close($curl_pointer); 44 | 45 | return $result; 46 | } 47 | 48 | public function getUrl() 49 | { 50 | return $this->url; 51 | } 52 | 53 | public function setUrl($url) 54 | { 55 | $this->url = $url; 56 | } 57 | 58 | public function addParam($key, $value) 59 | { 60 | if (! isset($this->requestParams[$key])) { 61 | $this->requestParams[$key] = array( 62 | $value 63 | ); 64 | } else { 65 | $valArray = $this->requestParams[$key]; 66 | array_push($valArray, $value); 67 | $this->requestParams[$key] = $valArray; 68 | } 69 | } 70 | 71 | public function addHeadder($key, $value) 72 | { 73 | $this->requestHeaders[$key] = $value; 74 | } 75 | 76 | public function getRequestHeadersMap() 77 | { 78 | return $this->requestHeaders; 79 | } 80 | 81 | public function getUrlParamsAsString($urlParams) 82 | { 83 | $params_as_string = ""; 84 | foreach ($urlParams as $key => $valueArray) { 85 | foreach ($valueArray as $value) { 86 | $params_as_string = $params_as_string . $key . "=" . $value . "&"; 87 | $this->requestParamCount ++; 88 | } 89 | } 90 | $params_as_string = rtrim($params_as_string, "&"); 91 | $params_as_string = str_replace(PHP_EOL, '', $params_as_string); 92 | return $params_as_string; 93 | } 94 | 95 | public function getRequestHeadersAsArray() 96 | { 97 | $headersArray = array(); 98 | $headersMap = self::getRequestHeadersMap(); 99 | foreach ($headersMap as $key => $value) { 100 | $headersArray[] = $key . ":" . $value; 101 | } 102 | 103 | return $headersArray; 104 | } 105 | } -------------------------------------------------------------------------------- /src/oauth/utility/ZohoOAuthParams.php: -------------------------------------------------------------------------------- 1 | clientId; 20 | } 21 | 22 | public function setClientId($clientId) 23 | { 24 | return $this->clientId = $clientId; 25 | } 26 | 27 | public function getClientSecret() 28 | { 29 | return $this->clientSecret; 30 | } 31 | 32 | public function setClientSecret($clientSecret) 33 | { 34 | return $this->clientSecret = $clientSecret; 35 | } 36 | 37 | public function getRedirectUrl() 38 | { 39 | return $this->redirectUrl; 40 | } 41 | 42 | public function setRedirectUrl($redirectUrl) 43 | { 44 | return $this->redirectUrl = $redirectUrl; 45 | } 46 | 47 | public function getAccessType() 48 | { 49 | return $this->accessType; 50 | } 51 | 52 | public function setAccessType($accessType) 53 | { 54 | return $this->accessType = $accessType; 55 | } 56 | 57 | public function getScopes() 58 | { 59 | return $this->scopes; 60 | } 61 | 62 | public function setScopes($scopes) 63 | { 64 | return $this->scopes = $scopes; 65 | } 66 | } -------------------------------------------------------------------------------- /src/oauth/utility/ZohoOAuthTokens.php: -------------------------------------------------------------------------------- 1 | refreshToken; 20 | } 21 | 22 | public function setRefreshToken($refreshToken) 23 | { 24 | $this->refreshToken = $refreshToken; 25 | } 26 | 27 | public function getAccessToken() 28 | { 29 | if ($this->isValidAccessToken()) { 30 | return $this->accessToken; 31 | } 32 | throw new ZohoOAuthException("Access token got expired!"); 33 | } 34 | 35 | public function setAccessToken($accessToken) 36 | { 37 | $this->accessToken = $accessToken; 38 | } 39 | 40 | public function getExpiryTime() 41 | { 42 | return $this->expiryTime; 43 | } 44 | 45 | public function setExpiryTime($expiryTime) 46 | { 47 | return $this->expiryTime = $expiryTime; 48 | } 49 | 50 | public function isValidAccessToken() 51 | { 52 | return ($this->getExpiryTime() - $this->getCurrentTimeInMillis()) > 1000; 53 | } 54 | 55 | public function getCurrentTimeInMillis() 56 | { 57 | return round(microtime(true) * 1000); 58 | } 59 | 60 | /** 61 | * userEmailId 62 | * 63 | * @return String 64 | */ 65 | public function getUserEmailId() 66 | { 67 | return $this->userEmailId; 68 | } 69 | 70 | /** 71 | * userEmailId 72 | * 73 | * @param String $userEmailId 74 | */ 75 | public function setUserEmailId($userEmailId) 76 | { 77 | $this->userEmailId = $userEmailId; 78 | } 79 | } --------------------------------------------------------------------------------