first commit

This commit is contained in:
2026-01-14 16:40:33 +03:00
commit f803480f7b
184 changed files with 5573 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace Gemini\AlfaBank\Requests\Webhooks;
use Gemini\AlfaBank\Data\WebhookData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
use Saloon\Contracts\Body\HasBody;
class CreateWebhookRequest extends Request implements HasBody
{
use HasJsonBody;
protected Method $method = Method::POST;
public function __construct(
protected string $object,
protected string $callbackUri,
protected ?array $accounts = null,
protected int $version = 1
) {}
public function resolveEndpoint(): string
{
return '/api/v1/webhooks';
}
protected function defaultBody(): array
{
$body = [
'object' => $this->object,
'callbackUri' => $this->callbackUri,
'version' => $this->version,
];
if ($this->accounts !== null) {
$body['data'] = ['accounts' => $this->accounts];
}
return $body;
}
public function createDtoFromResponse(Response $response): WebhookData
{
return WebhookData::from($response->json());
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Gemini\AlfaBank\Requests\Webhooks;
use Saloon\Enums\Method;
use Saloon\Http\Request;
class DeleteWebhookRequest extends Request
{
protected Method $method = Method::DELETE;
public function __construct(
protected string $id,
protected string $object
) {}
public function resolveEndpoint(): string
{
return "/api/v1/webhooks/{$this->id}";
}
protected function defaultQuery(): array
{
return [
'object' => $this->object,
];
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Gemini\AlfaBank\Requests\Webhooks;
use Gemini\AlfaBank\Data\WebhookCollectionData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
class GetWebhooksRequest extends Request
{
protected Method $method = Method::GET;
public function __construct(
protected ?int $offset = 0,
protected ?int $limit = 20,
protected ?string $object = null
) {}
public function resolveEndpoint(): string
{
return '/api/v2/webhooks';
}
protected function defaultQuery(): array
{
return array_filter([
'offset' => $this->offset,
'limit' => $this->limit,
'object' => $this->object,
]);
}
public function createDtoFromResponse(Response $response): WebhookCollectionData
{
return WebhookCollectionData::from($response->json());
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace Gemini\AlfaBank\Requests\Webhooks;
use Gemini\AlfaBank\Data\WebhookData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
use Saloon\Contracts\Body\HasBody;
class UpdateWebhookRequest extends Request implements HasBody
{
use HasJsonBody;
protected Method $method = Method::PUT;
public function __construct(
protected string $id,
protected string $object,
protected bool $enabled = true,
protected ?string $callbackUri = null,
protected ?array $accounts = null,
protected int $version = 1
) {}
public function resolveEndpoint(): string
{
return "/api/v2/webhooks/{$this->id}";
}
protected function defaultBody(): array
{
$body = [
'object' => $this->object,
'enabled' => $this->enabled,
'version' => $this->version,
];
if ($this->callbackUri !== null) {
$body['callbackUri'] = $this->callbackUri;
}
if ($this->accounts !== null) {
$body['data'] = ['accounts' => $this->accounts];
}
return $body;
}
public function createDtoFromResponse(Response $response): WebhookData
{
return WebhookData::from($response->json());
}
}