Laravel AT Protocol Client (alpha & unstable)

Merge public client methods into main request clients

Changed files
+233 -40
src
+64 -5
src/Client/Requests/Bsky/ActorRequestClient.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Client\Requests\Bsky; 4 4 5 - use SocialDept\AtpClient\Attributes\RequiresScope; 6 5 use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Data\Responses\Bsky\Actor\GetProfilesResponse; 7 + use SocialDept\AtpClient\Data\Responses\Bsky\Actor\GetSuggestionsResponse; 8 + use SocialDept\AtpClient\Data\Responses\Bsky\Actor\SearchActorsResponse; 9 + use SocialDept\AtpClient\Data\Responses\Bsky\Actor\SearchActorsTypeaheadResponse; 7 10 use SocialDept\AtpClient\Enums\Nsid\BskyActor; 8 - use SocialDept\AtpClient\Enums\Scope; 9 11 use SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs\ProfileViewDetailed; 10 12 11 13 class ActorRequestClient extends Request ··· 13 15 /** 14 16 * Get actor profile 15 17 * 16 - * @requires transition:generic (rpc:app.bsky.actor.getProfile) 17 - * 18 18 * @see https://docs.bsky.app/docs/api/app-bsky-actor-get-profile 19 19 */ 20 - #[RequiresScope(Scope::TransitionGeneric, granular: 'rpc:app.bsky.actor.getProfile')] 21 20 public function getProfile(string $actor): ProfileViewDetailed 22 21 { 23 22 $response = $this->atp->client->get( ··· 26 25 ); 27 26 28 27 return ProfileViewDetailed::fromArray($response->json()); 28 + } 29 + 30 + /** 31 + * Get multiple actor profiles 32 + * 33 + * @see https://docs.bsky.app/docs/api/app-bsky-actor-get-profiles 34 + */ 35 + public function getProfiles(array $actors): GetProfilesResponse 36 + { 37 + $response = $this->atp->client->get( 38 + endpoint: BskyActor::GetProfiles, 39 + params: compact('actors') 40 + ); 41 + 42 + return GetProfilesResponse::fromArray($response->json()); 43 + } 44 + 45 + /** 46 + * Get suggestions for actors to follow 47 + * 48 + * @see https://docs.bsky.app/docs/api/app-bsky-actor-get-suggestions 49 + */ 50 + public function getSuggestions(int $limit = 50, ?string $cursor = null): GetSuggestionsResponse 51 + { 52 + $response = $this->atp->client->get( 53 + endpoint: BskyActor::GetSuggestions, 54 + params: compact('limit', 'cursor') 55 + ); 56 + 57 + return GetSuggestionsResponse::fromArray($response->json()); 58 + } 59 + 60 + /** 61 + * Search for actors 62 + * 63 + * @see https://docs.bsky.app/docs/api/app-bsky-actor-search-actors 64 + */ 65 + public function searchActors(string $q, int $limit = 25, ?string $cursor = null): SearchActorsResponse 66 + { 67 + $response = $this->atp->client->get( 68 + endpoint: BskyActor::SearchActors, 69 + params: compact('q', 'limit', 'cursor') 70 + ); 71 + 72 + return SearchActorsResponse::fromArray($response->json()); 73 + } 74 + 75 + /** 76 + * Search for actors matching a prefix (typeahead/autocomplete) 77 + * 78 + * @see https://docs.bsky.app/docs/api/app-bsky-actor-search-actors-typeahead 79 + */ 80 + public function searchActorsTypeahead(string $q, int $limit = 10): SearchActorsTypeaheadResponse 81 + { 82 + $response = $this->atp->client->get( 83 + endpoint: BskyActor::SearchActorsTypeahead, 84 + params: compact('q', 'limit') 85 + ); 86 + 87 + return SearchActorsTypeaheadResponse::fromArray($response->json()); 29 88 } 30 89 }
+169 -35
src/Client/Requests/Bsky/FeedRequestClient.php
··· 4 4 5 5 use SocialDept\AtpClient\Attributes\RequiresScope; 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\DescribeFeedGeneratorResponse; 8 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetActorFeedsResponse; 9 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetActorLikesResponse; 7 10 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetAuthorFeedResponse; 11 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetFeedGeneratorResponse; 12 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetFeedGeneratorsResponse; 13 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetFeedResponse; 8 14 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetLikesResponse; 15 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetPostsResponse; 9 16 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetPostThreadResponse; 17 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetQuotesResponse; 10 18 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetRepostedByResponse; 19 + use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetSuggestedFeedsResponse; 11 20 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetTimelineResponse; 12 21 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\SearchPostsResponse; 13 22 use SocialDept\AtpClient\Enums\Nsid\BskyFeed; ··· 16 25 class FeedRequestClient extends Request 17 26 { 18 27 /** 19 - * Get timeline feed 28 + * Describe feed generator 20 29 * 21 - * @requires transition:generic (rpc:app.bsky.feed.getTimeline) 30 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-describe-feed-generator 31 + */ 32 + public function describeFeedGenerator(): DescribeFeedGeneratorResponse 33 + { 34 + $response = $this->atp->client->get( 35 + endpoint: BskyFeed::DescribeFeedGenerator 36 + ); 37 + 38 + return DescribeFeedGeneratorResponse::fromArray($response->json()); 39 + } 40 + 41 + /** 42 + * Get timeline feed (requires authentication) 22 43 * 23 44 * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-timeline 24 45 */ ··· 36 57 /** 37 58 * Get author feed 38 59 * 39 - * @requires transition:generic (rpc:app.bsky.feed.getAuthorFeed) 40 - * 41 60 * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-author-feed 42 61 */ 43 - #[RequiresScope(Scope::TransitionGeneric, granular: 'rpc:app.bsky.feed.getAuthorFeed')] 44 62 public function getAuthorFeed( 45 63 string $actor, 46 64 int $limit = 50, 47 - ?string $cursor = null 65 + ?string $cursor = null, 66 + ?string $filter = null 48 67 ): GetAuthorFeedResponse { 49 68 $response = $this->atp->client->get( 50 69 endpoint: BskyFeed::GetAuthorFeed, 51 - params: compact('actor', 'limit', 'cursor') 70 + params: compact('actor', 'limit', 'cursor', 'filter') 52 71 ); 53 72 54 73 return GetAuthorFeedResponse::fromArray($response->json()); 55 74 } 56 75 57 76 /** 58 - * Get post thread 77 + * Get feeds created by an actor 59 78 * 60 - * @requires transition:generic (rpc:app.bsky.feed.getPostThread) 79 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-actor-feeds 80 + */ 81 + public function getActorFeeds(string $actor, int $limit = 50, ?string $cursor = null): GetActorFeedsResponse 82 + { 83 + $response = $this->atp->client->get( 84 + endpoint: BskyFeed::GetActorFeeds, 85 + params: compact('actor', 'limit', 'cursor') 86 + ); 87 + 88 + return GetActorFeedsResponse::fromArray($response->json()); 89 + } 90 + 91 + /** 92 + * Get posts liked by an actor 93 + * 94 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-actor-likes 95 + */ 96 + public function getActorLikes(string $actor, int $limit = 50, ?string $cursor = null): GetActorLikesResponse 97 + { 98 + $response = $this->atp->client->get( 99 + endpoint: BskyFeed::GetActorLikes, 100 + params: compact('actor', 'limit', 'cursor') 101 + ); 102 + 103 + return GetActorLikesResponse::fromArray($response->json()); 104 + } 105 + 106 + /** 107 + * Get a feed 108 + * 109 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-feed 110 + */ 111 + public function getFeed(string $feed, int $limit = 50, ?string $cursor = null): GetFeedResponse 112 + { 113 + $response = $this->atp->client->get( 114 + endpoint: BskyFeed::GetFeed, 115 + params: compact('feed', 'limit', 'cursor') 116 + ); 117 + 118 + return GetFeedResponse::fromArray($response->json()); 119 + } 120 + 121 + /** 122 + * Get a feed generator 123 + * 124 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-feed-generator 125 + */ 126 + public function getFeedGenerator(string $feed): GetFeedGeneratorResponse 127 + { 128 + $response = $this->atp->client->get( 129 + endpoint: BskyFeed::GetFeedGenerator, 130 + params: compact('feed') 131 + ); 132 + 133 + return GetFeedGeneratorResponse::fromArray($response->json()); 134 + } 135 + 136 + /** 137 + * Get multiple feed generators 138 + * 139 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-feed-generators 140 + */ 141 + public function getFeedGenerators(array $feeds): GetFeedGeneratorsResponse 142 + { 143 + $response = $this->atp->client->get( 144 + endpoint: BskyFeed::GetFeedGenerators, 145 + params: compact('feeds') 146 + ); 147 + 148 + return GetFeedGeneratorsResponse::fromArray($response->json()); 149 + } 150 + 151 + /** 152 + * Get post thread 61 153 * 62 154 * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-post-thread 63 155 */ 64 - #[RequiresScope(Scope::TransitionGeneric, granular: 'rpc:app.bsky.feed.getPostThread')] 65 - public function getPostThread(string $uri, int $depth = 6): GetPostThreadResponse 156 + public function getPostThread(string $uri, int $depth = 6, int $parentHeight = 80): GetPostThreadResponse 66 157 { 67 158 $response = $this->atp->client->get( 68 159 endpoint: BskyFeed::GetPostThread, 69 - params: compact('uri', 'depth') 160 + params: compact('uri', 'depth', 'parentHeight') 70 161 ); 71 162 72 163 return GetPostThreadResponse::fromArray($response->json()); 73 164 } 74 165 75 166 /** 76 - * Search posts 167 + * Get multiple posts by URI 77 168 * 78 - * @requires transition:generic (rpc:app.bsky.feed.searchPosts) 79 - * 80 - * @see https://docs.bsky.app/docs/api/app-bsky-feed-search-posts 169 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-posts 81 170 */ 82 - #[RequiresScope(Scope::TransitionGeneric, granular: 'rpc:app.bsky.feed.searchPosts')] 83 - public function searchPosts( 84 - string $q, 85 - int $limit = 25, 86 - ?string $cursor = null 87 - ): SearchPostsResponse { 171 + public function getPosts(array $uris): GetPostsResponse 172 + { 88 173 $response = $this->atp->client->get( 89 - endpoint: BskyFeed::SearchPosts, 90 - params: compact('q', 'limit', 'cursor') 174 + endpoint: BskyFeed::GetPosts, 175 + params: compact('uris') 91 176 ); 92 177 93 - return SearchPostsResponse::fromArray($response->json()); 178 + return GetPostsResponse::fromArray($response->json()); 94 179 } 95 180 96 181 /** 97 182 * Get likes for a post 98 183 * 99 - * @requires transition:generic (rpc:app.bsky.feed.getLikes) 100 - * 101 184 * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-likes 102 185 */ 103 - #[RequiresScope(Scope::TransitionGeneric, granular: 'rpc:app.bsky.feed.getLikes')] 104 186 public function getLikes( 105 187 string $uri, 106 188 int $limit = 50, 107 - ?string $cursor = null 189 + ?string $cursor = null, 190 + ?string $cid = null 108 191 ): GetLikesResponse { 109 192 $response = $this->atp->client->get( 110 193 endpoint: BskyFeed::GetLikes, 111 - params: compact('uri', 'limit', 'cursor') 194 + params: compact('uri', 'limit', 'cursor', 'cid') 112 195 ); 113 196 114 197 return GetLikesResponse::fromArray($response->json()); 115 198 } 116 199 117 200 /** 118 - * Get reposts for a post 201 + * Get quotes of a post 119 202 * 120 - * @requires transition:generic (rpc:app.bsky.feed.getRepostedBy) 203 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-quotes 204 + */ 205 + public function getQuotes( 206 + string $uri, 207 + int $limit = 50, 208 + ?string $cursor = null, 209 + ?string $cid = null 210 + ): GetQuotesResponse { 211 + $response = $this->atp->client->get( 212 + endpoint: BskyFeed::GetQuotes, 213 + params: compact('uri', 'limit', 'cursor', 'cid') 214 + ); 215 + 216 + return GetQuotesResponse::fromArray($response->json()); 217 + } 218 + 219 + /** 220 + * Get reposts for a post 121 221 * 122 222 * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-reposted-by 123 223 */ 124 - #[RequiresScope(Scope::TransitionGeneric, granular: 'rpc:app.bsky.feed.getRepostedBy')] 125 224 public function getRepostedBy( 126 225 string $uri, 127 226 int $limit = 50, 128 - ?string $cursor = null 227 + ?string $cursor = null, 228 + ?string $cid = null 129 229 ): GetRepostedByResponse { 130 230 $response = $this->atp->client->get( 131 231 endpoint: BskyFeed::GetRepostedBy, 132 - params: compact('uri', 'limit', 'cursor') 232 + params: compact('uri', 'limit', 'cursor', 'cid') 133 233 ); 134 234 135 235 return GetRepostedByResponse::fromArray($response->json()); 236 + } 237 + 238 + /** 239 + * Get suggested feeds 240 + * 241 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-get-suggested-feeds 242 + */ 243 + public function getSuggestedFeeds(int $limit = 50, ?string $cursor = null): GetSuggestedFeedsResponse 244 + { 245 + $response = $this->atp->client->get( 246 + endpoint: BskyFeed::GetSuggestedFeeds, 247 + params: compact('limit', 'cursor') 248 + ); 249 + 250 + return GetSuggestedFeedsResponse::fromArray($response->json()); 251 + } 252 + 253 + /** 254 + * Search posts 255 + * 256 + * @see https://docs.bsky.app/docs/api/app-bsky-feed-search-posts 257 + */ 258 + public function searchPosts( 259 + string $q, 260 + int $limit = 25, 261 + ?string $cursor = null, 262 + ?string $sort = null 263 + ): SearchPostsResponse { 264 + $response = $this->atp->client->get( 265 + endpoint: BskyFeed::SearchPosts, 266 + params: compact('q', 'limit', 'cursor', 'sort') 267 + ); 268 + 269 + return SearchPostsResponse::fromArray($response->json()); 136 270 } 137 271 }