Laravel AT Protocol Client (alpha & unstable)
at dev 1.4 kB view raw
1<?php 2 3namespace SocialDept\AtpClient\Client\Requests\Atproto; 4 5use SocialDept\AtpClient\Attributes\PublicEndpoint; 6use SocialDept\AtpClient\Attributes\ScopedEndpoint; 7use SocialDept\AtpClient\Client\Requests\Request; 8use SocialDept\AtpClient\Data\Responses\Atproto\Server\DescribeServerResponse; 9use SocialDept\AtpClient\Data\Responses\Atproto\Server\GetSessionResponse; 10use SocialDept\AtpClient\Enums\Nsid\AtprotoServer; 11use SocialDept\AtpClient\Enums\Scope; 12 13class ServerRequestClient extends Request 14{ 15 /** 16 * Get current session 17 * 18 * @requires atproto (rpc:com.atproto.server.getSession) 19 * 20 * @see https://docs.bsky.app/docs/api/com-atproto-server-get-session 21 */ 22 #[ScopedEndpoint(Scope::Atproto, granular: 'rpc:com.atproto.server.getSession')] 23 public function getSession(): GetSessionResponse 24 { 25 $response = $this->atp->client->get( 26 endpoint: AtprotoServer::GetSession 27 ); 28 29 return GetSessionResponse::fromArray($response->json()); 30 } 31 32 /** 33 * Describe server 34 * 35 * @see https://docs.bsky.app/docs/api/com-atproto-server-describe-server 36 */ 37 #[PublicEndpoint] 38 public function describeServer(): DescribeServerResponse 39 { 40 $response = $this->atp->client->get( 41 endpoint: AtprotoServer::DescribeServer 42 ); 43 44 return DescribeServerResponse::fromArray($response->json()); 45 } 46}