Skip to content

Latest commit

 

History

History
318 lines (224 loc) · 16.6 KB

README.md

File metadata and controls

318 lines (224 loc) · 16.6 KB

Consumers

(vault->consumers)

Overview

Available Operations

create

Create a consumer

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->build();

$consumer = new Components\ConsumerInput(
    consumerId: 'test_consumer_id',
    metadata: new Components\ConsumerMetadata(
        accountName: 'SpaceX',
        userName: 'Elon Musk',
        email: '[email protected]',
        image: 'https://www.spacex.com/static/images/share.jpg',
    ),
);

$response = $sdk->vault->consumers->create(
    consumer: $consumer,
    appId: 'dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX'

);

if ($response->createConsumerResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
consumer Components\ConsumerInput ✔️ N/A
appId ?string The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX

Response

?Operations\VaultConsumersAddResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*

list

This endpoint includes all application consumers, along with an aggregated count of requests made.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->build();



$responses = $sdk->vault->consumers->list(
    appId: 'dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX',
    limit: 20,
    cursor: '<value>'

);


foreach ($responses as $response) {
    if ($response->httpMeta->response->getStatusCode() === 200) {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
appId ?string The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX
limit ?int Number of results to return. Minimum 1, Maximum 200, Default 20
cursor ?string Cursor to start from. You can find cursors for next/previous pages in the meta.cursors property of the response.

Response

?Operations\VaultConsumersAllResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*

delete

Delete consumer and all their connections, including credentials.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->build();



$response = $sdk->vault->consumers->delete(
    consumerId: 'test_user_id',
    appId: 'dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX'

);

if ($response->deleteConsumerResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
consumerId string ✔️ ID of the consumer to return test_user_id
appId ?string The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX

Response

?Operations\VaultConsumersDeleteResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*

get

Consumer detail including their aggregated counts with the connections they have authorized.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->build();



$response = $sdk->vault->consumers->get(
    consumerId: 'test_user_id',
    appId: 'dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX'

);

if ($response->getConsumerResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
consumerId string ✔️ ID of the consumer to return test_user_id
appId ?string The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX

Response

?Operations\VaultConsumersOneResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*

update

Update consumer metadata such as name and email.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Apideck\Unify;
use Apideck\Unify\Models\Components;

$sdk = Unify\Apideck::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->setConsumerId('test-consumer')
    ->setAppId('dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX')
    ->build();

$updateConsumerRequest = new Components\UpdateConsumerRequest(
    metadata: new Components\ConsumerMetadata(
        accountName: 'SpaceX',
        userName: 'Elon Musk',
        email: '[email protected]',
        image: 'https://www.spacex.com/static/images/share.jpg',
    ),
);

$response = $sdk->vault->consumers->update(
    consumerId: 'test_user_id',
    updateConsumerRequest: $updateConsumerRequest,
    appId: 'dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX'

);

if ($response->updateConsumerResponse !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
consumerId string ✔️ ID of the consumer to return test_user_id
updateConsumerRequest Components\UpdateConsumerRequest ✔️ N/A
appId ?string The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX

Response

?Operations\VaultConsumersUpdateResponse

Errors

Error Type Status Code Content Type
Errors\BadRequestResponse 400 application/json
Errors\UnauthorizedResponse 401 application/json
Errors\PaymentRequiredResponse 402 application/json
Errors\NotFoundResponse 404 application/json
Errors\UnprocessableResponse 422 application/json
Errors\APIException 4XX, 5XX */*