Skip to content

Commit

Permalink
Merge pull request #5 from zoho/beta
Browse files Browse the repository at this point in the history
3.0.0
  • Loading branch information
raja-7453 authored Dec 31, 2024
2 parents 11e1ce9 + 275ed07 commit cb8ed6a
Show file tree
Hide file tree
Showing 1,812 changed files with 174,463 additions and 39 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ License

## Latest Version

- [3.0.0](/versions/3.0.0/README.md)

- Handled FileStore save and update token method issue.
- Update CADataCenter Accounts URL.

- [2.0.0](/versions/2.0.0/README.md)

- Handled Error Structure in MassDeleteTags API.
Expand All @@ -50,10 +55,10 @@ For older versions, please [refer](https://github.com/zoho/zohocrm-php-sdk-7.0/r

## Including the SDK in your project
You can include the SDK to your project using Composer.
For installing the latest [version](https://github.com/zoho/zohocrm-php-sdk-7.0/releases/tag/2.0.0) of PHP SDK, navigate to the workspace of your client app and run the following command.
For installing the latest [version](https://github.com/zoho/zohocrm-php-sdk-7.0/releases/tag/3.0.0) of PHP SDK, navigate to the workspace of your client app and run the following command.

```sh
composer require zohocrm/php-sdk-7.0:2.0.0
composer require zohocrm/php-sdk-7.0:3.0.0
```
With this, the PHP SDK will be installed and a package named vendor will be created in the workspace of your client app.

Expand All @@ -72,4 +77,4 @@ For example, if you generate the tokens for your Sandbox environment in the CN d
---

For more details, kindly refer here. [here](/versions/2.0.0/README.md).
For more details, kindly refer here. [here](/versions/3.0.0/README.md).
10 changes: 5 additions & 5 deletions src/com/zoho/api/authenticator/OAuthToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getGrantToken()

/**
* This is a getter method to get refresh token.
* @return NULL|string|mixed A string representing the refresh token.
* @return null|string|mixed A string representing the refresh token.
*/
public function getRefreshToken()
{
Expand Down Expand Up @@ -177,7 +177,7 @@ public function setUserSignature(UserSignature $userSignature)

/**
* This is a getter method to get ID.
* @return NULL|string|mixed A string representing the tokenId.
* @return null|string|mixed A string representing the tokenId.
*/
public function getId()
{
Expand Down Expand Up @@ -268,9 +268,9 @@ public function getToken()
}
$url = $initializer->getEnvironment()->getAccountsUrl();
$save = false;
if ($oauthToken->getAccessToken() == null || strlen($oauthToken->getAccessToken()) == 0)
if ($oauthToken->getAccessToken() == null && mb_strlen($oauthToken->getAccessToken() ?? '', 'utf-8') == 0)
{
if ($oauthToken->getRefreshToken() != null && strlen($oauthToken->getRefreshToken()) > 0)
if ($oauthToken->getRefreshToken() != null && mb_strlen($oauthToken->getRefreshToken() ?? '', 'utf-8') > 0)
{
SDKLogger::info(Constants::ACCESS_TOKEN_USING_REFRESH_TOKEN_MESSAGE);
$oauthToken->refreshAccessToken($oauthToken, $url);
Expand All @@ -282,7 +282,7 @@ public function getToken()
}
$save = true;
}
elseif ($oauthToken->getExpiresIn() != null && strlen($oauthToken->getExpiresIn())>0 && $this->isAccessTokenExpired($oauthToken->getExpiresIn()))
elseif ($oauthToken->getExpiresIn() != null && mb_strlen($oauthToken->getExpiresIn() ?? '', 'utf-8')>0 && $this->isAccessTokenExpired($oauthToken->getExpiresIn()))
{
SDKLogger::info(Constants::REFRESH_TOKEN_MESSAGE);
$oauthToken->refreshAccessToken($oauthToken, $url);
Expand Down
47 changes: 23 additions & 24 deletions src/com/zoho/api/authenticator/store/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,11 @@ public function saveToken(Token $token)
try
{
$oauthToken = $token;
$csvReader = file($this->filePath);
$allContents = file($this->filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$isRowPresent = false;
for ($index = 1; $index < sizeof($csvReader); $index++)
for ($index = 1; $index < sizeof($allContents); $index++)
{
$allContents = $csvReader[$index];
$nextRecord = str_getcsv($allContents);
$nextRecord = str_getcsv($allContents[$index]);
if (sizeof($nextRecord) > 1)
{
if ($oauthToken->getId() != null)
Expand All @@ -128,13 +127,13 @@ public function saveToken(Token $token)
if ($isRowPresent)
{
$this->setMergeData($oauthToken, $nextRecord);
array_splice($csvReader, $index, 1, implode(",", $this->setToken($oauthToken)) . "\n");
array_splice($allContents, $index, 1, implode(",", $this->setToken($oauthToken)));
break;
}
}
}
else
{
unset($csvReader[$index]);
unset($allContents[$index]);
}
}
if (!$isRowPresent)
Expand All @@ -148,13 +147,12 @@ public function saveToken(Token $token)
}
if ($oauthToken->getId() == null)
{
$newID = $this->generateId($csvReader);
$newID = $this->generateId($allContents);
$oauthToken->setId($newID);
}
array_push($csvReader, "\n");
array_push($csvReader, implode(",", $this->setToken($oauthToken)));
array_push($allContents, implode(",", $this->setToken($oauthToken)));
}
file_put_contents($this->filePath, $csvReader);
file_put_contents($this->filePath, implode(PHP_EOL, $allContents));
}
catch (SDKException $ex)
{
Expand Down Expand Up @@ -207,19 +205,20 @@ public function deleteToken($id)

public function getTokens()
{
$csvReader = null;
$tokens = array();
try
{
$csvReader = file($this->filePath, FILE_IGNORE_NEW_LINES);
for ($index = 1; $index < sizeof($csvReader); $index++)
$allContents = file($this->filePath, FILE_IGNORE_NEW_LINES);
for ($index = 1; $index < sizeof($allContents); $index++)
{
$allContents = $csvReader[$index];
$nextRecord = str_getcsv($allContents);
$class = new \ReflectionClass(OAuthToken::class);
$token = $class->newInstanceWithoutConstructor();
$this->setMergeData($token, $nextRecord);
array_push($tokens, $token);
$nextRecord = str_getcsv($allContents[$index]);
if(sizeof($nextRecord) > 1)
{
$class = new \ReflectionClass(OAuthToken::class);
$token = $class->newInstanceWithoutConstructor();
$this->setMergeData($token, $nextRecord);
array_push($tokens, $token);
}
}
}
catch (\Exception $ex)
Expand Down Expand Up @@ -392,12 +391,12 @@ private function generateId($allContents)
$maxValue = 0;
if (sizeof($allContents) > 1)
{
for ($index =1; $index < sizeof($allContents); $index++)
for ($index = 1; $index < sizeof($allContents); $index++)
{
$nextRecord = $allContents[$index];
if(strlen($nextRecord) > 1 && $nextRecord[0] != null && strlen($nextRecord[0]))
$nextRecord = str_getcsv($allContents[$index]);
if(sizeof($nextRecord) > 1 && $nextRecord[0] != null && mb_strlen($nextRecord[0] ?? '', 'utf-8'))
{
if ($maxValue < intval($nextRecord[0]))
if ($maxValue < intval( $nextRecord[0]))
{
$maxValue = intval($nextRecord[0]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/com/zoho/crm/api/dc/CADataCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public static function DEVELOPER()

public function getIAMUrl()
{
return "https://accounts.zoho.ca/oauth/v2/token";
return "https://accounts.zohocloud.ca/oauth/v2/token";
}

public function getFileUploadUrl()
{
return "https://content.zohoapis.ca";
return "https://upload.zohocloud.ca";
}
}
2 changes: 1 addition & 1 deletion src/com/zoho/crm/api/exception/SDKException.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct($code, $message, $details=null, \Exception $cause=nu
{
$this->_message = $cause->getMessage();
}
parent::__construct($this->_message);
parent::__construct(is_null($message) ? "" : $message);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/com/zoho/crm/api/util/APIResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getObject()

/**
* This is a getter method to get an API response instance that is the expected type or not.
* @return boolean representing the instance is expected type or not.
* @return bool representing the instance is expected type or not.
*/
public function isExpected()
{
Expand Down
4 changes: 2 additions & 2 deletions src/com/zoho/crm/api/util/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class Constants
const SET_API_URL_EXCEPTION = "Exception in setting API URL";
const AUTHENTICATION_EXCEPTION = "Exception in authenticating current request : ";
const FORM_REQUEST_EXCEPTION = "Exception in forming request body : ";
const SDK_VERSION = "2.0.0";
const SDK_VERSION = "3.0.0";
const API_CALL_EXCEPTION = "Exception in current API call execution : ";
const HTTP = "http";
const CONTENT_API_URL = "content.zohoapis.com";
Expand Down Expand Up @@ -390,7 +390,7 @@ class Constants
const IN_DATACENTER = ["https://www.zohoapis.in", "https://sandbox.zohoapis.in", "https://developer.zohoapis.in", "https://accounts.zoho.in/oauth/v2/token","in"];
const JP_DATACENTER = ["https://www.zohoapis.jp", "https://sandbox.zohoapis.jp", "https://developer.zohoapis.jp", "https://accounts.zoho.jp/oauth/v2/token","jp"];
const US_DATACENTER = ["https://www.zohoapis.com", "https://sandbox.zohoapis.com", "https://developer.zohoapis.com", "https://accounts.zoho.com/oauth/v2/token","us"];
const CA_DATACENTER = ["https://www.zohoapis.ca", "https://sandbox.zohoapis.ca", "https://developer.zohoapis.ca", "https://accounts.zoho.ca/oauth/v2/token", "ca"];
const CA_DATACENTER = ["https://www.zohoapis.ca", "https://sandbox.zohoapis.ca", "https://developer.zohoapis.ca", "https://accounts.zohocloud.ca/oauth/v2/token", "ca"];
const ENVIRONMENT_ERROR = "The given DataCenter config not valid. Please check the domain URL";
const ENVIRONMENT_ERROR_1 = "ENVIRONMENT_ERROR";
const DATACENTER_ERROR = "DATACENTER_ERROR";
Expand Down
2 changes: 1 addition & 1 deletion src/com/zoho/crm/api/util/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public abstract function getWrappedResponse($response, $pack);
* @param array $uniqueValuesMap A array containing the construct objects.
* @param integer $instanceNumber An integer containing the POJO class instance list number.
* @throws \com\zoho\crm\api\exception\SDKException if a problem occurs.
* @return boolean A boolean representing the key value is expected pattern, unique, length, and values.
* @return bool A boolean representing the key value is expected pattern, unique, length, and values.
*/
public function valueChecker($className, $memberName, $keyDetails, $value, &$uniqueValuesMap, $instanceNumber)
{
Expand Down
Loading

0 comments on commit cb8ed6a

Please sign in to comment.