Laravel AT Protocol Client (alpha & unstable)
at dev 3.0 kB view raw
1<?php 2 3namespace SocialDept\AtpClient\Client\Requests\Bsky; 4 5use SocialDept\AtpClient\Attributes\PublicEndpoint; 6use SocialDept\AtpClient\Client\Requests\Request; 7use SocialDept\AtpClient\Data\Responses\Bsky\Actor\GetProfilesResponse; 8use SocialDept\AtpClient\Data\Responses\Bsky\Actor\GetSuggestionsResponse; 9use SocialDept\AtpClient\Data\Responses\Bsky\Actor\SearchActorsResponse; 10use SocialDept\AtpClient\Data\Responses\Bsky\Actor\SearchActorsTypeaheadResponse; 11use SocialDept\AtpClient\Enums\Nsid\BskyActor; 12use SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs\ProfileViewDetailed; 13 14class ActorRequestClient extends Request 15{ 16 /** 17 * Get actor profile 18 * 19 * @see https://docs.bsky.app/docs/api/app-bsky-actor-get-profile 20 */ 21 #[PublicEndpoint] 22 public function getProfile(string $actor): ProfileViewDetailed 23 { 24 $response = $this->atp->client->get( 25 endpoint: BskyActor::GetProfile, 26 params: compact('actor') 27 ); 28 29 return ProfileViewDetailed::fromArray($response->toArray()); 30 } 31 32 /** 33 * Get multiple actor profiles 34 * 35 * @see https://docs.bsky.app/docs/api/app-bsky-actor-get-profiles 36 */ 37 #[PublicEndpoint] 38 public function getProfiles(array $actors): GetProfilesResponse 39 { 40 $response = $this->atp->client->get( 41 endpoint: BskyActor::GetProfiles, 42 params: compact('actors') 43 ); 44 45 return GetProfilesResponse::fromArray($response->json()); 46 } 47 48 /** 49 * Get suggestions for actors to follow 50 * 51 * @see https://docs.bsky.app/docs/api/app-bsky-actor-get-suggestions 52 */ 53 #[PublicEndpoint] 54 public function getSuggestions(int $limit = 50, ?string $cursor = null): GetSuggestionsResponse 55 { 56 $response = $this->atp->client->get( 57 endpoint: BskyActor::GetSuggestions, 58 params: compact('limit', 'cursor') 59 ); 60 61 return GetSuggestionsResponse::fromArray($response->json()); 62 } 63 64 /** 65 * Search for actors 66 * 67 * @see https://docs.bsky.app/docs/api/app-bsky-actor-search-actors 68 */ 69 #[PublicEndpoint] 70 public function searchActors(string $q, int $limit = 25, ?string $cursor = null): SearchActorsResponse 71 { 72 $response = $this->atp->client->get( 73 endpoint: BskyActor::SearchActors, 74 params: compact('q', 'limit', 'cursor') 75 ); 76 77 return SearchActorsResponse::fromArray($response->json()); 78 } 79 80 /** 81 * Search for actors matching a prefix (typeahead/autocomplete) 82 * 83 * @see https://docs.bsky.app/docs/api/app-bsky-actor-search-actors-typeahead 84 */ 85 #[PublicEndpoint] 86 public function searchActorsTypeahead(string $q, int $limit = 10): SearchActorsTypeaheadResponse 87 { 88 $response = $this->atp->client->get( 89 endpoint: BskyActor::SearchActorsTypeahead, 90 params: compact('q', 'limit') 91 ); 92 93 return SearchActorsTypeaheadResponse::fromArray($response->json()); 94 } 95}