Skip to content

Latest commit

 

History

History
405 lines (278 loc) · 17.5 KB

File metadata and controls

405 lines (278 loc) · 17.5 KB

SDKWebhooksV1

Overview

Available Operations

activateConfig

Activate a webhooks config by ID, to start receiving webhooks to its endpoint.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use formance\stack;
use formance\stack\Models\Operations;
use formance\stack\Models\Shared;

$security = new Shared\Security(
    authorization: "<YOUR_AUTHORIZATION_HERE>",
);

$sdk = stack\SDK::builder()->setSecurity($security)->build();

try {
    $request = new Operations\ActivateConfigRequest(
        id: '4997257d-dfb6-445b-929c-cbe2ab182818',
    );
    $response = $sdk->webhooksV1->activateConfig($request);

    if ($response->configResponse !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
$request Operations\ActivateConfigRequest ✔️ The request object to use for the request.

Response

?Operations\ActivateConfigResponse

Errors

Error Object Status Code Content Type
Errors\WebhooksErrorResponse default application/json
formance\stack\Models\Errors.SDKException 4xx-5xx /

changeConfigSecret

Change the signing secret of the endpoint of a webhooks config.

If not passed or empty, a secret is automatically generated. The format is a random string of bytes of size 24, base64 encoded. (larger size after encoding)

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use formance\stack;
use formance\stack\Models\Operations;
use formance\stack\Models\Shared;

$security = new Shared\Security(
    authorization: "<YOUR_AUTHORIZATION_HERE>",
);

$sdk = stack\SDK::builder()->setSecurity($security)->build();

try {
    $request = new Operations\ChangeConfigSecretRequest(
        id: '4997257d-dfb6-445b-929c-cbe2ab182818',
        configChangeSecret: new Shared\ConfigChangeSecret(
            secret: 'V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3',
        ),
    );
    $response = $sdk->webhooksV1->changeConfigSecret($request);

    if ($response->configResponse !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
$request Operations\ChangeConfigSecretRequest ✔️ The request object to use for the request.

Response

?Operations\ChangeConfigSecretResponse

Errors

Error Object Status Code Content Type
Errors\WebhooksErrorResponse default application/json
formance\stack\Models\Errors.SDKException 4xx-5xx /

deactivateConfig

Deactivate a webhooks config by ID, to stop receiving webhooks to its endpoint.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use formance\stack;
use formance\stack\Models\Operations;
use formance\stack\Models\Shared;

$security = new Shared\Security(
    authorization: "<YOUR_AUTHORIZATION_HERE>",
);

$sdk = stack\SDK::builder()->setSecurity($security)->build();

try {
    $request = new Operations\DeactivateConfigRequest(
        id: '4997257d-dfb6-445b-929c-cbe2ab182818',
    );
    $response = $sdk->webhooksV1->deactivateConfig($request);

    if ($response->configResponse !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
$request Operations\DeactivateConfigRequest ✔️ The request object to use for the request.

Response

?Operations\DeactivateConfigResponse

Errors

Error Object Status Code Content Type
Errors\WebhooksErrorResponse default application/json
formance\stack\Models\Errors.SDKException 4xx-5xx /

deleteConfig

Delete a webhooks config by ID.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use formance\stack;
use formance\stack\Models\Operations;
use formance\stack\Models\Shared;

$security = new Shared\Security(
    authorization: "<YOUR_AUTHORIZATION_HERE>",
);

$sdk = stack\SDK::builder()->setSecurity($security)->build();

try {
    $request = new Operations\DeleteConfigRequest(
        id: '4997257d-dfb6-445b-929c-cbe2ab182818',
    );
    $response = $sdk->webhooksV1->deleteConfig($request);

    if ($response->statusCode === 200) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
$request Operations\DeleteConfigRequest ✔️ The request object to use for the request.

Response

?Operations\DeleteConfigResponse

Errors

Error Object Status Code Content Type
Errors\WebhooksErrorResponse default application/json
formance\stack\Models\Errors.SDKException 4xx-5xx /

getManyConfigs

Sorted by updated date descending

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use formance\stack;
use formance\stack\Models\Operations;
use formance\stack\Models\Shared;

$security = new Shared\Security(
    authorization: "<YOUR_AUTHORIZATION_HERE>",
);

$sdk = stack\SDK::builder()->setSecurity($security)->build();

try {
    $request = new Operations\GetManyConfigsRequest(
        endpoint: 'https://example.com',
        id: '4997257d-dfb6-445b-929c-cbe2ab182818',
    );
    $response = $sdk->webhooksV1->getManyConfigs($request);

    if ($response->configsResponse !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
$request Operations\GetManyConfigsRequest ✔️ The request object to use for the request.

Response

?Operations\GetManyConfigsResponse

Errors

Error Object Status Code Content Type
Errors\WebhooksErrorResponse default application/json
formance\stack\Models\Errors.SDKException 4xx-5xx /

insertConfig

Insert a new webhooks config.

The endpoint should be a valid https URL and be unique.

The secret is the endpoint's verification secret. If not passed or empty, a secret is automatically generated. The format is a random string of bytes of size 24, base64 encoded. (larger size after encoding)

All eventTypes are converted to lower-case when inserted.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use formance\stack;
use formance\stack\Models\Shared;

$security = new Shared\Security(
    authorization: "<YOUR_AUTHORIZATION_HERE>",
);

$sdk = stack\SDK::builder()->setSecurity($security)->build();

try {
    $request = new Shared\ConfigUser(
        endpoint: 'https://example.com',
        eventTypes: [
            'TYPE1',
            'TYPE2',
        ],
        name: 'customer_payment',
        secret: 'V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3',
    );
    $response = $sdk->webhooksV1->insertConfig($request);

    if ($response->configResponse !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
$request Shared\ConfigUser ✔️ The request object to use for the request.

Response

?Operations\InsertConfigResponse

Errors

Error Object Status Code Content Type
Errors\WebhooksErrorResponse default application/json
formance\stack\Models\Errors.SDKException 4xx-5xx /

testConfig

Test a config by sending a webhook to its endpoint.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use formance\stack;
use formance\stack\Models\Operations;
use formance\stack\Models\Shared;

$security = new Shared\Security(
    authorization: "<YOUR_AUTHORIZATION_HERE>",
);

$sdk = stack\SDK::builder()->setSecurity($security)->build();

try {
    $request = new Operations\TestConfigRequest(
        id: '4997257d-dfb6-445b-929c-cbe2ab182818',
    );
    $response = $sdk->webhooksV1->testConfig($request);

    if ($response->attemptResponse !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description
$request Operations\TestConfigRequest ✔️ The request object to use for the request.

Response

?Operations\TestConfigResponse

Errors

Error Object Status Code Content Type
Errors\WebhooksErrorResponse default application/json
formance\stack\Models\Errors.SDKException 4xx-5xx /