Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update Chat clients to return typed responses

+59 -28
+3 -3
src/Client/Requests/Chat/ActorRequestClient.php
··· 25 25 } 26 26 27 27 /** 28 - * Export account data 28 + * Export account data (returns JSONL stream) 29 29 * 30 30 * @requires transition:chat.bsky (rpc:chat.bsky.actor.exportAccountData) 31 31 * ··· 47 47 * @see https://docs.bsky.app/docs/api/chat-bsky-actor-delete-account 48 48 */ 49 49 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.actor.deleteAccount')] 50 - public function deleteAccount(): Response 50 + public function deleteAccount(): void 51 51 { 52 - return $this->atp->client->post( 52 + $this->atp->client->post( 53 53 endpoint: 'chat.bsky.actor.deleteAccount' 54 54 ); 55 55 }
+56 -25
src/Client/Requests/Chat/ConvoRequestClient.php
··· 4 4 5 5 use SocialDept\AtpClient\Attributes\RequiresScope; 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 + use SocialDept\AtpClient\Data\Responses\Chat\Convo\GetLogResponse; 8 + use SocialDept\AtpClient\Data\Responses\Chat\Convo\GetMessagesResponse; 9 + use SocialDept\AtpClient\Data\Responses\Chat\Convo\LeaveConvoResponse; 10 + use SocialDept\AtpClient\Data\Responses\Chat\Convo\ListConvosResponse; 11 + use SocialDept\AtpClient\Data\Responses\Chat\Convo\SendMessageBatchResponse; 7 12 use SocialDept\AtpClient\Enums\Scope; 8 - use SocialDept\AtpClient\Http\Response; 13 + use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\ConvoView; 14 + use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\DeletedMessageView; 15 + use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\MessageView; 9 16 10 17 class ConvoRequestClient extends Request 11 18 { ··· 17 24 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-get-convo 18 25 */ 19 26 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.getConvo')] 20 - public function getConvo(string $convoId): Response 27 + public function getConvo(string $convoId): ConvoView 21 28 { 22 - return $this->atp->client->get( 29 + $response = $this->atp->client->get( 23 30 endpoint: 'chat.bsky.convo.getConvo', 24 31 params: compact('convoId') 25 32 ); 33 + 34 + return ConvoView::fromArray($response->json()['convo']); 26 35 } 27 36 28 37 /** ··· 33 42 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-get-convo-for-members 34 43 */ 35 44 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.getConvoForMembers')] 36 - public function getConvoForMembers(array $members): Response 45 + public function getConvoForMembers(array $members): ConvoView 37 46 { 38 - return $this->atp->client->get( 47 + $response = $this->atp->client->get( 39 48 endpoint: 'chat.bsky.convo.getConvoForMembers', 40 49 params: compact('members') 41 50 ); 51 + 52 + return ConvoView::fromArray($response->json()['convo']); 42 53 } 43 54 44 55 /** ··· 49 60 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-list-convos 50 61 */ 51 62 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.listConvos')] 52 - public function listConvos(int $limit = 50, ?string $cursor = null): Response 63 + public function listConvos(int $limit = 50, ?string $cursor = null): ListConvosResponse 53 64 { 54 - return $this->atp->client->get( 65 + $response = $this->atp->client->get( 55 66 endpoint: 'chat.bsky.convo.listConvos', 56 67 params: compact('limit', 'cursor') 57 68 ); 69 + 70 + return ListConvosResponse::fromArray($response->json()); 58 71 } 59 72 60 73 /** ··· 69 82 string $convoId, 70 83 int $limit = 50, 71 84 ?string $cursor = null 72 - ): Response { 73 - return $this->atp->client->get( 85 + ): GetMessagesResponse { 86 + $response = $this->atp->client->get( 74 87 endpoint: 'chat.bsky.convo.getMessages', 75 88 params: compact('convoId', 'limit', 'cursor') 76 89 ); 90 + 91 + return GetMessagesResponse::fromArray($response->json()); 77 92 } 78 93 79 94 /** ··· 84 99 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-send-message 85 100 */ 86 101 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.sendMessage')] 87 - public function sendMessage(string $convoId, array $message): Response 102 + public function sendMessage(string $convoId, array $message): MessageView 88 103 { 89 - return $this->atp->client->post( 104 + $response = $this->atp->client->post( 90 105 endpoint: 'chat.bsky.convo.sendMessage', 91 106 body: compact('convoId', 'message') 92 107 ); 108 + 109 + return MessageView::fromArray($response->json()); 93 110 } 94 111 95 112 /** ··· 100 117 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-send-message-batch 101 118 */ 102 119 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.sendMessageBatch')] 103 - public function sendMessageBatch(array $items): Response 120 + public function sendMessageBatch(array $items): SendMessageBatchResponse 104 121 { 105 - return $this->atp->client->post( 122 + $response = $this->atp->client->post( 106 123 endpoint: 'chat.bsky.convo.sendMessageBatch', 107 124 body: compact('items') 108 125 ); 126 + 127 + return SendMessageBatchResponse::fromArray($response->json()); 109 128 } 110 129 111 130 /** ··· 116 135 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-delete-message-for-self 117 136 */ 118 137 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.deleteMessageForSelf')] 119 - public function deleteMessageForSelf(string $convoId, string $messageId): Response 138 + public function deleteMessageForSelf(string $convoId, string $messageId): DeletedMessageView 120 139 { 121 - return $this->atp->client->post( 140 + $response = $this->atp->client->post( 122 141 endpoint: 'chat.bsky.convo.deleteMessageForSelf', 123 142 body: compact('convoId', 'messageId') 124 143 ); 144 + 145 + return DeletedMessageView::fromArray($response->json()); 125 146 } 126 147 127 148 /** ··· 132 153 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-update-read 133 154 */ 134 155 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.updateRead')] 135 - public function updateRead(string $convoId, ?string $messageId = null): Response 156 + public function updateRead(string $convoId, ?string $messageId = null): ConvoView 136 157 { 137 - return $this->atp->client->post( 158 + $response = $this->atp->client->post( 138 159 endpoint: 'chat.bsky.convo.updateRead', 139 160 body: compact('convoId', 'messageId') 140 161 ); 162 + 163 + return ConvoView::fromArray($response->json()['convo']); 141 164 } 142 165 143 166 /** ··· 148 171 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-mute-convo 149 172 */ 150 173 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.muteConvo')] 151 - public function muteConvo(string $convoId): Response 174 + public function muteConvo(string $convoId): ConvoView 152 175 { 153 - return $this->atp->client->post( 176 + $response = $this->atp->client->post( 154 177 endpoint: 'chat.bsky.convo.muteConvo', 155 178 body: compact('convoId') 156 179 ); 180 + 181 + return ConvoView::fromArray($response->json()['convo']); 157 182 } 158 183 159 184 /** ··· 164 189 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-unmute-convo 165 190 */ 166 191 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.unmuteConvo')] 167 - public function unmuteConvo(string $convoId): Response 192 + public function unmuteConvo(string $convoId): ConvoView 168 193 { 169 - return $this->atp->client->post( 194 + $response = $this->atp->client->post( 170 195 endpoint: 'chat.bsky.convo.unmuteConvo', 171 196 body: compact('convoId') 172 197 ); 198 + 199 + return ConvoView::fromArray($response->json()['convo']); 173 200 } 174 201 175 202 /** ··· 180 207 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-leave-convo 181 208 */ 182 209 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.leaveConvo')] 183 - public function leaveConvo(string $convoId): Response 210 + public function leaveConvo(string $convoId): LeaveConvoResponse 184 211 { 185 - return $this->atp->client->post( 212 + $response = $this->atp->client->post( 186 213 endpoint: 'chat.bsky.convo.leaveConvo', 187 214 body: compact('convoId') 188 215 ); 216 + 217 + return LeaveConvoResponse::fromArray($response->json()); 189 218 } 190 219 191 220 /** ··· 196 225 * @see https://docs.bsky.app/docs/api/chat-bsky-convo-get-log 197 226 */ 198 227 #[RequiresScope(Scope::TransitionChat, granular: 'rpc:chat.bsky.convo.getLog')] 199 - public function getLog(?string $cursor = null): Response 228 + public function getLog(?string $cursor = null): GetLogResponse 200 229 { 201 - return $this->atp->client->get( 230 + $response = $this->atp->client->get( 202 231 endpoint: 'chat.bsky.convo.getLog', 203 232 params: compact('cursor') 204 233 ); 234 + 235 + return GetLogResponse::fromArray($response->json()); 205 236 } 206 237 }