Files
kulakpos_web/vendor/kreait/firebase-php/src/Firebase/DynamicLink/ApiClient.php
eko54r b5e3a778ce
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
allow vendord
2026-03-30 14:54:57 +07:00

71 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Kreait\Firebase\DynamicLink;
use Beste\Json;
use GuzzleHttp\ClientInterface;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use const JSON_FORCE_OBJECT;
/**
* @internal
*/
final class ApiClient
{
public function __construct(
private readonly ClientInterface $client,
private readonly RequestFactoryInterface $requestFactory,
private readonly StreamFactoryInterface $streamFactory,
) {
}
public function createDynamicLinkRequest(CreateDynamicLink $action): RequestInterface
{
return $this->requestFactory
->createRequest('POST', 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks')
->withBody($this->streamFactory->createStream(Json::encode($action, JSON_FORCE_OBJECT)))
->withHeader('Content-Type', 'application/json; charset=UTF-8')
;
}
public function createStatisticsRequest(GetStatisticsForDynamicLink $action): RequestInterface
{
$url = sprintf(
'https://firebasedynamiclinks.googleapis.com/v1/%s/linkStats?durationDays=%d',
rawurlencode($action->dynamicLink()),
$action->durationInDays(),
);
return $this->requestFactory
->createRequest('GET', $url)
->withHeader('Content-Type', 'application/json; charset=UTF-8')
;
}
public function createShortenLinkRequest(ShortenLongDynamicLink $action): RequestInterface
{
return $this->requestFactory
->createRequest('POST', 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks')
->withBody($this->streamFactory->createStream(Json::encode($action, JSON_FORCE_OBJECT)))
->withHeader('Content-Type', 'application/json; charset=UTF-8')
;
}
/**
* @param array<string, mixed> $options
*
* @throws ClientExceptionInterface
*/
public function send(RequestInterface $request, array $options = []): ResponseInterface
{
return $this->client->send($request, $options);
}
}