Skip to content

Commit fb7bb1a

Browse files
author
Balaji Jayaraman
committed
added code changes for httpinfo
1 parent 3b5a9e7 commit fb7bb1a

File tree

86 files changed

+1677
-278
lines changed

Some content is hidden

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

86 files changed

+1677
-278
lines changed

src/Controllers/Examples/Admin/EG002CreateActiveCLMESignUser.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DocuSign\Controllers\Examples\Admin;
44

5+
use DateTime;
56
use DocuSign\Admin\Client\ApiException;
67
use DocuSign\Controllers\AdminApiBaseController;
78
use DocuSign\Services\Examples\Admin\CreateActiveCLMESignUserService;
@@ -30,9 +31,18 @@ public function __construct()
3031
$eSignProductId = $clmProductId = $clmPermissionProfiles = $eSignPermissionProfiles = "";
3132
$this->orgId = $this->clientService->getOrgAdminId($this->args);
3233
$ppReq = $this->clientService->permProfilesApi();
33-
$permissionProfiles = $ppReq->getProductPermissionProfiles($this->orgId, $this->args["account_id"]);
34+
$permissionProfiles = $ppReq->getProductPermissionProfilesWithHttpInfo($this->orgId, $this->args["account_id"]);
3435

35-
foreach ($permissionProfiles['product_permission_profiles'] as $item) {
36+
$remaining = $permissionProfiles[2]['X-RateLimit-Remaining'] ?? null;
37+
$reset = $permissionProfiles[2]['X-RateLimit-Reset'] ?? null;
38+
39+
if ($remaining !== null && $reset !== null) {
40+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
41+
error_log("API calls remaining: $remaining");
42+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
43+
}
44+
45+
foreach ($permissionProfiles[0]['product_permission_profiles'] as $item) {
3646
if ($item['product_name'] == "CLM") {
3747
$clmPermissionProfiles = $item;
3848
$clmProductId = $item["product_id"];
@@ -45,9 +55,19 @@ public function __construct()
4555

4656
#ds-snippet-start:Admin2Step4
4757
$dsgReq = $this->clientService->adminGroupsApi();
48-
$dsgRes = $dsgReq->getDSGroups($this->orgId, $this->args["account_id"]);
49-
$dsGroups = $dsgRes["ds_groups"];
50-
if ($dsgRes["ds_groups"] == null) {
58+
$dsgRes = $dsgReq->getDSGroupsWithHttpInfo($this->orgId, $this->args["account_id"]);
59+
60+
$remaining = $dsgRes[2]['X-RateLimit-Remaining'] ?? null;
61+
$reset = $dsgRes[2]['X-RateLimit-Reset'] ?? null;
62+
63+
if ($remaining !== null && $reset !== null) {
64+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
65+
error_log("API calls remaining: $remaining");
66+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
67+
}
68+
69+
$dsGroups = $dsgRes[0]["ds_groups"];
70+
if ($dsgRes[0]["ds_groups"] == null) {
5171
throw new ApiException(
5272
$this->codeExampleText["CustomErrorTexts"][0]["ErrorMessage"]
5373
);

src/Controllers/Examples/Admin/EG003aCheckRequestStatus.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DocuSign\Controllers\Examples\Admin;
44

5+
use DateTime;
56
use DocuSign\OrgAdmin\Client\ApiException;
67
use DocuSign\Controllers\AdminApiBaseController;
78

@@ -53,10 +54,19 @@ private function checkRequestStatus()
5354
$exportId = $_SESSION['export_id'];
5455

5556
# Step 4 start
56-
$result = $bulkExportsApi->getUserListExport($this->clientService->getOrgAdminId($this->args), $exportId);
57+
$result = $bulkExportsApi->getUserListExportWithHttpInfo($this->clientService->getOrgAdminId($this->args), $exportId);
58+
59+
$remaining = $result[2]['X-RateLimit-Remaining'] ?? null;
60+
$reset = $result[2]['X-RateLimit-Reset'] ?? null;
61+
62+
if ($remaining !== null && $reset !== null) {
63+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
64+
error_log("API calls remaining: $remaining");
65+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
66+
}
5767
# Step 4 end
5868

59-
return json_decode($result->__toString());
69+
return json_decode($result[0]->__toString());
6070
}
6171

6272
/**

src/Controllers/Examples/Admin/EG004aCheckImportRequestStatus.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DocuSign\Controllers\Examples\Admin;
44

5+
use DateTime;
56
use DocuSign\OrgAdmin\Client\ApiException;
67
use DocuSign\Controllers\AdminApiBaseController;
78

@@ -70,10 +71,20 @@ private function checkRequestStatus(): object
7071

7172
#ds-snippet-start:Admin4Step4
7273
$importId = $_SESSION['import_id'];
73-
return $bulkImport->getBulkUserImportRequest(
74+
$response = $bulkImport->getBulkUserImportRequestWithHttpInfo(
7475
$this->clientService->getOrgAdminId($this->args),
7576
$importId
7677
);
78+
79+
$remaining = $response[2]['X-RateLimit-Remaining'] ?? null;
80+
$reset = $response[2]['X-RateLimit-Reset'] ?? null;
81+
82+
if ($remaining !== null && $reset !== null) {
83+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
84+
error_log("API calls remaining: $remaining");
85+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
86+
}
87+
return $response[0];
7788
#ds-snippet-end:Admin4Step4
7889
}
7990

src/Controllers/Examples/Admin/EG008UpdateUserProductPermissionProfile.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DocuSign\Controllers\Examples\Admin;
44

5+
use DateTime;
56
use DocuSign\Admin\Client\ApiException;
67
use DocuSign\Admin\Model\ProductPermissionProfilesResponse;
78
use DocuSign\Controllers\AdminApiBaseController;
@@ -50,13 +51,22 @@ public function __construct()
5051

5152
$permissionProfilesAPI = $this->clientService->permProfilesApi();
5253

53-
$productPermissionProfilesResponse = $permissionProfilesAPI->getProductPermissionProfiles(
54+
$productPermissionProfilesResponse = $permissionProfilesAPI->getProductPermissionProfilesWithHttpInfo(
5455
$this->orgId,
5556
$this->args["account_id"]
5657
);
5758

59+
$remaining = $productPermissionProfilesResponse[2]['X-RateLimit-Remaining'] ?? null;
60+
$reset = $productPermissionProfilesResponse[2]['X-RateLimit-Reset'] ?? null;
61+
62+
if ($remaining !== null && $reset !== null) {
63+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
64+
error_log("API calls remaining: $remaining");
65+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
66+
}
67+
5868
parent::controller(
59-
$this->preparePageProperties($productPermissionProfilesResponse)
69+
$this->preparePageProperties($productPermissionProfilesResponse[0])
6070
);
6171
}
6272
} catch (ApiException $e) {

src/Controllers/Examples/Admin/EG009DeleteUserProductPermissionProfile.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DocuSign\Controllers\Examples\Admin;
44

5+
use DateTime;
56
use DocuSign\Admin\Client\ApiException;
67
use DocuSign\Admin\Model\UserProductPermissionProfilesResponse;
78
use DocuSign\Controllers\AdminApiBaseController;
@@ -59,15 +60,24 @@ public function __construct()
5960
$getUserProductPermissionProfilesByEmailOptions->setEmail($_SESSION['email_address']);
6061

6162
$userProductPermissionProfilesResponse = $permissionProfilesApi->
62-
getUserProductPermissionProfilesByEmail(
63+
getUserProductPermissionProfilesByEmailWithHttpInfo(
6364
$this->orgId,
6465
$this->args["account_id"],
6566
$getUserProductPermissionProfilesByEmailOptions
6667
);
68+
69+
$remaining = $userProductPermissionProfilesResponse[2]['X-RateLimit-Remaining'] ?? null;
70+
$reset = $userProductPermissionProfilesResponse[2]['X-RateLimit-Reset'] ?? null;
71+
72+
if ($remaining !== null && $reset !== null) {
73+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
74+
error_log("API calls remaining: $remaining");
75+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
76+
}
6777
#ds-snippet-end:Admin9Step3
6878

6979
parent::controller(
70-
$this->preparePageProperties($userProductPermissionProfilesResponse)
80+
$this->preparePageProperties($userProductPermissionProfilesResponse[0])
7181
);
7282
}
7383
} catch (ApiException $e) {

src/Controllers/Examples/eSignature/EG027PermissionDelete.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public function createController(): void
4444
if ($deleteResponse) {
4545
# That need an envelope_id
4646
$this->clientService->showDoneTemplateFromManifest(
47-
$this->codeExampleText,
48-
$deleteResponse
47+
$this->codeExampleText
4948
);
5049
}
5150
}

src/Services/Examples/Admin/AuditUsersService.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DocuSign\Services\Examples\Admin;
44

5+
use DateTime;
56
use DocuSign\Admin\Api\UsersApi\GetUserProfilesOptions;
67
use DocuSign\Admin\Api\UsersApi\GetUsersOptions;
78
use DocuSign\Admin\Client\ApiException;
@@ -42,18 +43,34 @@ public static function auditUsers(
4243
$options->setLastModifiedSince($from_date);
4344

4445
try {
45-
$modifiedUsers = $admin_api->getUsers($organizationId, $options);
46+
$modifiedUsers = $admin_api->getUsersWithHttpInfo($organizationId, $options);
4647
#ds-snippet-end:Admin5Step3
48+
$remaining = $modifiedUsers[2]['X-RateLimit-Remaining'] ?? null;
49+
$reset = $modifiedUsers[2]['X-RateLimit-Reset'] ?? null;
50+
51+
if ($remaining !== null && $reset !== null) {
52+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
53+
error_log("API calls remaining: $remaining");
54+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
55+
}
4756

4857
#ds-snippet-start:Admin5Step4
49-
foreach ($modifiedUsers["users"] as $user) {
58+
foreach ($modifiedUsers[0]["users"] as $user) {
5059
$profileOptions = new GetUserProfilesOptions();
5160
$profileOptions->setEmail($user["email"]);
5261
#ds-snippet-end:Admin5Step4
5362

5463
#ds-snippet-start:Admin5Step5
55-
$res = $admin_api->getUserProfiles($organizationId, $profileOptions);
56-
$userDrilldownResponse->setUsers($res->getUsers());
64+
$res = $admin_api->getUserProfilesWithHttpInfo($organizationId, $profileOptions);
65+
$remaining = $res[2]['X-RateLimit-Remaining'] ?? null;
66+
$reset = $res[2]['X-RateLimit-Reset'] ?? null;
67+
68+
if ($remaining !== null && $reset !== null) {
69+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
70+
error_log("API calls remaining: $remaining");
71+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
72+
}
73+
$userDrilldownResponse->setUsers($res[0]->getUsers());
5774
$decoded = json_decode((string)$userDrilldownResponse, true);
5875
array_push($usersInformation, $decoded["users"]);
5976
#ds-snippet-end:Admin5Step5

src/Services/Examples/Admin/BulkExportUserDataService.php

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DocuSign\Services\Examples\Admin;
44

5+
use DateTime;
56
use DocuSign\Admin\Client\ApiException;
67
use DocuSign\Admin\Model\OrganizationExportResponse;
78
use DocuSign\Services\AdminApiClientService;
@@ -28,28 +29,65 @@ public static function getExportsData(
2829
$bulkExportsApi = $clientService->bulkExportsAPI();
2930
$request = new OrganizationExportResponse();
3031
$request->setType("organization_memberships_export");
31-
$bulkList = $bulkExportsApi->createUserListExport($organizationId, $request);
32+
$bulkList = $bulkExportsApi->createUserListExportWithHttpInfo($organizationId, $request);
3233
#ds-snippet-end:Admin3Step3
3334

35+
$remaining = $bulkList[2]['X-RateLimit-Remaining'] ?? null;
36+
$reset = $bulkList[2]['X-RateLimit-Reset'] ?? null;
37+
38+
if ($remaining !== null && $reset !== null) {
39+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
40+
error_log("API calls remaining: $remaining");
41+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
42+
}
43+
3444
sleep(30);
3545

3646
#ds-snippet-start:Admin3Step4
37-
$organizationExportResponse = $bulkExportsApi->getUserListExport($organizationId, $bulkList["id"]);
47+
$organizationExportResponse = $bulkExportsApi->getUserListExportWithHttpInfo($organizationId, $bulkList[0]["id"]);
3848
#ds-snippet-end:Admin3Step4
3949

50+
$remaining = $organizationExportResponse[2]['X-RateLimit-Remaining'] ?? null;
51+
$reset = $organizationExportResponse[2]['X-RateLimit-Reset'] ?? null;
52+
53+
if ($remaining !== null && $reset !== null) {
54+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
55+
error_log("API calls remaining: $remaining");
56+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
57+
}
58+
4059
try {
41-
if ($organizationExportResponse["percent_completed"] < 100) {
60+
if ($organizationExportResponse[0]["percent_completed"] < 100) {
4261
sleep(25);
43-
$organizationExportResponse = $bulkExportsApi->getUserListExport($organizationId, $bulkList["id"]);
62+
$organizationExportResponse = $bulkExportsApi->getUserListExportWithHttpInfo($organizationId, $bulkList[0]["id"]);
63+
$remaining = $organizationExportResponse[2]['X-RateLimit-Remaining'] ?? null;
64+
$reset = $organizationExportResponse[2]['X-RateLimit-Reset'] ?? null;
4465

45-
if ($organizationExportResponse["percent_completed"] < 100) {
66+
if ($remaining !== null && $reset !== null) {
67+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
68+
error_log("API calls remaining: $remaining");
69+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
70+
}
71+
72+
if ($organizationExportResponse[0]["percent_completed"] < 100) {
4673
sleep(15);
47-
$organizationExportResponse = $bulkExportsApi->getUserListExport($organizationId, $bulkList["id"]);
74+
$organizationExportResponse = $bulkExportsApi->getUserListExportWithHttpInfo(
75+
$organizationId,
76+
$bulkList["id"]
77+
);
78+
$remaining = $organizationExportResponse[2]['X-RateLimit-Remaining'] ?? null;
79+
$reset = $organizationExportResponse[2]['X-RateLimit-Reset'] ?? null;
80+
81+
if ($remaining !== null && $reset !== null) {
82+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
83+
error_log("API calls remaining: $remaining");
84+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
85+
}
4886
}
4987
}
5088

5189
#ds-snippet-start:Admin3Step5
52-
$csvUri = $organizationExportResponse->getResults()[0]->getUrl();
90+
$csvUri = $organizationExportResponse[0]->getResults()[0]->getUrl();
5391

5492
$client = new Client();
5593
$client->request(
@@ -66,11 +104,21 @@ public static function getExportsData(
66104
);
67105
#ds-snippet-end:Admin3Step5
68106

69-
if ($organizationExportResponse->getResults() !== null) {
70-
$_SESSION['export_id'] = strval($organizationExportResponse->getResults()[0]->getId());
107+
if ($organizationExportResponse[0]->getResults() !== null) {
108+
$_SESSION['export_id'] = strval($organizationExportResponse[0]->getResults()[0]->getId());
109+
}
110+
$organizationExportResponse = $bulkExportsApi->getUserListExportsWithHttpInfo($organizationId);
111+
112+
$remaining = $organizationExportResponse[2]['X-RateLimit-Remaining'] ?? null;
113+
$reset = $organizationExportResponse[2]['X-RateLimit-Reset'] ?? null;
114+
115+
if ($remaining !== null && $reset !== null) {
116+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
117+
error_log("API calls remaining: $remaining");
118+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
71119
}
72-
$organizationExportResponse = $bulkExportsApi->getUserListExports($organizationId);
73-
return json_decode($organizationExportResponse->__toString());
120+
121+
return json_decode($organizationExportResponse[0]->__toString());
74122
} catch (ApiException $e) {
75123
$clientService->showErrorTemplate($e);
76124
}

src/Services/Examples/Admin/BulkImportUserDataService.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DocuSign\Services\Examples\Admin;
44

5+
use DateTime;
56
use DocuSign\Admin\Client\ApiException as ApiExceptionAlias;
67
use DocuSign\Services\AdminApiClientService;
78
use Exception;
@@ -24,23 +25,30 @@ public static function bulkImportUserData(AdminApiClientService $clientService,
2425
$str = file_get_contents($csvFile);
2526
$str = str_replace("<accountId>", $accountId, $str);
2627

27-
28-
2928
file_put_contents($csvFile, $str);
3029

3130
#ds-snippet-start:Admin4Step3
3231
$bulkImport = $clientService->bulkImportsApi();
33-
$organizationImportResponse = $bulkImport->createBulkImportAddUsersRequest(
32+
$organizationImportResponse = $bulkImport->createBulkImportAddUsersRequestWithHttpInfo(
3433
$organizationId,
3534
new SplFileObject($csvFile)
3635
);
36+
37+
$remaining = $organizationImportResponse[2]['X-RateLimit-Remaining'] ?? null;
38+
$reset = $organizationImportResponse[2]['X-RateLimit-Reset'] ?? null;
39+
40+
if ($remaining !== null && $reset !== null) {
41+
$resetInstant = (new DateTime())->setTimestamp((int)$reset);
42+
error_log("API calls remaining: $remaining");
43+
error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
44+
}
3745
#ds-snippet-end:Admin4Step3
3846

3947
$str = str_replace($accountId, "<accountId>", $str);
4048
file_put_contents($csvFile, $str);
4149

42-
$_SESSION['import_id'] = strval($organizationImportResponse->getId());
50+
$_SESSION['import_id'] = strval($organizationImportResponse[0]->getId());
4351

44-
return json_decode($organizationImportResponse->__toString());
52+
return json_decode($organizationImportResponse[0]->__toString());
4553
}
4654
}

0 commit comments

Comments
 (0)