From a67ddc9222d919e8340281fe5ff1da4384941ddd Mon Sep 17 00:00:00 2001 From: Majid Mallis Date: Tue, 30 Jun 2020 14:32:40 -0700 Subject: [PATCH] Version 4.4.0-rc release (#109) * Version 4.4.0-rc-v2-20.2.00 release * Corrected release date for previous version Co-authored-by: automation Co-authored-by: Dhaval Brahmbhatt <32913565+dbbrahmbhatt@users.noreply.github.com> --- CHANGELOG.md | 2 +- src/Api/TrustServiceProvidersApi.php | 187 +++++++++++++++++++++++++++ src/ObjectSerializer.php | 9 +- test/UnitTests.php | 4 +- 4 files changed, 197 insertions(+), 5 deletions(-) create mode 100644 src/Api/TrustServiceProvidersApi.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d2343d0..40acc447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,4 +41,4 @@ See [DocuSign Support Center](https://support.docusign.com/en/releasenotes/) for ## [2.0.0] - New shiny PHP client - 2017-12-05 -## [1.0.0] - Old legacy version - 2016-02-18 \ No newline at end of file +## [1.0.0] - Old legacy version - 2016-02-18 diff --git a/src/Api/TrustServiceProvidersApi.php b/src/Api/TrustServiceProvidersApi.php new file mode 100644 index 00000000..d6c70ca0 --- /dev/null +++ b/src/Api/TrustServiceProvidersApi.php @@ -0,0 +1,187 @@ +apiClient = $apiClient; + } + + /** + * Get API client + * + * @return \DocuSign\eSign\Client\ApiClient get the API client + */ + public function getApiClient() + { + return $this->apiClient; + } + + /** + * Set the API client + * + * @param \DocuSign\eSign\Client\ApiClient $apiClient set the API client + * + * @return TrustServiceProvidersApi + */ + public function setApiClient(\DocuSign\eSign\Client\ApiClient $apiClient) + { + $this->apiClient = $apiClient; + return $this; + } + + /** + * Operation getSealProviders + * + * Returns Account available seals for specified account. + * + * @param string $account_id The external account number (int) or account ID Guid. + * @throws \DocuSign\eSign\Client\ApiException on non-2xx response + * @return \DocuSign\eSign\Model\AccountSeals + */ + public function getSealProviders($account_id) + { + list($response) = $this->getSealProvidersWithHttpInfo($account_id); + return $response; + } + + /** + * Operation getSealProvidersWithHttpInfo + * + * Returns Account available seals for specified account. + * + * @param string $account_id The external account number (int) or account ID Guid. + * @throws \DocuSign\eSign\Client\ApiException on non-2xx response + * @return array of \DocuSign\eSign\Model\AccountSeals, HTTP status code, HTTP response headers (array of strings) + */ + public function getSealProvidersWithHttpInfo($account_id) + { + // verify the required parameter 'account_id' is set + if ($account_id === null) { + throw new \InvalidArgumentException('Missing the required parameter $account_id when calling getSealProviders'); + } + // parse inputs + $resourcePath = "/v2/accounts/{accountId}/seals"; + $httpBody = ''; + $queryParams = []; + $headerParams = []; + $formParams = []; + $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType([]); + + + // path params + if ($account_id !== null) { + $resourcePath = str_replace( + "{" . "accountId" . "}", + $this->apiClient->getSerializer()->toPathValue($account_id), + $resourcePath + ); + } + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, + 'GET', + $queryParams, + $httpBody, + $headerParams, + '\DocuSign\eSign\Model\AccountSeals', + '/v2/accounts/{accountId}/seals' + ); + + return [$this->apiClient->getSerializer()->deserialize($response, '\DocuSign\eSign\Model\AccountSeals', $httpHeader), $statusCode, $httpHeader]; + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\DocuSign\eSign\Model\AccountSeals', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + case 400: + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\DocuSign\eSign\Model\ErrorDetails', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } + + throw $e; + } + } +} diff --git a/src/ObjectSerializer.php b/src/ObjectSerializer.php index 053e4d35..87967f82 100644 --- a/src/ObjectSerializer.php +++ b/src/ObjectSerializer.php @@ -282,8 +282,13 @@ public static function deserialize($data, $class, $httpHeaders = null) } $file = fopen($filename, 'w'); - while ($chunk = $data->read(200)) { - fwrite($file, $chunk); + if(is_string($data)){ + fwrite($file, $data); + } + else{ + while ($chunk = $data->read(200)) { + fwrite($file, $chunk); + } } fclose($file); diff --git a/test/UnitTests.php b/test/UnitTests.php index 89beaaf5..b489f728 100644 --- a/test/UnitTests.php +++ b/test/UnitTests.php @@ -313,8 +313,8 @@ public function testListDocumentsAndDownload($testConfig) foreach($docsList->getEnvelopeDocuments() as $document) { $this->assertNotEmpty($document->getDocumentId()); - //$file = $envelopeApi->getDocument($testConfig->getAccountId(), $testConfig->getEnvelopeId(), $document->getDocumentId()); - //$this->assertNotEmpty($file); + $file = $envelopeApi->getDocument($testConfig->getAccountId(), $document->getDocumentId(), $testConfig->getEnvelopeId()); + $this->assertNotEmpty($file); } }