# Affinidi Iota Framework

> Manage Affinidi Iota Framework configuration to request data from Affinidi Vault.

## Install Dependency

Package: affinidi-tdk/affinidi-tdk-php

```bash
composer require affinidi-tdk/affinidi-tdk-php
```

Check the latest version on the [Packagist repository](https://packagist.org/packages/affinidi-tdk/affinidi-tdk-php) or view the source on [GitHub](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient).

## Classes and Methods

### Configurations API

Manage Affinidi Iota Framework configurations to integrate your application to request data from Affinidi Vault.

#### createIotaConfiguration

Creates an Affinidi Iota Framework configuration.

Parameters

    createIotaConfigurationInput
    [CreateIotaConfigurationInput](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient/docs/Model/CreateIotaConfigurationInput.md)
    Required
  Configuration name, wallet ARI, and webhook URL.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'name' => 'Sample App',
        'walletAri' => '',
        'iotaResponseWebhookURL' => 'http://localhost',
    );
    $result = $apiInstance->createIotaConfiguration($request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### deleteIotaConfigurationById

Deletes an existing Affinidi Iota Framework configuration by ID.

Parameters

    configurationId
    string
    Required
  ID of the configuration to delete.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->deleteIotaConfigurationById('');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### getIotaConfigurationById

Retrieves an existing Affinidi Iota Framework configuration by ID.

Parameters

    configurationId
    string
    Required
  ID of the configuration to retrieve.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->getIotaConfigurationById('');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### getIotaConfigurationMetaData

Retrieves the metadata of an existing Affinidi Iota Framework configuration.

Parameters

    projectId
    string
    Required
  Project ID where the configuration was created.

    configurationId
    string
    Required
  ID of the configuration.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->getIotaConfigurationMetaData('

', '');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### listIotaConfigurations

Returns all Affinidi Iota Framework configurations.

No parameters required.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->listIotaConfigurations();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### updateIotaConfigurationById

Updates an existing Affinidi Iota Framework configuration by ID.

Parameters

    configurationId
    string
    Required
  ID of the configuration to update.

    updateConfigurationByIdInput
    [UpdateConfigurationByIdInput](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient/docs/Model/UpdateConfigurationByIdInput.md)
    Required
  Updated configuration name, wallet ARI, and webhook URL.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'name' => 'Sample App',
        'walletAri' => '',
        'iotaResponseWebhookURL' => 'http://localhost',
    );
    $result = $apiInstance->updateIotaConfigurationById('', $request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

### Iota API

Generate access token required to access the Affinidi Iota Framework.

#### awsExchangeCredentials

Exchanges a limited token into a Cognito token.

Parameters

    awsExchangeCredentials
    [AwsExchangeCredentials](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient/docs/Model/AwsExchangeCredentials.md)
    Required
  JWT assertion string.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\IotaApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'assertion' => '',
    );
    $result = $apiInstance->awsExchangeCredentials($request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### initiateDataSharingRequest

Initiates a data-sharing request and returns the signed request token.

Parameters

    initiateDataSharingRequestInput
    [InitiateDataSharingRequestInput](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient/docs/Model/InitiateDataSharingRequestInput.md)
    Required
  Configuration ID, mode, query ID, correlation ID, nonce, and redirect URI.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\IotaApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'configurationId' => '',
        'mode' => 'redirect',
        'queryId' => '',
        'correlationId' => '',
        'nonce' => '',
        'redirectUri' => '',
    );
    $result = $apiInstance->initiateDataSharingRequest($request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### fetchIotaVpResponse

Fetches the callback response from Affinidi Vault.

Parameters

    fetchIOTAVPResponseInput
    [FetchIOTAVPResponseInput](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient/docs/Model/FetchIOTAVPResponseInput.md)
    Required
  Configuration ID, correlation ID, transaction ID, and response code.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\IotaApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'configurationId' => '',
        'correlationId' => '',
        'transactionId' => '
',
        'responseCode' => '',
    );
    $result = $apiInstance->fetchIotaVpResponse($request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

### Default API

Manage logged consent from Affinidi Iota Framework.

#### listLoggedConsents

Returns the list of logged consents for the project.

Parameters

    configurationId
    string
    Optional
  Filter by configuration ID.

    userId
    string
    Optional
  Filter by user ID.

    limit
    integer
    Optional
  Maximum number of records to return.

    exclusiveStartKey
    string
    Optional
  Base64url-encoded pagination key.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\DefaultApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->listLoggedConsents();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

### Callback API

Manage logged consent from Affinidi Iota Framework.

#### iotOIDC4VPCallback

Handles the callback from clients with data from OID4VP transactions.

Parameters

    callbackInput
    [CallbackInput](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient/docs/Model/CallbackInput.md)
    Required
  State, presentation submission, and VP token.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\CallbackApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'state' => '',
        'presentation_submission' => '

',
        'vp_token' => '',
    );
    $result = $apiInstance->iotOIDC4VPCallback($request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

### PexQuery API

Manage Presentation Exchange query definitions in an Affinidi Iota Framework configuration.

#### createPexQuery

Creates a Presentation Definition in the Iota configuration.

Parameters

    configurationId
    string
    Required
  ID of the Iota configuration.

    createPexQueryInput
    [CreatePexQueryInput](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient/docs/Model/CreatePexQueryInput.md)
    Required
  PEX query name and VP definition.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'name' => 'Request Data',
        'vpDefinition' => '

',
    );
    $result = $apiInstance->createPexQuery('', $request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### deletePexQueryById

Deletes a Presentation Definition by query ID from the Iota configuration.

Parameters

    configurationId
    string
    Required
  ID of the Iota configuration.

    queryId
    string
    Required
  ID of the Presentation Definition to delete.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->deletePexQueryById('', '');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### getPexQueryById

Retrieves a Presentation Definition by query ID from the Iota configuration.

Parameters

    configurationId
    string
    Required
  ID of the Iota configuration.

    queryId
    string
    Required
  ID of the Presentation Definition to retrieve.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->getPexQueryById('', '');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### listPexQueries

Retrieves all Presentation Definitions in the Iota configuration.

Parameters

    configurationId
    string
    Required
  ID of the Iota configuration.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->listPexQueries('');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```

#### updatePexQueryById

Updates a Presentation Definition by query ID in the Iota configuration.

Parameters

    configurationId
    string
    Required
  ID of the Iota configuration.

    queryId
    string
    Required
  ID of the Presentation Definition to update.

    updatePexQueryInput
    [UpdatePexQueryInput](https://github.com/affinidi/affinidi-tdk-php/tree/main/src/Clients/IotaClient/docs/Model/UpdatePexQueryInput.md)
    Required
  Updated VP definition.

Example

```php
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'vpDefinition' => '

',
    );
    $result = $apiInstance->updatePexQueryById('', '', $request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}
```
