Something went wrong. Try again.
Laravel AT Protocol Client (alpha & unstable)
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239<?php
namespace SocialDept\AtpClient\Client\Requests\Chat;
use SocialDept\AtpClient\Attributes\ScopedEndpoint;use SocialDept\AtpClient\Client\Requests\Request;use SocialDept\AtpClient\Data\Responses\Chat\Convo\GetLogResponse;use SocialDept\AtpClient\Data\Responses\Chat\Convo\GetMessagesResponse;use SocialDept\AtpClient\Data\Responses\Chat\Convo\LeaveConvoResponse;use SocialDept\AtpClient\Data\Responses\Chat\Convo\ListConvosResponse;use SocialDept\AtpClient\Data\Responses\Chat\Convo\SendMessageBatchResponse;use SocialDept\AtpClient\Enums\Nsid\ChatConvo;use SocialDept\AtpClient\Enums\Scope;use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\ConvoView;use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\DeletedMessageView;use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\MessageView;
class ConvoRequestClient extends Request{ /** * Get conversation * * @requires transition:chat.bsky (rpc:chat.bsky.convo.getConvo) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-get-convo */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.getConvo')] public function getConvo(string $convoId): ConvoView { $response = $this->atp->client->get( endpoint: ChatConvo::GetConvo, params: compact('convoId') );
return ConvoView::fromArray($response->json()['convo']); }
/** * Get conversation for members * * @requires transition:chat.bsky (rpc:chat.bsky.convo.getConvoForMembers) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-get-convo-for-members */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.getConvoForMembers')] public function getConvoForMembers(array $members): ConvoView { $response = $this->atp->client->get( endpoint: ChatConvo::GetConvoForMembers, params: compact('members') );
return ConvoView::fromArray($response->json()['convo']); }
/** * List conversations * * @requires transition:chat.bsky (rpc:chat.bsky.convo.listConvos) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-list-convos */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.listConvos')] public function listConvos(int $limit = 50, ?string $cursor = null): ListConvosResponse { $response = $this->atp->client->get( endpoint: ChatConvo::ListConvos, params: compact('limit', 'cursor') );
return ListConvosResponse::fromArray($response->json()); }
/** * Get messages * * @requires transition:chat.bsky (rpc:chat.bsky.convo.getMessages) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-get-messages */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.getMessages')] public function getMessages( string $convoId, int $limit = 50, ?string $cursor = null ): GetMessagesResponse { $response = $this->atp->client->get( endpoint: ChatConvo::GetMessages, params: compact('convoId', 'limit', 'cursor') );
return GetMessagesResponse::fromArray($response->json()); }
/** * Send message * * @requires transition:chat.bsky (rpc:chat.bsky.convo.sendMessage) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-send-message */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.sendMessage')] public function sendMessage(string $convoId, array $message): MessageView { $response = $this->atp->client->post( endpoint: ChatConvo::SendMessage, body: compact('convoId', 'message') );
return MessageView::fromArray($response->json()); }
/** * Send message batch * * @requires transition:chat.bsky (rpc:chat.bsky.convo.sendMessageBatch) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-send-message-batch */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.sendMessageBatch')] public function sendMessageBatch(array $items): SendMessageBatchResponse { $response = $this->atp->client->post( endpoint: ChatConvo::SendMessageBatch, body: compact('items') );
return SendMessageBatchResponse::fromArray($response->json()); }
/** * Delete message for self * * @requires transition:chat.bsky (rpc:chat.bsky.convo.deleteMessageForSelf) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-delete-message-for-self */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.deleteMessageForSelf')] public function deleteMessageForSelf(string $convoId, string $messageId): DeletedMessageView { $response = $this->atp->client->post( endpoint: ChatConvo::DeleteMessageForSelf, body: compact('convoId', 'messageId') );
return DeletedMessageView::fromArray($response->json()); }
/** * Update read status * * @requires transition:chat.bsky (rpc:chat.bsky.convo.updateRead) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-update-read */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.updateRead')] public function updateRead(string $convoId, ?string $messageId = null): ConvoView { $response = $this->atp->client->post( endpoint: ChatConvo::UpdateRead, body: compact('convoId', 'messageId') );
return ConvoView::fromArray($response->json()['convo']); }
/** * Mute conversation * * @requires transition:chat.bsky (rpc:chat.bsky.convo.muteConvo) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-mute-convo */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.muteConvo')] public function muteConvo(string $convoId): ConvoView { $response = $this->atp->client->post( endpoint: ChatConvo::MuteConvo, body: compact('convoId') );
return ConvoView::fromArray($response->json()['convo']); }
/** * Unmute conversation * * @requires transition:chat.bsky (rpc:chat.bsky.convo.unmuteConvo) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-unmute-convo */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.unmuteConvo')] public function unmuteConvo(string $convoId): ConvoView { $response = $this->atp->client->post( endpoint: ChatConvo::UnmuteConvo, body: compact('convoId') );
return ConvoView::fromArray($response->json()['convo']); }
/** * Leave conversation * * @requires transition:chat.bsky (rpc:chat.bsky.convo.leaveConvo) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-leave-convo */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.leaveConvo')] public function leaveConvo(string $convoId): LeaveConvoResponse { $response = $this->atp->client->post( endpoint: ChatConvo::LeaveConvo, body: compact('convoId') );
return LeaveConvoResponse::fromArray($response->json()); }
/** * Get log * * @requires transition:chat.bsky (rpc:chat.bsky.convo.getLog) * * @see https://docs.bsky.app/docs/api/chat-bsky-convo-get-log */ #[ScopedEndpoint(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.getLog')] public function getLog(?string $cursor = null): GetLogResponse { $response = $this->atp->client->get( endpoint: ChatConvo::GetLog, params: compact('cursor') );
return GetLogResponse::fromArray($response->json()); }}