allow vendord
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

This commit is contained in:
2026-03-30 14:54:57 +07:00
parent 66aed7c4e8
commit b5e3a778ce
21316 changed files with 2777892 additions and 13 deletions

View File

@@ -0,0 +1,70 @@
<?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);
}
}