|
2 | 2 |
|
3 | 3 | import com.docusign.admin.api.BulkExportsApi; |
4 | 4 | import com.docusign.admin.client.ApiException; |
| 5 | +import com.docusign.admin.client.ApiResponse; |
5 | 6 | import com.docusign.admin.model.OrganizationExportRequest; |
6 | 7 | import com.docusign.admin.model.OrganizationExportResponse; |
7 | 8 | import com.docusign.admin.model.OrganizationExportsResponse; |
|
18 | 19 | import java.net.URISyntaxException; |
19 | 20 | import java.net.URL; |
20 | 21 | import java.nio.file.Paths; |
| 22 | +import java.time.Instant; |
| 23 | +import java.util.List; |
| 24 | +import java.util.Map; |
21 | 25 | import java.util.Objects; |
22 | 26 | import java.util.UUID; |
23 | 27 |
|
24 | 28 | public class BulkExportUserDataService { |
25 | 29 | public static OrganizationExportsResponse bulkExportsUserData( |
26 | 30 | BulkExportsApi bulkExportsApi, |
27 | 31 | UUID organizationId) throws ApiException { |
28 | | - return bulkExportsApi.getUserListExports(organizationId); |
| 32 | + ApiResponse<OrganizationExportsResponse> response = bulkExportsApi |
| 33 | + .getUserListExportsWithHttpInfo(organizationId); |
| 34 | + |
| 35 | + Map<String, List<String>> headers = response.getHeaders(); |
| 36 | + List<String> remaining = headers.get("X-RateLimit-Remaining"); |
| 37 | + List<String> reset = headers.get("X-RateLimit-Reset"); |
| 38 | + |
| 39 | + if (remaining != null & reset != null) { |
| 40 | + Instant resetInstant = Instant.ofEpochSecond(Long.parseLong(reset.get(0))); |
| 41 | + System.out.println("API calls remaining: " + remaining); |
| 42 | + System.out.println("Next Reset: " + resetInstant); |
| 43 | + } |
| 44 | + |
| 45 | + return response.getData(); |
29 | 46 | } |
30 | 47 |
|
31 | 48 | public static OrganizationExportResponse bulkExportUserData( |
32 | 49 | BulkExportsApi bulkExportsApi, |
33 | 50 | UUID organizationId, |
34 | 51 | UUID exportId) throws ApiException { |
35 | | - return bulkExportsApi.getUserListExport(organizationId, exportId); |
| 52 | + ApiResponse<OrganizationExportResponse> response = bulkExportsApi.getUserListExportWithHttpInfo(organizationId, |
| 53 | + exportId); |
| 54 | + |
| 55 | + Map<String, List<String>> headers = response.getHeaders(); |
| 56 | + List<String> remaining = headers.get("X-RateLimit-Remaining"); |
| 57 | + List<String> reset = headers.get("X-RateLimit-Reset"); |
| 58 | + |
| 59 | + if (remaining != null & reset != null) { |
| 60 | + Instant resetInstant = Instant.ofEpochSecond(Long.parseLong(reset.get(0))); |
| 61 | + System.out.println("API calls remaining: " + remaining); |
| 62 | + System.out.println("Next Reset: " + resetInstant); |
| 63 | + } |
| 64 | + |
| 65 | + return response.getData(); |
36 | 66 | } |
37 | 67 |
|
38 | 68 | public static OrganizationExportResponse createUserListExport( |
39 | 69 | BulkExportsApi bulkExportsApi, |
40 | 70 | UUID organizationId) throws ApiException { |
41 | 71 | OrganizationExportRequest request = new OrganizationExportRequest(); |
42 | 72 | request.setType("organization_memberships_export"); |
43 | | - return bulkExportsApi.createUserListExport(organizationId, request); |
| 73 | + ApiResponse<OrganizationExportResponse> response = bulkExportsApi |
| 74 | + .createUserListExportWithHttpInfo(organizationId, request); |
| 75 | + |
| 76 | + Map<String, List<String>> headers = response.getHeaders(); |
| 77 | + List<String> remaining = headers.get("X-RateLimit-Remaining"); |
| 78 | + List<String> reset = headers.get("X-RateLimit-Reset"); |
| 79 | + |
| 80 | + if (remaining != null & reset != null) { |
| 81 | + Instant resetInstant = Instant.ofEpochSecond(Long.parseLong(reset.get(0))); |
| 82 | + System.out.println("API calls remaining: " + remaining); |
| 83 | + System.out.println("Next Reset: " + resetInstant); |
| 84 | + } |
| 85 | + |
| 86 | + return response.getData(); |
44 | 87 | } |
45 | 88 |
|
46 | 89 | public static String moveUserListExportToFile( |
|
0 commit comments