Skip to content

Commit b0bf9d5

Browse files
authored
Merge pull request #12 from zoho/beta
Beta
2 parents 368bbfa + e3f84c4 commit b0bf9d5

File tree

3,443 files changed

+218798
-4877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,443 files changed

+218798
-4877
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ License
2525

2626

2727
## Latest Version
28+
29+
- [5.0.0](/versions/5.0.0/README.md)
30+
- Improved DB store query handling.
31+
- Fixed an issue with the Blueprint update API response.
32+
- Blueprint Field class `validationRule` field datatype changed (String to Object).
33+
- BulkWrite `BodyWrapper` class `fileType` field datatype changed (Choice to String).
34+
- BulkWrite `JobDetail` class `fileType` field datatype changed (Choice to String).
35+
- BulkRead `Query` class `fileType` field datatype changed (Choice to String).
36+
- Modules `GetModulesParam` class `STATUS` field datatype changed (Choice to String).
37+
- Added new `trigger` field in Notes `BodyWrapper` class.
38+
- Notifications class `deleteEvents` field datatype changed (Choice to String).
39+
- Modules `DeleteNotificationParam` class `CHANNEL_IDS` field datatype changed (Long to String).
40+
- Profiles and `MinifiedProfile` class `delete` field datatype changed (Boolean to `Delete` class).
41+
- Added new `applyFeatureExecution`, `applyValidationRule`, `applyFunctionValidationRule`, and `skipFeatureExecution` fields in Record `BodyWrapper` class.
42+
- Tags class `colorCode` field datatype changed (Choice to String).
43+
- Users `CountWrapper` class `count` field datatype changed (Long to Integer).
44+
- Users `GetUsersParam` class `TYPE` field datatype changed (Choice to String).
45+
- Webforms `Abtesting` class `id` field datatype changed (Long to String).
46+
- Webforms `AcknowledgeVisitor` class `templateId` field datatype changed (Long to String).
47+
- Webforms `AssignmentRule` class `id` field datatype changed (Long to String).
48+
- Webforms `Layout` class `id` field datatype changed (Long to String).
49+
- Webforms `Module` class `id` field datatype changed (Long to String).
50+
- Webforms `Owner` class `id` field datatype changed (Long to String).
51+
- Webforms `Tags` class `id` field datatype changed (Long to String).
52+
- Webforms `Users` class `id` field datatype changed (Long to String).
53+
- Webforms `Users` `acknowledgeVisitor` field datatype changed (AcknowledgeVisitors to AcknowledgeVisitor).
54+
- Removed `updateWebForms` method from the `WebformsOperations` class.
55+
2856
- [4.0.0](/versions/4.0.0/README.md)
2957
- Handled null values in _delete fields in the API.
3058

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
namespace samples\attachments;
3+
4+
use com\zoho\api\authenticator\OAuthBuilder;
5+
use com\zoho\crm\api\dc\USDataCenter;
6+
use com\zoho\crm\api\InitializeBuilder;
7+
use com\zoho\crm\api\attachments\AttachmentsOperations;
8+
use com\zoho\crm\api\attachments\ActionWrapper;
9+
use com\zoho\crm\api\attachments\SuccessResponse;
10+
use com\zoho\crm\api\attachments\APIException;
11+
12+
require_once "vendor/autoload.php";
13+
14+
class DeleteAttachment
15+
{
16+
public static function initialize()
17+
{
18+
$environment = USDataCenter::PRODUCTION();
19+
$token = (new OAuthBuilder())
20+
->clientId("client_id")
21+
->clientSecret("client_secret")
22+
->refreshToken("refresh_token")
23+
->build();
24+
(new InitializeBuilder())
25+
->environment($environment)
26+
->token($token)
27+
->initialize();
28+
}
29+
30+
public static function deleteAttachment(string $moduleAPIName, string $recordId, string $attachmentId)
31+
{
32+
$attachmentsOperations = new AttachmentsOperations();
33+
34+
$response = $attachmentsOperations->deleteAttachment($attachmentId, $recordId, $moduleAPIName);
35+
36+
if ($response != null) {
37+
echo("Status Code: " . $response->getStatusCode() . "\n");
38+
39+
$actionHandler = $response->getObject();
40+
41+
if ($actionHandler instanceof ActionWrapper) {
42+
$actionWrapper = $actionHandler;
43+
$actionResponses = $actionWrapper->getData();
44+
45+
foreach ($actionResponses as $actionResponse) {
46+
if ($actionResponse instanceof SuccessResponse) {
47+
$successResponse = $actionResponse;
48+
echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
49+
echo("Code: " . $successResponse->getCode()->getValue() . "\n");
50+
echo("Message: " . $successResponse->getMessage() . "\n");
51+
52+
if ($successResponse->getDetails() != null) {
53+
echo("Details: \n");
54+
foreach ($successResponse->getDetails() as $keyName => $keyValue) {
55+
echo($keyName . ": " . $keyValue . "\n");
56+
}
57+
}
58+
} else if ($actionResponse instanceof APIException) {
59+
$exception = $actionResponse;
60+
echo("Status: " . $exception->getStatus()->getValue() . "\n");
61+
echo("Code: " . $exception->getCode()->getValue() . "\n");
62+
echo("Message: " . $exception->getMessage() . "\n");
63+
64+
if ($exception->getDetails() != null) {
65+
echo("Details: \n");
66+
foreach ($exception->getDetails() as $keyName => $keyValue) {
67+
echo($keyName . ": " . $keyValue . "\n");
68+
}
69+
}
70+
}
71+
}
72+
} else if ($actionHandler instanceof APIException) {
73+
$exception = $actionHandler;
74+
echo("Status: " . $exception->getStatus()->getValue() . "\n");
75+
echo("Code: " . $exception->getCode()->getValue() . "\n");
76+
echo("Message: " . $exception->getMessage() . "\n");
77+
}
78+
}
79+
}
80+
}
81+
82+
DeleteAttachment::initialize();
83+
$moduleAPIName = "Leads";
84+
$recordId = "1055806000028386022";
85+
$attachmentId = "1055806000028437001";
86+
DeleteAttachment::deleteAttachment($moduleAPIName, $recordId, $attachmentId);
87+
?>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
namespace samples\attachments;
3+
4+
use com\zoho\api\authenticator\OAuthBuilder;
5+
use com\zoho\crm\api\dc\USDataCenter;
6+
use com\zoho\crm\api\InitializeBuilder;
7+
use com\zoho\crm\api\ParameterMap;
8+
use com\zoho\crm\api\attachments\AttachmentsOperations;
9+
use com\zoho\crm\api\attachments\DeleteAttachmentsParam;
10+
use com\zoho\crm\api\attachments\ActionWrapper;
11+
use com\zoho\crm\api\attachments\SuccessResponse;
12+
use com\zoho\crm\api\attachments\APIException;
13+
14+
require_once "vendor/autoload.php";
15+
16+
class DeleteAttachments
17+
{
18+
public static function initialize()
19+
{
20+
$environment = USDataCenter::PRODUCTION();
21+
$token = (new OAuthBuilder())
22+
->clientId("client_id")
23+
->clientSecret("client_secret")
24+
->refreshToken("refresh_token")
25+
->build();
26+
(new InitializeBuilder())
27+
->environment($environment)
28+
->token($token)
29+
->initialize();
30+
}
31+
32+
public static function deleteAttachments(string $moduleAPIName, string $recordId, array $attachmentIds)
33+
{
34+
$attachmentsOperations = new AttachmentsOperations();
35+
$paramInstance = new ParameterMap();
36+
37+
foreach ($attachmentIds as $attachmentId) {
38+
$paramInstance->add(DeleteAttachmentsParam::ids(), $attachmentId);
39+
}
40+
41+
$response = $attachmentsOperations->deleteAttachments($recordId, $moduleAPIName, $paramInstance);
42+
43+
if ($response != null) {
44+
echo("Status Code: " . $response->getStatusCode() . "\n");
45+
46+
$actionHandler = $response->getObject();
47+
48+
if ($actionHandler instanceof ActionWrapper) {
49+
$actionWrapper = $actionHandler;
50+
$actionResponses = $actionWrapper->getData();
51+
52+
foreach ($actionResponses as $actionResponse) {
53+
if ($actionResponse instanceof SuccessResponse) {
54+
$successResponse = $actionResponse;
55+
echo("Status: " . $successResponse->getStatus()->getValue() . "\n");
56+
echo("Code: " . $successResponse->getCode()->getValue() . "\n");
57+
echo("Message: " . $successResponse->getMessage() . "\n");
58+
59+
if ($successResponse->getDetails() != null) {
60+
echo("Details: \n");
61+
foreach ($successResponse->getDetails() as $keyName => $keyValue) {
62+
echo($keyName . ": " . $keyValue . "\n");
63+
}
64+
}
65+
} else if ($actionResponse instanceof APIException) {
66+
$exception = $actionResponse;
67+
echo("Status: " . $exception->getStatus()->getValue() . "\n");
68+
echo("Code: " . $exception->getCode()->getValue() . "\n");
69+
echo("Message: " . $exception->getMessage() . "\n");
70+
71+
if ($exception->getDetails() != null) {
72+
echo("Details: \n");
73+
foreach ($exception->getDetails() as $keyName => $keyValue) {
74+
echo($keyName . ": " . $keyValue . "\n");
75+
}
76+
}
77+
}
78+
}
79+
} else if ($actionHandler instanceof APIException) {
80+
$exception = $actionHandler;
81+
echo("Status: " . $exception->getStatus()->getValue() . "\n");
82+
echo("Code: " . $exception->getCode()->getValue() . "\n");
83+
echo("Message: " . $exception->getMessage() . "\n");
84+
}
85+
}
86+
}
87+
}
88+
89+
DeleteAttachments::initialize();
90+
$moduleAPIName = "Leads";
91+
$recordId = "1055806000028386022";
92+
$attachmentIds = array("1055806000028386058", "1055806000028386052");
93+
DeleteAttachments::deleteAttachments($moduleAPIName, $recordId, $attachmentIds);
94+
?>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
namespace samples\attachments;
3+
4+
use com\zoho\api\authenticator\OAuthBuilder;
5+
use com\zoho\crm\api\dc\INDataCenter;
6+
use com\zoho\crm\api\InitializeBuilder;
7+
use com\zoho\crm\api\attachments\AttachmentsOperations;
8+
use com\zoho\crm\api\attachments\FileBodyWrapper;
9+
use com\zoho\crm\api\attachments\APIException;
10+
11+
require_once "vendor/autoload.php";
12+
13+
class DownloadAttachment
14+
{
15+
public static function initialize()
16+
{
17+
$environment = INDataCenter::PRODUCTION();
18+
$token = (new OAuthBuilder())
19+
->clientId("client_id")
20+
->clientSecret("client_secret")
21+
->refreshToken("refresh_token")
22+
->build();
23+
(new InitializeBuilder())
24+
->environment($environment)
25+
->token($token)
26+
->initialize();
27+
}
28+
29+
public static function downloadAttachment(string $moduleAPIName, string $recordId, string $attachmentId, string $destinationFolder)
30+
{
31+
$attachmentsOperations = new AttachmentsOperations();
32+
$response = $attachmentsOperations->getAttachment($attachmentId, $recordId, $moduleAPIName);
33+
if ($response != null) {
34+
echo("Status Code: " . $response->getStatusCode() . "\n");
35+
36+
if ($response->getStatusCode() == 204) {
37+
echo("No Content\n");
38+
return;
39+
}
40+
41+
$responseHandler = $response->getObject();
42+
43+
if ($responseHandler instanceof FileBodyWrapper) {
44+
$fileBodyWrapper = $responseHandler;
45+
$streamWrapper = $fileBodyWrapper->getFile();
46+
$fp = fopen($destinationFolder . "/" . $streamWrapper->getName(), "w");
47+
$stream = $streamWrapper->getStream();
48+
fputs($fp, $stream);
49+
fclose($fp);
50+
51+
echo("File downloaded successfully to: " . $destinationFolder . "/" . $streamWrapper->getName() . "\n");
52+
} else if ($responseHandler instanceof APIException) {
53+
$exception = $responseHandler;
54+
echo("Status: " . $exception->getStatus()->getValue() . "\n");
55+
echo("Code: " . $exception->getCode()->getValue() . "\n");
56+
echo("Message: " . $exception->getMessage() . "\n");
57+
58+
if ($exception->getDetails() != null) {
59+
echo("Details: \n");
60+
foreach ($exception->getDetails() as $keyName => $keyValue) {
61+
echo($keyName . ": " . $keyValue . "\n");
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}
68+
69+
DownloadAttachment::initialize();
70+
$moduleAPIName = "Leads";
71+
$recordId = "1055806000028386022";
72+
$attachmentId = "1055806000028443001";
73+
$destinationFolder = "/file";
74+
DownloadAttachment::downloadAttachment($moduleAPIName, $recordId, $attachmentId, $destinationFolder);
75+
?>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
namespace samples\attachments;
3+
4+
use com\zoho\api\authenticator\OAuthBuilder;
5+
use com\zoho\crm\api\dc\INDataCenter;
6+
use com\zoho\crm\api\InitializeBuilder;
7+
use com\zoho\crm\api\ParameterMap;
8+
use com\zoho\crm\api\attachments\AttachmentsOperations;
9+
use com\zoho\crm\api\attachments\GetAttachmentsParam;
10+
use com\zoho\crm\api\attachments\ResponseWrapper;
11+
use com\zoho\crm\api\attachments\APIException;
12+
13+
require_once "vendor/autoload.php";
14+
15+
class GetAttachments
16+
{
17+
public static function initialize()
18+
{
19+
$environment = INDataCenter::PRODUCTION();
20+
$token = (new OAuthBuilder())
21+
->clientId("client_id")
22+
->clientSecret("client_secret")
23+
->refreshToken("refresh_token")
24+
->build();
25+
(new InitializeBuilder())
26+
->environment($environment)
27+
->token($token)
28+
->initialize();
29+
}
30+
31+
public static function getAttachments(string $moduleAPIName, string $recordId)
32+
{
33+
$attachmentsOperations = new AttachmentsOperations();
34+
$paramInstance = new ParameterMap();
35+
$paramInstance->add(GetAttachmentsParam::page(), 1);
36+
$paramInstance->add(GetAttachmentsParam::perPage(), 10);
37+
$paramInstance->add(GetAttachmentsParam::fields(), "id,Modified_Time");
38+
39+
$response = $attachmentsOperations->getAttachments($recordId, $moduleAPIName, $paramInstance);
40+
41+
if ($response != null) {
42+
echo("Status Code: " . $response->getStatusCode() . "\n");
43+
44+
if (in_array($response->getStatusCode(), array(204, 304))) {
45+
echo($response->getStatusCode() == 204 ? "No Content\n" : "Not Modified\n");
46+
return;
47+
}
48+
49+
$responseHandler = $response->getObject();
50+
51+
if ($responseHandler instanceof ResponseWrapper) {
52+
$responseWrapper = $responseHandler;
53+
$attachments = $responseWrapper->getData();
54+
55+
foreach ($attachments as $attachment) {
56+
echo("Attachment ID: " . $attachment->getId() . "\n");
57+
echo("Attachment File Name: " . $attachment->getFileName() . "\n");
58+
echo("Attachment File Size: " . $attachment->getSize() . "\n");
59+
60+
$owner = $attachment->getOwner();
61+
if ($owner != null) {
62+
echo("Attachment Owner Name: " . $owner->getName() . "\n");
63+
echo("Attachment Owner ID: " . $owner->getId() . "\n");
64+
}
65+
66+
echo("Attachment Modified Time: ");
67+
print_r($attachment->getModifiedTime());
68+
echo("\n");
69+
70+
echo("Attachment Created Time: ");
71+
print_r($attachment->getCreatedTime());
72+
echo("\n");
73+
}
74+
} else if ($responseHandler instanceof APIException) {
75+
$exception = $responseHandler;
76+
echo("Status: " . $exception->getStatus()->getValue() . "\n");
77+
echo("Code: " . $exception->getCode()->getValue() . "\n");
78+
echo("Message: " . $exception->getMessage() . "\n");
79+
}
80+
}
81+
}
82+
}
83+
84+
GetAttachments::initialize();
85+
$moduleAPIName = "Leads";
86+
$recordId = "105586022";
87+
GetAttachments::getAttachments($moduleAPIName, $recordId);
88+
?>

0 commit comments

Comments
 (0)