From 0e32f82a1558491e64b06d4c80a74663e149402e Mon Sep 17 00:00:00 2001 From: dvacca-onfido <134616519+dvacca-onfido@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:42:47 +0000 Subject: [PATCH 1/2] Upgrade after onfido-openapi-spec change 40b86a1 --- .release.json | 8 +- composer.json | 2 +- composer.lock | 2 +- lib/Api/DefaultApi.php | 372 ++++++++++++++++++ lib/Configuration.php | 4 +- lib/Model/Document.php | 2 + lib/Model/DocumentProperties.php | 102 +++-- lib/Model/DocumentShared.php | 2 + ...riverVerificationReportAllOfProperties.php | 102 +++-- lib/Model/WebhookEventPayloadObject.php | 36 +- 10 files changed, 555 insertions(+), 77 deletions(-) diff --git a/.release.json b/.release.json index 6e713ed..1a1f772 100644 --- a/.release.json +++ b/.release.json @@ -1,9 +1,9 @@ { "source": { "repo_url": "https://github.com/onfido/onfido-openapi-spec", - "short_sha": "01ed1b5", - "long_sha": "01ed1b5fe0f7490bfce54816504a9fec13b33862", - "version": "v3.1.0" + "short_sha": "40b86a1", + "long_sha": "40b86a1c8ec8687c15514470f60428b3e7633968", + "version": "v3.2.0" }, - "release": "v7.1.0" + "release": "v7.2.0" } diff --git a/composer.json b/composer.json index 7a571f5..05d9200 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "onfido/onfido-php", - "version": "7.1.0", + "version": "7.2.0", "description": "The Onfido API (v3.6)", "keywords": [ "openapitools", diff --git a/composer.lock b/composer.lock index 5f172a1..69dfddf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aaeda59087897c36f0bb2030af02815b", + "content-hash": "7bcbf425cb158f89d77476ccc0b10e87", "packages": [ { "name": "guzzlehttp/guzzle", diff --git a/lib/Api/DefaultApi.php b/lib/Api/DefaultApi.php index 653c39c..f5102db 100644 --- a/lib/Api/DefaultApi.php +++ b/lib/Api/DefaultApi.php @@ -131,6 +131,9 @@ class DefaultApi 'downloadMotionCaptureFrame' => [ 'application/json', ], + 'downloadQesDocument' => [ + 'application/json', + ], 'downloadSignedEvidenceFile' => [ 'application/json', ], @@ -6760,6 +6763,375 @@ public function downloadMotionCaptureFrameRequest($motion_capture_id, string $co ); } + /** + * Operation downloadQesDocument + * + * Retrieves the signed document or application form + * + * @param string $workflow_run_id The unique identifier of the Workflow Run for which you want to retrieve the signed document. (required) + * @param string $file_id The unique identifier of the file which you want to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadQesDocument'] to see the possible values for this operation + * + * @throws \Onfido\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return |\SplFileObject|\Onfido\Model\Error + */ + public function downloadQesDocument($workflow_run_id, $file_id, string $contentType = self::contentTypes['downloadQesDocument'][0]) + { + list($response) = $this->downloadQesDocumentWithHttpInfo($workflow_run_id, $file_id, $contentType); + return $response; + } + + /** + * Operation downloadQesDocumentWithHttpInfo + * + * Retrieves the signed document or application form + * + * @param string $workflow_run_id The unique identifier of the Workflow Run for which you want to retrieve the signed document. (required) + * @param string $file_id The unique identifier of the file which you want to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadQesDocument'] to see the possible values for this operation + * + * @throws \Onfido\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of |\SplFileObject|\Onfido\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadQesDocumentWithHttpInfo($workflow_run_id, $file_id, string $contentType = self::contentTypes['downloadQesDocument'][0]) + { + $request = $this->downloadQesDocumentRequest($workflow_run_id, $file_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\Onfido\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\Onfido\Model\Error' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\Onfido\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Onfido\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadQesDocumentAsync + * + * Retrieves the signed document or application form + * + * @param string $workflow_run_id The unique identifier of the Workflow Run for which you want to retrieve the signed document. (required) + * @param string $file_id The unique identifier of the file which you want to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadQesDocument'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadQesDocumentAsync($workflow_run_id, $file_id, string $contentType = self::contentTypes['downloadQesDocument'][0]) + { + return $this->downloadQesDocumentAsyncWithHttpInfo($workflow_run_id, $file_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadQesDocumentAsyncWithHttpInfo + * + * Retrieves the signed document or application form + * + * @param string $workflow_run_id The unique identifier of the Workflow Run for which you want to retrieve the signed document. (required) + * @param string $file_id The unique identifier of the file which you want to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadQesDocument'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadQesDocumentAsyncWithHttpInfo($workflow_run_id, $file_id, string $contentType = self::contentTypes['downloadQesDocument'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadQesDocumentRequest($workflow_run_id, $file_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadQesDocument' + * + * @param string $workflow_run_id The unique identifier of the Workflow Run for which you want to retrieve the signed document. (required) + * @param string $file_id The unique identifier of the file which you want to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadQesDocument'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadQesDocumentRequest($workflow_run_id, $file_id, string $contentType = self::contentTypes['downloadQesDocument'][0]) + { + + // verify the required parameter 'workflow_run_id' is set + if ($workflow_run_id === null || (is_array($workflow_run_id) && count($workflow_run_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $workflow_run_id when calling downloadQesDocument' + ); + } + + // verify the required parameter 'file_id' is set + if ($file_id === null || (is_array($file_id) && count($file_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $file_id when calling downloadQesDocument' + ); + } + + + $resourcePath = '/qualified_electronic_signature/documents'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $workflow_run_id, + 'workflow_run_id', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $file_id, + 'file_id', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + if ($apiKey !== null) { + $headers['Authorization'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Operation downloadSignedEvidenceFile * diff --git a/lib/Configuration.php b/lib/Configuration.php index fd4da0e..4ab0421 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -87,7 +87,7 @@ class Configuration * * @var string */ - protected $userAgent = 'onfido-php/7.1.0'; + protected $userAgent = 'onfido-php/7.2.0'; /** * Debug switch (default set to false) @@ -404,7 +404,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: v3.6' . PHP_EOL; - $report .= ' SDK Package Version: 7.1.0' . PHP_EOL; + $report .= ' SDK Package Version: 7.2.0' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; diff --git a/lib/Model/Document.php b/lib/Model/Document.php index 8966764..249ebbf 100644 --- a/lib/Model/Document.php +++ b/lib/Model/Document.php @@ -289,6 +289,7 @@ public function getModelName() } public const FILE_TYPE_JPG = 'jpg'; + public const FILE_TYPE_JPEG = 'jpeg'; public const FILE_TYPE_PNG = 'png'; public const FILE_TYPE_PDF = 'pdf'; public const FILE_TYPE_UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api'; @@ -305,6 +306,7 @@ public function getFileTypeAllowableValues() { return [ self::FILE_TYPE_JPG, + self::FILE_TYPE_JPEG, self::FILE_TYPE_PNG, self::FILE_TYPE_PDF, self::FILE_TYPE_UNKNOWN_DEFAULT_OPEN_API, diff --git a/lib/Model/DocumentProperties.php b/lib/Model/DocumentProperties.php index 4c0b9d1..27535b6 100644 --- a/lib/Model/DocumentProperties.php +++ b/lib/Model/DocumentProperties.php @@ -63,9 +63,10 @@ class DocumentProperties implements ModelInterface, ArrayAccess, \JsonSerializab 'document_numbers' => '\Onfido\Model\DocumentPropertiesDocumentNumbersInner[]', 'document_type' => 'string', 'first_name' => 'string', + 'middle_name' => 'string', + 'last_name' => 'string', 'gender' => 'string', 'issuing_country' => 'string', - 'last_name' => 'string', 'nationality' => 'string', 'issuing_state' => 'string', 'issuing_date' => '\DateTime', @@ -117,9 +118,10 @@ class DocumentProperties implements ModelInterface, ArrayAccess, \JsonSerializab 'document_numbers' => null, 'document_type' => null, 'first_name' => null, + 'middle_name' => null, + 'last_name' => null, 'gender' => null, 'issuing_country' => null, - 'last_name' => null, 'nationality' => null, 'issuing_state' => null, 'issuing_date' => 'date', @@ -169,9 +171,10 @@ class DocumentProperties implements ModelInterface, ArrayAccess, \JsonSerializab 'document_numbers' => false, 'document_type' => false, 'first_name' => false, + 'middle_name' => false, + 'last_name' => false, 'gender' => false, 'issuing_country' => false, - 'last_name' => false, 'nationality' => false, 'issuing_state' => false, 'issuing_date' => false, @@ -301,9 +304,10 @@ public function isNullableSetToNull(string $property): bool 'document_numbers' => 'document_numbers', 'document_type' => 'document_type', 'first_name' => 'first_name', + 'middle_name' => 'middle_name', + 'last_name' => 'last_name', 'gender' => 'gender', 'issuing_country' => 'issuing_country', - 'last_name' => 'last_name', 'nationality' => 'nationality', 'issuing_state' => 'issuing_state', 'issuing_date' => 'issuing_date', @@ -353,9 +357,10 @@ public function isNullableSetToNull(string $property): bool 'document_numbers' => 'setDocumentNumbers', 'document_type' => 'setDocumentType', 'first_name' => 'setFirstName', + 'middle_name' => 'setMiddleName', + 'last_name' => 'setLastName', 'gender' => 'setGender', 'issuing_country' => 'setIssuingCountry', - 'last_name' => 'setLastName', 'nationality' => 'setNationality', 'issuing_state' => 'setIssuingState', 'issuing_date' => 'setIssuingDate', @@ -405,9 +410,10 @@ public function isNullableSetToNull(string $property): bool 'document_numbers' => 'getDocumentNumbers', 'document_type' => 'getDocumentType', 'first_name' => 'getFirstName', + 'middle_name' => 'getMiddleName', + 'last_name' => 'getLastName', 'gender' => 'getGender', 'issuing_country' => 'getIssuingCountry', - 'last_name' => 'getLastName', 'nationality' => 'getNationality', 'issuing_state' => 'getIssuingState', 'issuing_date' => 'getIssuingDate', @@ -577,9 +583,10 @@ public function __construct(array $data = null) $this->setIfExists('document_numbers', $data ?? [], null); $this->setIfExists('document_type', $data ?? [], null); $this->setIfExists('first_name', $data ?? [], null); + $this->setIfExists('middle_name', $data ?? [], null); + $this->setIfExists('last_name', $data ?? [], null); $this->setIfExists('gender', $data ?? [], null); $this->setIfExists('issuing_country', $data ?? [], null); - $this->setIfExists('last_name', $data ?? [], null); $this->setIfExists('nationality', $data ?? [], null); $this->setIfExists('issuing_state', $data ?? [], null); $this->setIfExists('issuing_date', $data ?? [], null); @@ -849,82 +856,109 @@ public function setFirstName($first_name) } /** - * Gets gender + * Gets middle_name * * @return string|null */ - public function getGender() + public function getMiddleName() { - return $this->container['gender']; + return $this->container['middle_name']; } /** - * Sets gender + * Sets middle_name * - * @param string|null $gender gender + * @param string|null $middle_name middle_name * * @return self */ - public function setGender($gender) + public function setMiddleName($middle_name) { - if (is_null($gender)) { - throw new \InvalidArgumentException('non-nullable gender cannot be null'); + if (is_null($middle_name)) { + throw new \InvalidArgumentException('non-nullable middle_name cannot be null'); } - $this->container['gender'] = $gender; + $this->container['middle_name'] = $middle_name; return $this; } /** - * Gets issuing_country + * Gets last_name * * @return string|null */ - public function getIssuingCountry() + public function getLastName() { - return $this->container['issuing_country']; + return $this->container['last_name']; } /** - * Sets issuing_country + * Sets last_name * - * @param string|null $issuing_country issuing_country + * @param string|null $last_name last_name * * @return self */ - public function setIssuingCountry($issuing_country) + public function setLastName($last_name) { - if (is_null($issuing_country)) { - throw new \InvalidArgumentException('non-nullable issuing_country cannot be null'); + if (is_null($last_name)) { + throw new \InvalidArgumentException('non-nullable last_name cannot be null'); } - $this->container['issuing_country'] = $issuing_country; + $this->container['last_name'] = $last_name; return $this; } /** - * Gets last_name + * Gets gender * * @return string|null */ - public function getLastName() + public function getGender() { - return $this->container['last_name']; + return $this->container['gender']; } /** - * Sets last_name + * Sets gender * - * @param string|null $last_name last_name + * @param string|null $gender gender * * @return self */ - public function setLastName($last_name) + public function setGender($gender) { - if (is_null($last_name)) { - throw new \InvalidArgumentException('non-nullable last_name cannot be null'); + if (is_null($gender)) { + throw new \InvalidArgumentException('non-nullable gender cannot be null'); } - $this->container['last_name'] = $last_name; + $this->container['gender'] = $gender; + + return $this; + } + + /** + * Gets issuing_country + * + * @return string|null + */ + public function getIssuingCountry() + { + return $this->container['issuing_country']; + } + + /** + * Sets issuing_country + * + * @param string|null $issuing_country issuing_country + * + * @return self + */ + public function setIssuingCountry($issuing_country) + { + if (is_null($issuing_country)) { + throw new \InvalidArgumentException('non-nullable issuing_country cannot be null'); + } + $this->container['issuing_country'] = $issuing_country; return $this; } diff --git a/lib/Model/DocumentShared.php b/lib/Model/DocumentShared.php index 3c247a2..dacaba7 100644 --- a/lib/Model/DocumentShared.php +++ b/lib/Model/DocumentShared.php @@ -253,6 +253,7 @@ public function getModelName() } public const FILE_TYPE_JPG = 'jpg'; + public const FILE_TYPE_JPEG = 'jpeg'; public const FILE_TYPE_PNG = 'png'; public const FILE_TYPE_PDF = 'pdf'; public const FILE_TYPE_UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api'; @@ -269,6 +270,7 @@ public function getFileTypeAllowableValues() { return [ self::FILE_TYPE_JPG, + self::FILE_TYPE_JPEG, self::FILE_TYPE_PNG, self::FILE_TYPE_PDF, self::FILE_TYPE_UNKNOWN_DEFAULT_OPEN_API, diff --git a/lib/Model/DocumentWithDriverVerificationReportAllOfProperties.php b/lib/Model/DocumentWithDriverVerificationReportAllOfProperties.php index 13e46e9..87a996e 100644 --- a/lib/Model/DocumentWithDriverVerificationReportAllOfProperties.php +++ b/lib/Model/DocumentWithDriverVerificationReportAllOfProperties.php @@ -63,9 +63,10 @@ class DocumentWithDriverVerificationReportAllOfProperties implements ModelInterf 'document_numbers' => '\Onfido\Model\DocumentPropertiesDocumentNumbersInner[]', 'document_type' => 'string', 'first_name' => 'string', + 'middle_name' => 'string', + 'last_name' => 'string', 'gender' => 'string', 'issuing_country' => 'string', - 'last_name' => 'string', 'nationality' => 'string', 'issuing_state' => 'string', 'issuing_date' => '\DateTime', @@ -123,9 +124,10 @@ class DocumentWithDriverVerificationReportAllOfProperties implements ModelInterf 'document_numbers' => null, 'document_type' => null, 'first_name' => null, + 'middle_name' => null, + 'last_name' => null, 'gender' => null, 'issuing_country' => null, - 'last_name' => null, 'nationality' => null, 'issuing_state' => null, 'issuing_date' => 'date', @@ -181,9 +183,10 @@ class DocumentWithDriverVerificationReportAllOfProperties implements ModelInterf 'document_numbers' => false, 'document_type' => false, 'first_name' => false, + 'middle_name' => false, + 'last_name' => false, 'gender' => false, 'issuing_country' => false, - 'last_name' => false, 'nationality' => false, 'issuing_state' => false, 'issuing_date' => false, @@ -319,9 +322,10 @@ public function isNullableSetToNull(string $property): bool 'document_numbers' => 'document_numbers', 'document_type' => 'document_type', 'first_name' => 'first_name', + 'middle_name' => 'middle_name', + 'last_name' => 'last_name', 'gender' => 'gender', 'issuing_country' => 'issuing_country', - 'last_name' => 'last_name', 'nationality' => 'nationality', 'issuing_state' => 'issuing_state', 'issuing_date' => 'issuing_date', @@ -377,9 +381,10 @@ public function isNullableSetToNull(string $property): bool 'document_numbers' => 'setDocumentNumbers', 'document_type' => 'setDocumentType', 'first_name' => 'setFirstName', + 'middle_name' => 'setMiddleName', + 'last_name' => 'setLastName', 'gender' => 'setGender', 'issuing_country' => 'setIssuingCountry', - 'last_name' => 'setLastName', 'nationality' => 'setNationality', 'issuing_state' => 'setIssuingState', 'issuing_date' => 'setIssuingDate', @@ -435,9 +440,10 @@ public function isNullableSetToNull(string $property): bool 'document_numbers' => 'getDocumentNumbers', 'document_type' => 'getDocumentType', 'first_name' => 'getFirstName', + 'middle_name' => 'getMiddleName', + 'last_name' => 'getLastName', 'gender' => 'getGender', 'issuing_country' => 'getIssuingCountry', - 'last_name' => 'getLastName', 'nationality' => 'getNationality', 'issuing_state' => 'getIssuingState', 'issuing_date' => 'getIssuingDate', @@ -613,9 +619,10 @@ public function __construct(array $data = null) $this->setIfExists('document_numbers', $data ?? [], null); $this->setIfExists('document_type', $data ?? [], null); $this->setIfExists('first_name', $data ?? [], null); + $this->setIfExists('middle_name', $data ?? [], null); + $this->setIfExists('last_name', $data ?? [], null); $this->setIfExists('gender', $data ?? [], null); $this->setIfExists('issuing_country', $data ?? [], null); - $this->setIfExists('last_name', $data ?? [], null); $this->setIfExists('nationality', $data ?? [], null); $this->setIfExists('issuing_state', $data ?? [], null); $this->setIfExists('issuing_date', $data ?? [], null); @@ -891,82 +898,109 @@ public function setFirstName($first_name) } /** - * Gets gender + * Gets middle_name * * @return string|null */ - public function getGender() + public function getMiddleName() { - return $this->container['gender']; + return $this->container['middle_name']; } /** - * Sets gender + * Sets middle_name * - * @param string|null $gender gender + * @param string|null $middle_name middle_name * * @return self */ - public function setGender($gender) + public function setMiddleName($middle_name) { - if (is_null($gender)) { - throw new \InvalidArgumentException('non-nullable gender cannot be null'); + if (is_null($middle_name)) { + throw new \InvalidArgumentException('non-nullable middle_name cannot be null'); } - $this->container['gender'] = $gender; + $this->container['middle_name'] = $middle_name; return $this; } /** - * Gets issuing_country + * Gets last_name * * @return string|null */ - public function getIssuingCountry() + public function getLastName() { - return $this->container['issuing_country']; + return $this->container['last_name']; } /** - * Sets issuing_country + * Sets last_name * - * @param string|null $issuing_country issuing_country + * @param string|null $last_name last_name * * @return self */ - public function setIssuingCountry($issuing_country) + public function setLastName($last_name) { - if (is_null($issuing_country)) { - throw new \InvalidArgumentException('non-nullable issuing_country cannot be null'); + if (is_null($last_name)) { + throw new \InvalidArgumentException('non-nullable last_name cannot be null'); } - $this->container['issuing_country'] = $issuing_country; + $this->container['last_name'] = $last_name; return $this; } /** - * Gets last_name + * Gets gender * * @return string|null */ - public function getLastName() + public function getGender() { - return $this->container['last_name']; + return $this->container['gender']; } /** - * Sets last_name + * Sets gender * - * @param string|null $last_name last_name + * @param string|null $gender gender * * @return self */ - public function setLastName($last_name) + public function setGender($gender) { - if (is_null($last_name)) { - throw new \InvalidArgumentException('non-nullable last_name cannot be null'); + if (is_null($gender)) { + throw new \InvalidArgumentException('non-nullable gender cannot be null'); } - $this->container['last_name'] = $last_name; + $this->container['gender'] = $gender; + + return $this; + } + + /** + * Gets issuing_country + * + * @return string|null + */ + public function getIssuingCountry() + { + return $this->container['issuing_country']; + } + + /** + * Sets issuing_country + * + * @param string|null $issuing_country issuing_country + * + * @return self + */ + public function setIssuingCountry($issuing_country) + { + if (is_null($issuing_country)) { + throw new \InvalidArgumentException('non-nullable issuing_country cannot be null'); + } + $this->container['issuing_country'] = $issuing_country; return $this; } diff --git a/lib/Model/WebhookEventPayloadObject.php b/lib/Model/WebhookEventPayloadObject.php index 01b44e8..86eff6f 100644 --- a/lib/Model/WebhookEventPayloadObject.php +++ b/lib/Model/WebhookEventPayloadObject.php @@ -60,6 +60,7 @@ class WebhookEventPayloadObject implements ModelInterface, ArrayAccess, \JsonSer protected static $openAPITypes = [ 'id' => 'string', 'status' => 'string', + 'started_at_iso8601' => '\DateTime', 'completed_at_iso8601' => '\DateTime', 'href' => 'string' ]; @@ -72,8 +73,9 @@ class WebhookEventPayloadObject implements ModelInterface, ArrayAccess, \JsonSer * @psalm-var array */ protected static $openAPIFormats = [ - 'id' => 'uuid', + 'id' => null, 'status' => null, + 'started_at_iso8601' => 'date-time', 'completed_at_iso8601' => 'date-time', 'href' => null ]; @@ -86,6 +88,7 @@ class WebhookEventPayloadObject implements ModelInterface, ArrayAccess, \JsonSer protected static array $openAPINullables = [ 'id' => false, 'status' => false, + 'started_at_iso8601' => false, 'completed_at_iso8601' => false, 'href' => false ]; @@ -178,6 +181,7 @@ public function isNullableSetToNull(string $property): bool protected static $attributeMap = [ 'id' => 'id', 'status' => 'status', + 'started_at_iso8601' => 'started_at_iso8601', 'completed_at_iso8601' => 'completed_at_iso8601', 'href' => 'href' ]; @@ -190,6 +194,7 @@ public function isNullableSetToNull(string $property): bool protected static $setters = [ 'id' => 'setId', 'status' => 'setStatus', + 'started_at_iso8601' => 'setStartedAtIso8601', 'completed_at_iso8601' => 'setCompletedAtIso8601', 'href' => 'setHref' ]; @@ -202,6 +207,7 @@ public function isNullableSetToNull(string $property): bool protected static $getters = [ 'id' => 'getId', 'status' => 'getStatus', + 'started_at_iso8601' => 'getStartedAtIso8601', 'completed_at_iso8601' => 'getCompletedAtIso8601', 'href' => 'getHref' ]; @@ -265,6 +271,7 @@ public function __construct(array $data = null) { $this->setIfExists('id', $data ?? [], null); $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('started_at_iso8601', $data ?? [], null); $this->setIfExists('completed_at_iso8601', $data ?? [], null); $this->setIfExists('href', $data ?? [], null); } @@ -371,6 +378,33 @@ public function setStatus($status) return $this; } + /** + * Gets started_at_iso8601 + * + * @return \DateTime|null + */ + public function getStartedAtIso8601() + { + return $this->container['started_at_iso8601']; + } + + /** + * Sets started_at_iso8601 + * + * @param \DateTime|null $started_at_iso8601 The date and time when the operation was started, if available. + * + * @return self + */ + public function setStartedAtIso8601($started_at_iso8601) + { + if (is_null($started_at_iso8601)) { + throw new \InvalidArgumentException('non-nullable started_at_iso8601 cannot be null'); + } + $this->container['started_at_iso8601'] = $started_at_iso8601; + + return $this; + } + /** * Gets completed_at_iso8601 * From 1b9a0b2f3d4b5e7c9a616873a2e2c9cce2e1066f Mon Sep 17 00:00:00 2001 From: Francisco Castanho Date: Tue, 16 Jul 2024 11:43:35 +0100 Subject: [PATCH 2/2] test(qes): cover document download --- test/OnfidoTestCase.php | 33 ++++++++++-- .../QualifiedElectronicSignatureTest.php | 51 +++++++++++++++++++ 2 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 test/Resource/QualifiedElectronicSignatureTest.php diff --git a/test/OnfidoTestCase.php b/test/OnfidoTestCase.php index b45d648..91aa269 100644 --- a/test/OnfidoTestCase.php +++ b/test/OnfidoTestCase.php @@ -58,9 +58,13 @@ protected function createApplicant(): Onfido\Model\Applicant 'town' => 'London', 'postcode' => 'SW4 6EH', 'country' => Onfido\Model\CountryCodes::GBR, - 'line1' => 'My wonderful address']) - ]) - ); + 'line1' => 'My wonderful address' + ]), + 'email' => 'first.last@gmail.com', + 'phone_number' => '351911111111', + ] + ), + ); } protected static function cleanUpApplicants(): void @@ -186,6 +190,29 @@ protected function repeatRequestUntilStatusChanges( return $instance; } + protected function repeatRequestUntilTaskOutputChanges( + callable $function, + array $params, + $maxRetries = 10, + $sleepTime = 1 + ) + { + $instance = call_user_func_array($function, $params); + $iteration = 0; + + while($instance["output"] == NULL) { + if($iteration > $maxRetries) { + $this->fail('Output did not change in time'); + } + + $iteration += 1; + sleep($sleepTime); + + $instance = call_user_func_array($function, $params); + } + return $instance; + } + protected function repeatRequestUntilHttpCodeChanges( callable $function, array $params, diff --git a/test/Resource/QualifiedElectronicSignatureTest.php b/test/Resource/QualifiedElectronicSignatureTest.php new file mode 100644 index 0000000..eae6366 --- /dev/null +++ b/test/Resource/QualifiedElectronicSignatureTest.php @@ -0,0 +1,51 @@ +createApplicant()->getId(); + + $workflowRunBuilder = new WorkflowRunBuilder([ + 'applicant_id' => $applicantId, + 'workflow_id' => '8b74614f-9e7f-42fd-852a-5f2bcc852587', + 'custom_data' => [ + 'country_of_operation' => 'GBR', + 'document_date_of_expiry' => '2022-01-01', + 'document_issuing_country' => 'FRA', + 'document_issuing_date' => '2022-01-01', + 'document_number' => 'Example string', + 'document_to_sign_url' => 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', + 'document_type' => 'driving_licence', + ] + ]); + $workflowRun = $this->createWorkflowRun($workflowRunBuilder); + + $task = self::$onfido->listTasks($workflowRun["id"])[0]; + $workflowRunId = $workflowRun["id"]; + $taskId = $task->getId(); + + $findTaskFn = function($workflowRunId, $taskId) { + return self::$onfido->findTask($workflowRunId, $taskId); + }; + + $output = $this->repeatRequestUntilTaskOutputChanges( + $findTaskFn, + [$workflowRunId, $taskId], + 10, + 3, + )["output"]; + + $fileId = $output["properties"]->{'signed_documents'}[0]->{"id"}; + + $file = self::$onfido->downloadQesDocument($workflowRun->getId(), $fileId); + $this->assertGreaterThan(0, $file->getSize()); + } +} + +?> \ No newline at end of file