Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182<?php
declare(strict_types=1);
namespace Wotnak\Atproto;
use Psr\Http\Message\StreamInterface;use Wotnak\Atproto\Client\RawXrpcResponse;use Wotnak\Atproto\Client\XrpcClient;use Wotnak\Atproto\Client\XrpcOptions;use Wotnak\Atproto\Client\XrpcResponse;use Wotnak\Atproto\Identity\DidResolver;use Wotnak\Atproto\Identity\HandleResolver;use Wotnak\Atproto\Lexicon\LexiconRepositoryInterface;
/** * Convenience facade for XRPC execution and identity resolution. * * @api */final class AtprotoClient implements AtprotoClientInterface {
public function __construct( private readonly XrpcClient $xrpc, private readonly HandleResolver $handles, private readonly DidResolver $dids, ) {}
/** * Sends a GET XRPC request and returns decoded data. * * @param array<string, mixed> $query * * @return array<string, mixed> */ public function get(string $method, array $query = [], ?XrpcOptions $options = NULL): array { return $this->xrpc->get($method, $query, $options); }
/** * Sends a POST XRPC request and returns decoded data. * * @param array<string, mixed> $payload * * @return array<string, mixed> */ public function post(string $method, array $payload = [], ?XrpcOptions $options = NULL): array { return $this->xrpc->post($method, $payload, $options); }
/** * Sends a POST XRPC request with a caller-provided raw body. * * @return array<string, mixed> */ public function postRaw( string $method, string|StreamInterface $body, string $contentType = 'application/octet-stream', ?XrpcOptions $options = NULL, ): array { return $this->xrpc->postRaw($method, $body, $contentType, $options); }
/** * Sends an XRPC request and returns decoded data with response metadata. * * @param array<string, mixed> $data */ public function request( string $httpMethod, string $method, array $data = [], ?XrpcOptions $options = NULL, ): XrpcResponse { return $this->xrpc->request($httpMethod, $method, $data, $options); }
/** * Sends an XRPC request without a body. * * @param array<string, mixed> $query */ public function requestWithoutBody( string $httpMethod, string $method, array $query = [], ?XrpcOptions $options = NULL, ): XrpcResponse { return $this->xrpc->requestWithoutBody($httpMethod, $method, $query, $options); }
/** * Sends an XRPC request with a caller-provided raw body. * * @param array<string, mixed> $query */ public function requestWithBody( string $httpMethod, string $method, string|StreamInterface $body, string $contentType = 'application/octet-stream', array $query = [], ?XrpcOptions $options = NULL, ): XrpcResponse { return $this->xrpc->requestWithBody($httpMethod, $method, $body, $contentType, $query, $options); }
/** * Sends an XRPC request and returns the raw response body. * * @param array<string, mixed> $data */ public function requestRaw( string $httpMethod, string $method, array $data = [], ?XrpcOptions $options = NULL, ): RawXrpcResponse { return $this->xrpc->requestRaw($httpMethod, $method, $data, $options); }
/** * Sends an XRPC request without a body and returns the raw response body. * * @param array<string, mixed> $query */ public function requestRawWithoutBody( string $httpMethod, string $method, array $query = [], ?XrpcOptions $options = NULL, ): RawXrpcResponse { return $this->xrpc->requestRawWithoutBody($httpMethod, $method, $query, $options); }
/** * Sends an XRPC request with a raw body and returns the raw response body. * * @param array<string, mixed> $query */ public function requestRawWithBody( string $httpMethod, string $method, string|StreamInterface $body, string $contentType = 'application/octet-stream', array $query = [], ?XrpcOptions $options = NULL, ): RawXrpcResponse { return $this->xrpc->requestRawWithBody($httpMethod, $method, $body, $contentType, $query, $options); }
/** * Returns the default service url. */ public function getDefaultServiceUrl(): ?string { return $this->xrpc->getDefaultServiceUrl(); }
/** * Creates a Lexicon-aware XRPC client for the repository. */ public function lexicons(LexiconRepositoryInterface $repository): LexiconXrpcClient { return new LexiconXrpcClient($this->xrpc, new \Wotnak\Atproto\Lexicon\SchemaCompiler($repository)); }
/** * Returns the configured handle resolver. */ public function handles(): HandleResolver { return $this->handles; }
/** * Returns the configured DID resolver. */ public function dids(): DidResolver { return $this->dids; }
}