22
33namespace DocuSign \Services \Examples \Admin ;
44
5+ use DateTime ;
56use DocuSign \Admin \Client \ApiException ;
67use DocuSign \Admin \Model \OrganizationExportResponse ;
78use 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 }
0 commit comments