Skip to content

Commit

Permalink
4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
raja-7453 committed Jul 2, 2024
1 parent 2fd4096 commit 5356c51
Show file tree
Hide file tree
Showing 1,598 changed files with 154,996 additions and 44 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ License


## Latest Version
- [4.0.0](/versions/4.0.0/README.md)
- Supported multiple field update operations in the FieldsOperations class.

- [3.0.0](/versions/3.0.0/README.md)
- Blueprint Transition ***percentPartialSave*** field datatype changed(Integer to float).
Expand Down Expand Up @@ -67,10 +69,10 @@ For older versions, please [refer](https://github.com/zoho/zohocrm-php-sdk-6.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-6.0/releases/tag/3.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-6.0/releases/tag/4.0.0) of PHP SDK, navigate to the workspace of your client app and run the following command.

```sh
composer require zohocrm/php-sdk-6.0:3.0.0
composer require zohocrm/php-sdk-6.0:4.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 @@ -89,4 +91,4 @@ For example, if you generate the tokens for your Sandbox environment in the CN d
---

For more details, kindly refer here. [here](/versions/3.0.0/README.md).
For more details, kindly refer here. [here](/versions/4.0.0/README.md).
85 changes: 85 additions & 0 deletions samples/taxes/GetTax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
namespace taxes;

use com\zoho\api\authenticator\OAuthBuilder;
use com\zoho\crm\api\dc\USDataCenter;
use com\zoho\crm\api\InitializeBuilder;
use com\zoho\crm\api\taxes\APIException;
use com\zoho\crm\api\taxes\ResponseWrapper;
use com\zoho\crm\api\taxes\TaxesOperations;
use com\zoho\crm\api\util\Choice;

require_once "vendor/autoload.php";

class GetTax
{
public static function initialize()
{
$environment = USDataCenter::PRODUCTION();
$token = (new OAuthBuilder())
->clientId("client_id")
->clientSecret("client_secret")
->refreshToken("refresh_token")
->build();
(new InitializeBuilder())
->environment($environment)
->token($token)
->initialize();
}

/**
* <h3> Get Tax </h3>
* This method is used to get the Organization Tax and print the response.
* @param taxId - The ID of the tax to be obtainted
* @throws Exception
*/
public static function getTax(string $taxId)
{
$taxesOperations = new TaxesOperations();
//Call getTax method that takes taxId as parameter
$response = $taxesOperations->getTax($taxId);
if ($response != null) {
echo ("Status code " . $response->getStatusCode() . "\n");
if (in_array($response->getStatusCode(), array(204, 304))) {
echo ($response->getStatusCode() == 204 ? "No Content\n" : "Not Modified\n");
return;
}
$responseHandler = $response->getObject();
if ($responseHandler instanceof ResponseWrapper) {
$responseWrapper = $responseHandler;
$orgTax = $responseWrapper->getOrgTaxes();
$taxes = $orgTax->getTaxes();
if ($taxes != null) {
foreach ($taxes as $tax) {
echo ("Tax DisplayLabel: " . $tax->getDisplayLabel() . "\n");
echo ("Tax Name: " . $tax->getName() . "\n");
echo ("Tax Id: " . $tax->getId() . "\n");
echo ("Tax Value: " . $tax->getValue() . "\n");
}
}
$preference = $orgTax->getPreference();
if ($preference != null) {
echo ("Preference AutoPopulateTax: ");
print_r($preference->getAutoPopulateTax());
echo ("\n");
echo ("Preference ModifyTaxRates: ");
print_r($preference->getModifyTaxRates());
echo ("\n");
}
}
else if ($responseHandler instanceof APIException) {
$exception = $responseHandler;
echo ("Status: " . $exception->getStatus()->getValue() . "\n");
echo ("Code: " . $exception->getCode()->getValue() . "\n");
echo ("Details: ");
foreach ($exception->getDetails() as $key => $value) {
echo ($key . " : " . $value . "\n");
}
echo ("Message : " . ($exception->getMessage() instanceof Choice ? $exception->getMessage()->getValue() : $exception->getMessage()));
}
}
}
}
$taxId = "34773778001";
GetTax::initialize();
GetTax::getTax($taxId);
83 changes: 83 additions & 0 deletions samples/taxes/GetTaxes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
namespace taxes;

use com\zoho\api\authenticator\OAuthBuilder;
use com\zoho\crm\api\dc\USDataCenter;
use com\zoho\crm\api\InitializeBuilder;
use com\zoho\crm\api\taxes\APIException;
use com\zoho\crm\api\taxes\ResponseWrapper;
use com\zoho\crm\api\taxes\TaxesOperations;
use com\zoho\crm\api\util\Choice;

require_once "vendor/autoload.php";

class GetTaxes
{
public static function initialize()
{
$environment = USDataCenter::PRODUCTION();
$token = (new OAuthBuilder())
->clientId("client_id")
->clientSecret("client_secret")
->refreshToken("refresh_token")
->build();
(new InitializeBuilder())
->environment($environment)
->token($token)
->initialize();
}

/**
* <h3> Get Taxes </h3>
* This method is used to get all the Organization Taxes and print the response.
* @throws Exception
*/
public static function getTaxes()
{
$taxesOperations = new TaxesOperations();
//Call getTaxes method
$response = $taxesOperations->getTaxes();
if ($response != null) {
echo ("Status code " . $response->getStatusCode() . "\n");
if (in_array($response->getStatusCode(), array(204, 304))) {
echo ($response->getStatusCode() == 204 ? "No Content\n" : "Not Modified\n");
return;
}
$responseHandler = $response->getObject();
if ($responseHandler instanceof ResponseWrapper) {
$responseWrapper = $responseHandler;
$orgTax = $responseWrapper->getOrgTaxes();
$taxes = $orgTax->getTaxes();
if ($taxes != null) {
foreach ($taxes as $tax) {
echo ("Tax DisplayLabel: " . $tax->getDisplayLabel() . "\n");
echo ("Tax Name: " . $tax->getName() . "\n");
echo ("Tax Id: " . $tax->getId() . "\n");
echo ("Tax Value: " . $tax->getValue() . "\n");
}
}
$preference = $orgTax->getPreference();
if ($preference != null) {
echo ("Preference AutoPopulateTax: ");
print_r($preference->getAutoPopulateTax());
echo ("\n");
echo ("Preference ModifyTaxRates: ");
print_r($preference->getModifyTaxRates());
echo ("\n");
}
}
else if ($responseHandler instanceof APIException) {
$exception = $responseHandler;
echo ("Status: " . $exception->getStatus()->getValue() . "\n");
echo ("Code: " . $exception->getCode()->getValue() . "\n");
echo ("Details: ");
foreach ($exception->getDetails() as $key => $value) {
echo ($key . " : " . $value . "\n");
}
echo ("Message : " . ($exception->getMessage() instanceof Choice ? $exception->getMessage()->getValue() : $exception->getMessage()));
}
}
}
}
GetTaxes::initialize();
GetTaxes::getTaxes();
121 changes: 121 additions & 0 deletions samples/taxes/UpdateTaxes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
namespace com\zoho\crm\sample\taxes;

use com\zoho\api\authenticator\OAuthBuilder;
use com\zoho\crm\api\dc\USDataCenter;
use com\zoho\crm\api\InitializeBuilder;
use com\zoho\crm\api\taxes\ActionWrapper;
use com\zoho\crm\api\taxes\APIException;
use com\zoho\crm\api\taxes\BodyWrapper;
use com\zoho\crm\api\taxes\OrgTax;
use com\zoho\crm\api\taxes\Preference;
use com\zoho\crm\api\taxes\TaxesOperations;
use com\zoho\crm\api\taxes\Tax;
use com\zoho\crm\api\taxes\SuccessResponse;
use com\zoho\crm\api\util\Choice;

require_once "vendor/autoload.php";

class UpdateTaxes
{
public static function initialize()
{
$environment = USDataCenter::PRODUCTION();
$token = (new OAuthBuilder())
->clientId("client_id")
->clientSecret("client_secret")
->refreshToken("refresh_token")
->build();
(new InitializeBuilder())
->environment($environment)
->token($token)
->initialize();
}
/**
* <h3> Update Taxes </h3>
* This method is used to update Organization Taxes and print the response.
* @throws Exception
*/
public static function updateTaxes()
{
$taxesOperations = new TaxesOperations();
$request = new BodyWrapper();
$orgTax = new OrgTax();
//List of Tax instances
$taxList = array();

/** update tax */
$tax1 = new Tax();
$tax1->setId("3477779001");
$tax1->setName("MyTax435");
$tax1->setSequenceNumber(1);
$tax1->setValue(15.0);
array_push($taxList, $tax1);

/** create tax */
$tax2 = new Tax();
$tax2->setName("New Tax");
$tax2->setSequenceNumber(1);
$tax2->setValue(15.0);
array_push($taxList, $tax2);

/** delete tax */
$tax3 = new Tax();
$tax3->setId("34770619001");
$tax3->setDelete(null);
array_push($taxList, $tax3);

$orgTax->setTaxes($taxList);
$preference = new Preference();
$preference->setAutoPopulateTax(false);
$preference->setModifyTaxRates(false);
$orgTax->setPreference($preference);
$request->setOrgTaxes($orgTax);
//Call updateTaxes method that takes BodyWrapper instance as parameter
$response = $taxesOperations->updateTaxes($request);
if ($response != null) {
echo ("Status Code: " . $response->getStatusCode() . "\n");
$actionHandler = $response->getObject();
if ($actionHandler instanceof ActionWrapper) {
$actionWrapper = $actionHandler;
$actionResponse = $actionWrapper->getOrgTaxes();
if ($actionResponse instanceof SuccessResponse) {
$successResponse = $actionResponse;
echo ("Status: " . $successResponse->getStatus()->getValue() . "\n");
echo ("Code: " . $successResponse->getCode()->getValue() . "\n");
if ($successResponse->getDetails() != null) {
echo ("Details: ");
foreach ($successResponse->getDetails() as $key => $value) {
echo ($key . " : ");
print_r($value);
echo ("\n");
}
}
echo ("Message: " . ($successResponse->getMessage() instanceof Choice ? $successResponse->getMessage()->getValue() : $successResponse->getMessage()) . "\n");
}
else if ($actionResponse instanceof APIException) {
$exception = $actionResponse;
echo ("Status: " . $exception->getStatus()->getValue() . "\n");
echo ("Code: " . $exception->getCode()->getValue() . "\n");
echo ("Details: ");
foreach ($exception->getDetails() as $key => $value) {
echo ($key . " : "); print_r($value); echo("\n");
}
echo ("Message : " . ($exception->getMessage() instanceof Choice ? $exception->getMessage()->getValue() : $exception->getMessage()) . "\n");
}
}
else if ($actionHandler instanceof APIException) {
$exception = $actionHandler;
echo ("Status: " . $exception->getStatus()->getValue() . "\n");
echo ("Code: " . $exception->getCode()->getValue() . "\n");
echo ("Details: ");
foreach ($exception->getDetails() as $key => $value) {
echo ($key . " : " . $value . "\n");
}
echo ("Message : " . ($exception->getMessage() instanceof Choice ? $exception->getMessage()->getValue() : $exception->getMessage()));
}
}
}
}
UpdateTaxes::initialize();
UpdateTaxes::updateTaxes();
2 changes: 1 addition & 1 deletion src/com/zoho/crm/api/assignmentrules/APIException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use com\zoho\crm\api\util\Choice;
use com\zoho\crm\api\util\Model;

class APIException implements Model, ResponseHandler
class APIException implements Model, ActionResponse, ResponseHandler
{

private $code;
Expand Down
7 changes: 7 additions & 0 deletions src/com/zoho/crm/api/assignmentrules/ActionResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace com\zoho\crm\api\assignmentrules;

interface ActionResponse
{

}
2 changes: 1 addition & 1 deletion src/com/zoho/crm/api/assignmentrules/SuccessResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use com\zoho\crm\api\util\Choice;
use com\zoho\crm\api\util\Model;

class SuccessResponse implements Model
class SuccessResponse implements Model, ActionResponse
{

private $code;
Expand Down
22 changes: 22 additions & 0 deletions src/com/zoho/crm/api/fields/FieldsOperations.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ public function createField(BodyWrapper $request, ParameterMap $paramInstance=nu

}

/**
* The method to update fields
* @param BodyWrapper $request An instance of BodyWrapper
* @param ParameterMap $paramInstance An instance of ParameterMap
* @return APIResponse An instance of APIResponse
*/
public function updateFields(BodyWrapper $request, ParameterMap $paramInstance=null)
{
$handlerInstance=new CommonAPIHandler();
$apiPath="";
$apiPath=$apiPath.('/crm/v6/settings/fields');
$handlerInstance->setAPIPath($apiPath);
$handlerInstance->setHttpMethod('PATCH');
$handlerInstance->setCategoryMethod(Constants::REQUEST_CATEGORY_UPDATE);
$handlerInstance->setContentType('application/json');
$handlerInstance->setRequest($request);
$handlerInstance->setMandatoryChecker(true);
$handlerInstance->setParam($paramInstance);
return $handlerInstance->apiCall(ActionHandler::class, 'application/json');

}

/**
* The method to get field
* @param string $field A string
Expand Down
Loading

0 comments on commit 5356c51

Please sign in to comment.