diff --git a/src/Clients/CredentialIssuanceClient/.openapi-generator/FILES b/src/Clients/CredentialIssuanceClient/.openapi-generator/FILES index 42ddcf4..8459b20 100644 --- a/src/Clients/CredentialIssuanceClient/.openapi-generator/FILES +++ b/src/Clients/CredentialIssuanceClient/.openapi-generator/FILES @@ -75,6 +75,8 @@ lib/Api/WellKnownApi.php lib/ApiException.php lib/Configuration.php lib/HeaderSelector.php +lib/InvalidJwtTokenError.php +lib/InvalidParameterError.php lib/Model/ActionForbiddenError.php lib/Model/ActionForbiddenErrorDetailsInner.php lib/Model/ChangeCredentialStatusInput.php @@ -135,5 +137,6 @@ lib/Model/UpdateIssuanceConfigInput.php lib/Model/VcClaimedError.php lib/Model/WellKnownOpenIdCredentialIssuerResponse.php lib/Model/WellKnownOpenIdCredentialIssuerResponseCredentialsSupportedInner.php +lib/NotFoundError.php lib/ObjectSerializer.php phpunit.xml.dist diff --git a/src/Clients/CredentialIssuanceClient/docs/Api/DefaultApi.md b/src/Clients/CredentialIssuanceClient/docs/Api/DefaultApi.md index bb9d35e..fbd62d3 100644 --- a/src/Clients/CredentialIssuanceClient/docs/Api/DefaultApi.md +++ b/src/Clients/CredentialIssuanceClient/docs/Api/DefaultApi.md @@ -11,7 +11,7 @@ All URIs are relative to https://apse1.api.affinidi.io/cis, except if the operat ## `changeCredentialStatus()` ```php -changeCredentialStatus($project_id, $configuration_id): \AffinidiTdk\Clients\CredentialIssuanceClient\Model\FlowData +changeCredentialStatus($project_id, $configuration_id, $change_credential_status_input): \AffinidiTdk\Clients\CredentialIssuanceClient\Model\FlowData ``` change credential status. @@ -39,9 +39,10 @@ $apiInstance = new AffinidiTdk\Clients\CredentialIssuanceClient\Api\DefaultApi( ); $project_id = 'project_id_example'; // string | project id $configuration_id = 'configuration_id_example'; // string | configuration id +$change_credential_status_input = new \AffinidiTdk\Clients\CredentialIssuanceClient\Model\ChangeCredentialStatusInput(); // \AffinidiTdk\Clients\CredentialIssuanceClient\Model\ChangeCredentialStatusInput | Request body for changing credential status try { - $result = $apiInstance->changeCredentialStatus($project_id, $configuration_id); + $result = $apiInstance->changeCredentialStatus($project_id, $configuration_id, $change_credential_status_input); print_r($result); } catch (Exception $e) { echo 'Exception when calling DefaultApi->changeCredentialStatus: ', $e->getMessage(), PHP_EOL; @@ -54,6 +55,7 @@ try { | ------------- | ------------- | ------------- | ------------- | | **project_id** | **string**| project id | | | **configuration_id** | **string**| configuration id | | +| **change_credential_status_input** | [**\AffinidiTdk\Clients\CredentialIssuanceClient\Model\ChangeCredentialStatusInput**](../Model/ChangeCredentialStatusInput.md)| Request body for changing credential status | | ### Return type @@ -65,7 +67,7 @@ try { ### HTTP request headers -- **Content-Type**: Not defined +- **Content-Type**: `application/json` - **Accept**: `application/json` [[Back to top]](#) [[Back to API list]](../../README.md#endpoints) diff --git a/src/Clients/CredentialIssuanceClient/docs/Model/ChangeCredentialStatusInput.md b/src/Clients/CredentialIssuanceClient/docs/Model/ChangeCredentialStatusInput.md index e4414ab..e322d8f 100644 --- a/src/Clients/CredentialIssuanceClient/docs/Model/ChangeCredentialStatusInput.md +++ b/src/Clients/CredentialIssuanceClient/docs/Model/ChangeCredentialStatusInput.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**change_reason** | **string** | | [optional] -**issuance_flow_data_id** | **string** | | [optional] +**change_reason** | **string** | reason for revocation | [optional] +**issuance_record_id** | **string** | | [optional] [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/src/Clients/CredentialIssuanceClient/lib/Api/ConfigurationApi.php b/src/Clients/CredentialIssuanceClient/lib/Api/ConfigurationApi.php index 44f3ca7..fe52418 100644 --- a/src/Clients/CredentialIssuanceClient/lib/Api/ConfigurationApi.php +++ b/src/Clients/CredentialIssuanceClient/lib/Api/ConfigurationApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\CredentialIssuanceClient\ApiException; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidParameterError; +use AffinidiTdk\Clients\CredentialIssuanceClient\NotFoundError; use AffinidiTdk\Clients\CredentialIssuanceClient\Configuration; use AffinidiTdk\Clients\CredentialIssuanceClient\HeaderSelector; use AffinidiTdk\Clients\CredentialIssuanceClient\ObjectSerializer; @@ -96,10 +99,10 @@ class ConfigurationApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -170,6 +173,20 @@ public function createIssuanceConfigWithHttpInfo($create_issuance_config_input, try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -508,6 +525,20 @@ public function deleteIssuanceConfigByIdWithHttpInfo($configuration_id, string $ try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -739,6 +770,20 @@ public function getIssuanceConfigByIdWithHttpInfo($configuration_id, string $con try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1112,6 +1157,20 @@ public function getIssuanceConfigListWithHttpInfo(string $contentType = self::co try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -1401,6 +1460,20 @@ public function updateIssuanceConfigByIdWithHttpInfo($configuration_id, $update_ try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/CredentialIssuanceClient/lib/Api/CredentialsApi.php b/src/Clients/CredentialIssuanceClient/lib/Api/CredentialsApi.php index e92a463..c798de9 100644 --- a/src/Clients/CredentialIssuanceClient/lib/Api/CredentialsApi.php +++ b/src/Clients/CredentialIssuanceClient/lib/Api/CredentialsApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\CredentialIssuanceClient\ApiException; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidParameterError; +use AffinidiTdk\Clients\CredentialIssuanceClient\NotFoundError; use AffinidiTdk\Clients\CredentialIssuanceClient\Configuration; use AffinidiTdk\Clients\CredentialIssuanceClient\HeaderSelector; use AffinidiTdk\Clients\CredentialIssuanceClient\ObjectSerializer; @@ -84,10 +87,10 @@ class CredentialsApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -160,6 +163,20 @@ public function generateCredentialsWithHttpInfo($project_id, $create_credential_ try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/CredentialIssuanceClient/lib/Api/DefaultApi.php b/src/Clients/CredentialIssuanceClient/lib/Api/DefaultApi.php index 42cbf84..80ff3ab 100644 --- a/src/Clients/CredentialIssuanceClient/lib/Api/DefaultApi.php +++ b/src/Clients/CredentialIssuanceClient/lib/Api/DefaultApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\CredentialIssuanceClient\ApiException; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidParameterError; +use AffinidiTdk\Clients\CredentialIssuanceClient\NotFoundError; use AffinidiTdk\Clients\CredentialIssuanceClient\Configuration; use AffinidiTdk\Clients\CredentialIssuanceClient\HeaderSelector; use AffinidiTdk\Clients\CredentialIssuanceClient\ObjectSerializer; @@ -87,10 +90,10 @@ class DefaultApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -133,15 +136,16 @@ public function getConfig() * * @param string $project_id project id (required) * @param string $configuration_id configuration id (required) + * @param \AffinidiTdk\Clients\CredentialIssuanceClient\Model\ChangeCredentialStatusInput $change_credential_status_input Request body for changing credential status (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['changeCredentialStatus'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\CredentialIssuanceClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \AffinidiTdk\Clients\CredentialIssuanceClient\Model\FlowData|\AffinidiTdk\Clients\CredentialIssuanceClient\Model\InvalidParameterError|\AffinidiTdk\Clients\CredentialIssuanceClient\Model\NotFoundError */ - public function changeCredentialStatus($project_id, $configuration_id, string $contentType = self::contentTypes['changeCredentialStatus'][0]) + public function changeCredentialStatus($project_id, $configuration_id, $change_credential_status_input, string $contentType = self::contentTypes['changeCredentialStatus'][0]) { - list($response) = $this->changeCredentialStatusWithHttpInfo($project_id, $configuration_id, $contentType); + list($response) = $this->changeCredentialStatusWithHttpInfo($project_id, $configuration_id, $change_credential_status_input, $contentType); return $response; } @@ -152,21 +156,36 @@ public function changeCredentialStatus($project_id, $configuration_id, string $c * * @param string $project_id project id (required) * @param string $configuration_id configuration id (required) + * @param \AffinidiTdk\Clients\CredentialIssuanceClient\Model\ChangeCredentialStatusInput $change_credential_status_input Request body for changing credential status (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['changeCredentialStatus'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\CredentialIssuanceClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \AffinidiTdk\Clients\CredentialIssuanceClient\Model\FlowData|\AffinidiTdk\Clients\CredentialIssuanceClient\Model\InvalidParameterError|\AffinidiTdk\Clients\CredentialIssuanceClient\Model\NotFoundError, HTTP status code, HTTP response headers (array of strings) */ - public function changeCredentialStatusWithHttpInfo($project_id, $configuration_id, string $contentType = self::contentTypes['changeCredentialStatus'][0]) + public function changeCredentialStatusWithHttpInfo($project_id, $configuration_id, $change_credential_status_input, string $contentType = self::contentTypes['changeCredentialStatus'][0]) { - $request = $this->changeCredentialStatusRequest($project_id, $configuration_id, $contentType); + $request = $this->changeCredentialStatusRequest($project_id, $configuration_id, $change_credential_status_input, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -348,14 +367,15 @@ public function changeCredentialStatusWithHttpInfo($project_id, $configuration_i * * @param string $project_id project id (required) * @param string $configuration_id configuration id (required) + * @param \AffinidiTdk\Clients\CredentialIssuanceClient\Model\ChangeCredentialStatusInput $change_credential_status_input Request body for changing credential status (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['changeCredentialStatus'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function changeCredentialStatusAsync($project_id, $configuration_id, string $contentType = self::contentTypes['changeCredentialStatus'][0]) + public function changeCredentialStatusAsync($project_id, $configuration_id, $change_credential_status_input, string $contentType = self::contentTypes['changeCredentialStatus'][0]) { - return $this->changeCredentialStatusAsyncWithHttpInfo($project_id, $configuration_id, $contentType) + return $this->changeCredentialStatusAsyncWithHttpInfo($project_id, $configuration_id, $change_credential_status_input, $contentType) ->then( function ($response) { return $response[0]; @@ -370,15 +390,16 @@ function ($response) { * * @param string $project_id project id (required) * @param string $configuration_id configuration id (required) + * @param \AffinidiTdk\Clients\CredentialIssuanceClient\Model\ChangeCredentialStatusInput $change_credential_status_input Request body for changing credential status (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['changeCredentialStatus'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function changeCredentialStatusAsyncWithHttpInfo($project_id, $configuration_id, string $contentType = self::contentTypes['changeCredentialStatus'][0]) + public function changeCredentialStatusAsyncWithHttpInfo($project_id, $configuration_id, $change_credential_status_input, string $contentType = self::contentTypes['changeCredentialStatus'][0]) { $returnType = '\AffinidiTdk\Clients\CredentialIssuanceClient\Model\FlowData'; - $request = $this->changeCredentialStatusRequest($project_id, $configuration_id, $contentType); + $request = $this->changeCredentialStatusRequest($project_id, $configuration_id, $change_credential_status_input, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -421,12 +442,13 @@ function ($exception) { * * @param string $project_id project id (required) * @param string $configuration_id configuration id (required) + * @param \AffinidiTdk\Clients\CredentialIssuanceClient\Model\ChangeCredentialStatusInput $change_credential_status_input Request body for changing credential status (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['changeCredentialStatus'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function changeCredentialStatusRequest($project_id, $configuration_id, string $contentType = self::contentTypes['changeCredentialStatus'][0]) + public function changeCredentialStatusRequest($project_id, $configuration_id, $change_credential_status_input, string $contentType = self::contentTypes['changeCredentialStatus'][0]) { // verify the required parameter 'project_id' is set @@ -443,6 +465,13 @@ public function changeCredentialStatusRequest($project_id, $configuration_id, st ); } + // verify the required parameter 'change_credential_status_input' is set + if ($change_credential_status_input === null || (is_array($change_credential_status_input) && count($change_credential_status_input) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $change_credential_status_input when calling changeCredentialStatus' + ); + } + $resourcePath = '/v1/{projectId}/configurations/{configurationId}/issuance/change-status'; $formParams = []; @@ -478,7 +507,14 @@ public function changeCredentialStatusRequest($project_id, $configuration_id, st ); // for model (json/xml) - if (count($formParams) > 0) { + if (isset($change_credential_status_input)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($change_credential_status_input)); + } else { + $httpBody = $change_credential_status_input; + } + } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -536,8 +572,8 @@ public function changeCredentialStatusRequest($project_id, $configuration_id, st * * @param string $project_id Affinidi project id (required) * @param string $configuration_id The id of the issuance configuration (required) - * @param int $limit Maximum number of records to fetch in a list (optional, default to 10) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 10) + * @param string|null $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listIssuanceDataRecords'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\CredentialIssuanceClient\ApiException on non-2xx response or if the response body is not in the expected format @@ -557,8 +593,8 @@ public function listIssuanceDataRecords($project_id, $configuration_id, $limit = * * @param string $project_id Affinidi project id (required) * @param string $configuration_id The id of the issuance configuration (required) - * @param int $limit Maximum number of records to fetch in a list (optional, default to 10) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 10) + * @param string|null $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listIssuanceDataRecords'] to see the possible values for this operation * * @throws \AffinidiTdk\Clients\CredentialIssuanceClient\ApiException on non-2xx response or if the response body is not in the expected format @@ -574,6 +610,20 @@ public function listIssuanceDataRecordsWithHttpInfo($project_id, $configuration_ try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -755,8 +805,8 @@ public function listIssuanceDataRecordsWithHttpInfo($project_id, $configuration_ * * @param string $project_id Affinidi project id (required) * @param string $configuration_id The id of the issuance configuration (required) - * @param int $limit Maximum number of records to fetch in a list (optional, default to 10) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 10) + * @param string|null $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listIssuanceDataRecords'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -779,8 +829,8 @@ function ($response) { * * @param string $project_id Affinidi project id (required) * @param string $configuration_id The id of the issuance configuration (required) - * @param int $limit Maximum number of records to fetch in a list (optional, default to 10) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 10) + * @param string|null $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listIssuanceDataRecords'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -832,8 +882,8 @@ function ($exception) { * * @param string $project_id Affinidi project id (required) * @param string $configuration_id The id of the issuance configuration (required) - * @param int $limit Maximum number of records to fetch in a list (optional, default to 10) - * @param string $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) + * @param int|null $limit Maximum number of records to fetch in a list (optional, default to 10) + * @param string|null $exclusive_start_key exclusiveStartKey for retrieving the next batch of data. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['listIssuanceDataRecords'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/src/Clients/CredentialIssuanceClient/lib/Api/IssuanceApi.php b/src/Clients/CredentialIssuanceClient/lib/Api/IssuanceApi.php index 679e1e5..6c23f24 100644 --- a/src/Clients/CredentialIssuanceClient/lib/Api/IssuanceApi.php +++ b/src/Clients/CredentialIssuanceClient/lib/Api/IssuanceApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\CredentialIssuanceClient\ApiException; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidParameterError; +use AffinidiTdk\Clients\CredentialIssuanceClient\NotFoundError; use AffinidiTdk\Clients\CredentialIssuanceClient\Configuration; use AffinidiTdk\Clients\CredentialIssuanceClient\HeaderSelector; use AffinidiTdk\Clients\CredentialIssuanceClient\ObjectSerializer; @@ -90,10 +93,10 @@ class IssuanceApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -166,6 +169,20 @@ public function issuanceStateWithHttpInfo($issuance_id, $project_id, string $con try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -594,6 +611,20 @@ public function listIssuanceWithHttpInfo($project_id, string $contentType = self try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), @@ -936,6 +967,20 @@ public function startIssuanceWithHttpInfo($project_id, $start_issuance_input, st try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/CredentialIssuanceClient/lib/Api/OfferApi.php b/src/Clients/CredentialIssuanceClient/lib/Api/OfferApi.php index 80a6a7a..299372a 100644 --- a/src/Clients/CredentialIssuanceClient/lib/Api/OfferApi.php +++ b/src/Clients/CredentialIssuanceClient/lib/Api/OfferApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\CredentialIssuanceClient\ApiException; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidParameterError; +use AffinidiTdk\Clients\CredentialIssuanceClient\NotFoundError; use AffinidiTdk\Clients\CredentialIssuanceClient\Configuration; use AffinidiTdk\Clients\CredentialIssuanceClient\HeaderSelector; use AffinidiTdk\Clients\CredentialIssuanceClient\ObjectSerializer; @@ -84,10 +87,10 @@ class OfferApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -160,6 +163,20 @@ public function getCredentialOfferWithHttpInfo($project_id, $issuance_id, string try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/CredentialIssuanceClient/lib/Api/WellKnownApi.php b/src/Clients/CredentialIssuanceClient/lib/Api/WellKnownApi.php index 26a026f..a018503 100644 --- a/src/Clients/CredentialIssuanceClient/lib/Api/WellKnownApi.php +++ b/src/Clients/CredentialIssuanceClient/lib/Api/WellKnownApi.php @@ -36,6 +36,9 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use AffinidiTdk\Clients\CredentialIssuanceClient\ApiException; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidJwtTokenError; +use AffinidiTdk\Clients\CredentialIssuanceClient\InvalidParameterError; +use AffinidiTdk\Clients\CredentialIssuanceClient\NotFoundError; use AffinidiTdk\Clients\CredentialIssuanceClient\Configuration; use AffinidiTdk\Clients\CredentialIssuanceClient\HeaderSelector; use AffinidiTdk\Clients\CredentialIssuanceClient\ObjectSerializer; @@ -84,10 +87,10 @@ class WellKnownApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); @@ -158,6 +161,20 @@ public function getWellKnownOpenIdCredentialIssuerWithHttpInfo($project_id, stri try { $response = $this->client->send($request, $options); } catch (RequestException $e) { + $jsonResponse = json_decode($e->getResponse()->getBody()); + if ($jsonResponse->name === 'InvalidJwtTokenError') { + $issue = $jsonResponse->details[0]->issue; + throw new InvalidJwtTokenError($issue, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'NotFoundError') { + throw new NotFoundError($jsonResponse->message, $jsonResponse->traceId); + } + + if ($jsonResponse->name === 'InvalidParameterError') { + throw new InvalidParameterError($jsonResponse->message, $jsonResponse->details, $jsonResponse->traceId); + } + throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), diff --git a/src/Clients/CredentialIssuanceClient/lib/InvalidJwtTokenError.php b/src/Clients/CredentialIssuanceClient/lib/InvalidJwtTokenError.php new file mode 100644 index 0000000..722fb46 --- /dev/null +++ b/src/Clients/CredentialIssuanceClient/lib/InvalidJwtTokenError.php @@ -0,0 +1,80 @@ + $this->name, + 'message' => $this->message, + 'issue' => $issue, + 'traceId' => $traceId + ]; + + parent::__construct(json_encode($message), 403); + $this->issue = $issue; + $this->traceId = $traceId; + } +} diff --git a/src/Clients/CredentialIssuanceClient/lib/InvalidParameterError.php b/src/Clients/CredentialIssuanceClient/lib/InvalidParameterError.php new file mode 100644 index 0000000..ef70a12 --- /dev/null +++ b/src/Clients/CredentialIssuanceClient/lib/InvalidParameterError.php @@ -0,0 +1,75 @@ + $this->name, + 'message' => $message, + 'details' => $details, + 'traceId' => $traceId + ]; + + parent::__construct(json_encode($message), 400); + $this->details = $details; + $this->traceId = $traceId; + } +} diff --git a/src/Clients/CredentialIssuanceClient/lib/Model/ChangeCredentialStatusInput.php b/src/Clients/CredentialIssuanceClient/lib/Model/ChangeCredentialStatusInput.php index 5b5ffb6..ac27e9f 100644 --- a/src/Clients/CredentialIssuanceClient/lib/Model/ChangeCredentialStatusInput.php +++ b/src/Clients/CredentialIssuanceClient/lib/Model/ChangeCredentialStatusInput.php @@ -59,7 +59,7 @@ class ChangeCredentialStatusInput implements ModelInterface, ArrayAccess, \JsonS */ protected static $openAPITypes = [ 'change_reason' => 'string', - 'issuance_flow_data_id' => 'string' + 'issuance_record_id' => 'string' ]; /** @@ -71,7 +71,7 @@ class ChangeCredentialStatusInput implements ModelInterface, ArrayAccess, \JsonS */ protected static $openAPIFormats = [ 'change_reason' => null, - 'issuance_flow_data_id' => null + 'issuance_record_id' => null ]; /** @@ -81,7 +81,7 @@ class ChangeCredentialStatusInput implements ModelInterface, ArrayAccess, \JsonS */ protected static array $openAPINullables = [ 'change_reason' => false, - 'issuance_flow_data_id' => false + 'issuance_record_id' => false ]; /** @@ -171,7 +171,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'change_reason' => 'changeReason', - 'issuance_flow_data_id' => 'issuanceFlowDataId' + 'issuance_record_id' => 'issuanceRecordId' ]; /** @@ -181,7 +181,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'change_reason' => 'setChangeReason', - 'issuance_flow_data_id' => 'setIssuanceFlowDataId' + 'issuance_record_id' => 'setIssuanceRecordId' ]; /** @@ -191,7 +191,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'change_reason' => 'getChangeReason', - 'issuance_flow_data_id' => 'getIssuanceFlowDataId' + 'issuance_record_id' => 'getIssuanceRecordId' ]; /** @@ -235,6 +235,21 @@ public function getModelName() return self::$openAPIModelName; } + public const CHANGE_REASON_INVALID_CREDENTIAL = 'INVALID_CREDENTIAL'; + public const CHANGE_REASON_COMPROMISED_ISSUER = 'COMPROMISED_ISSUER'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getChangeReasonAllowableValues() + { + return [ + self::CHANGE_REASON_INVALID_CREDENTIAL, + self::CHANGE_REASON_COMPROMISED_ISSUER, + ]; + } /** * Associative array for storing property values @@ -252,7 +267,7 @@ public function getModelName() public function __construct(array $data = null) { $this->setIfExists('change_reason', $data ?? [], null); - $this->setIfExists('issuance_flow_data_id', $data ?? [], null); + $this->setIfExists('issuance_record_id', $data ?? [], null); } /** @@ -282,6 +297,15 @@ public function listInvalidProperties() { $invalidProperties = []; + $allowedValues = $this->getChangeReasonAllowableValues(); + if (!is_null($this->container['change_reason']) && !in_array($this->container['change_reason'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'change_reason', must be one of '%s'", + $this->container['change_reason'], + implode("', '", $allowedValues) + ); + } + return $invalidProperties; } @@ -310,7 +334,7 @@ public function getChangeReason() /** * Sets change_reason * - * @param string|null $change_reason change_reason + * @param string|null $change_reason reason for revocation * * @return self */ @@ -319,34 +343,44 @@ public function setChangeReason($change_reason) if (is_null($change_reason)) { throw new \InvalidArgumentException('non-nullable change_reason cannot be null'); } + $allowedValues = $this->getChangeReasonAllowableValues(); + if (!in_array($change_reason, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'change_reason', must be one of '%s'", + $change_reason, + implode("', '", $allowedValues) + ) + ); + } $this->container['change_reason'] = $change_reason; return $this; } /** - * Gets issuance_flow_data_id + * Gets issuance_record_id * * @return string|null */ - public function getIssuanceFlowDataId() + public function getIssuanceRecordId() { - return $this->container['issuance_flow_data_id']; + return $this->container['issuance_record_id']; } /** - * Sets issuance_flow_data_id + * Sets issuance_record_id * - * @param string|null $issuance_flow_data_id issuance_flow_data_id + * @param string|null $issuance_record_id issuance_record_id * * @return self */ - public function setIssuanceFlowDataId($issuance_flow_data_id) + public function setIssuanceRecordId($issuance_record_id) { - if (is_null($issuance_flow_data_id)) { - throw new \InvalidArgumentException('non-nullable issuance_flow_data_id cannot be null'); + if (is_null($issuance_record_id)) { + throw new \InvalidArgumentException('non-nullable issuance_record_id cannot be null'); } - $this->container['issuance_flow_data_id'] = $issuance_flow_data_id; + $this->container['issuance_record_id'] = $issuance_record_id; return $this; } diff --git a/src/Clients/CredentialIssuanceClient/lib/NotFoundError.php b/src/Clients/CredentialIssuanceClient/lib/NotFoundError.php new file mode 100644 index 0000000..429bbb0 --- /dev/null +++ b/src/Clients/CredentialIssuanceClient/lib/NotFoundError.php @@ -0,0 +1,73 @@ + $this->name, + 'message' => $message, + 'traceId' => $traceId + ]; + + parent::__construct(json_encode($message), 404); + $this->traceId = $traceId; + } +}