Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

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

Merge branch 'refs/heads/dev'

+486 -116
+3 -1
src/Client/Public/PublicClient.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Client\Public; 4 4 5 + use BackedEnum; 5 6 use Illuminate\Support\Facades\Http; 6 7 use SocialDept\AtpClient\Exceptions\AtpResponseException; 7 8 use SocialDept\AtpClient\Http\Response; ··· 12 13 protected string $serviceUrl 13 14 ) {} 14 15 15 - public function get(string $endpoint, array $params = []): Response 16 + public function get(string|BackedEnum $endpoint, array $params = []): Response 16 17 { 18 + $endpoint = $endpoint instanceof BackedEnum ? $endpoint->value : $endpoint; 17 19 $url = rtrim($this->serviceUrl, '/') . '/xrpc/' . $endpoint; 18 20 $params = array_filter($params, fn ($v) => !is_null($v)); 19 21
+5 -1
src/Client/Public/Requests/Atproto/IdentityPublicRequestClient.php
··· 3 3 namespace SocialDept\AtpClient\Client\Public\Requests\Atproto; 4 4 5 5 use SocialDept\AtpClient\Client\Public\Requests\PublicRequest; 6 + use SocialDept\AtpClient\Enums\Nsid\AtprotoIdentity; 6 7 7 8 class IdentityPublicRequestClient extends PublicRequest 8 9 { 9 10 public function resolveHandle(string $handle): string 10 11 { 11 - $response = $this->atp->client->get('com.atproto.identity.resolveHandle', compact('handle')); 12 + $response = $this->atp->client->get( 13 + endpoint: AtprotoIdentity::ResolveHandle, 14 + params: compact('handle') 15 + ); 12 16 13 17 return $response->json()['did']; 14 18 }
+7 -6
src/Client/Public/Requests/Atproto/RepoPublicRequestClient.php
··· 6 6 use SocialDept\AtpClient\Data\Responses\Atproto\Repo\DescribeRepoResponse; 7 7 use SocialDept\AtpClient\Data\Responses\Atproto\Repo\GetRecordResponse; 8 8 use SocialDept\AtpClient\Data\Responses\Atproto\Repo\ListRecordsResponse; 9 + use SocialDept\AtpClient\Enums\Nsid\AtprotoRepo; 9 10 10 11 class RepoPublicRequestClient extends PublicRequest 11 12 { ··· 21 22 ?string $cid = null 22 23 ): GetRecordResponse { 23 24 $response = $this->atp->client->get( 24 - 'com.atproto.repo.getRecord', 25 - compact('repo', 'collection', 'rkey', 'cid') 25 + endpoint: AtprotoRepo::GetRecord, 26 + params: compact('repo', 'collection', 'rkey', 'cid') 26 27 ); 27 28 28 29 return GetRecordResponse::fromArray($response->json()); ··· 41 42 bool $reverse = false 42 43 ): ListRecordsResponse { 43 44 $response = $this->atp->client->get( 44 - 'com.atproto.repo.listRecords', 45 - compact('repo', 'collection', 'limit', 'cursor', 'reverse') 45 + endpoint: AtprotoRepo::ListRecords, 46 + params: compact('repo', 'collection', 'limit', 'cursor', 'reverse') 46 47 ); 47 48 48 49 return ListRecordsResponse::fromArray($response->json()); ··· 56 57 public function describeRepo(string $repo): DescribeRepoResponse 57 58 { 58 59 $response = $this->atp->client->get( 59 - 'com.atproto.repo.describeRepo', 60 - compact('repo') 60 + endpoint: AtprotoRepo::DescribeRepo, 61 + params: compact('repo') 61 62 ); 62 63 63 64 return DescribeRepoResponse::fromArray($response->json());
+21 -5
src/Client/Public/Requests/Bsky/ActorPublicRequestClient.php
··· 3 3 namespace SocialDept\AtpClient\Client\Public\Requests\Bsky; 4 4 5 5 use SocialDept\AtpClient\Client\Public\Requests\PublicRequest; 6 + use SocialDept\AtpClient\Enums\Nsid\BskyActor; 6 7 use SocialDept\AtpClient\Data\Responses\Bsky\Actor\GetProfilesResponse; 7 8 use SocialDept\AtpClient\Data\Responses\Bsky\Actor\GetSuggestionsResponse; 8 9 use SocialDept\AtpClient\Data\Responses\Bsky\Actor\SearchActorsResponse; ··· 13 14 { 14 15 public function getProfile(string $actor): ProfileViewDetailed 15 16 { 16 - $response = $this->atp->client->get('app.bsky.actor.getProfile', compact('actor')); 17 + $response = $this->atp->client->get( 18 + endpoint: BskyActor::GetProfile, 19 + params: compact('actor') 20 + ); 17 21 18 22 return ProfileViewDetailed::fromArray($response->json()); 19 23 } 20 24 21 25 public function getProfiles(array $actors): GetProfilesResponse 22 26 { 23 - $response = $this->atp->client->get('app.bsky.actor.getProfiles', compact('actors')); 27 + $response = $this->atp->client->get( 28 + endpoint: BskyActor::GetProfiles, 29 + params: compact('actors') 30 + ); 24 31 25 32 return GetProfilesResponse::fromArray($response->json()); 26 33 } 27 34 28 35 public function getSuggestions(int $limit = 50, ?string $cursor = null): GetSuggestionsResponse 29 36 { 30 - $response = $this->atp->client->get('app.bsky.actor.getSuggestions', compact('limit', 'cursor')); 37 + $response = $this->atp->client->get( 38 + endpoint: BskyActor::GetSuggestions, 39 + params: compact('limit', 'cursor') 40 + ); 31 41 32 42 return GetSuggestionsResponse::fromArray($response->json()); 33 43 } 34 44 35 45 public function searchActors(string $q, int $limit = 25, ?string $cursor = null): SearchActorsResponse 36 46 { 37 - $response = $this->atp->client->get('app.bsky.actor.searchActors', compact('q', 'limit', 'cursor')); 47 + $response = $this->atp->client->get( 48 + endpoint: BskyActor::SearchActors, 49 + params: compact('q', 'limit', 'cursor') 50 + ); 38 51 39 52 return SearchActorsResponse::fromArray($response->json()); 40 53 } 41 54 42 55 public function searchActorsTypeahead(string $q, int $limit = 10): SearchActorsTypeaheadResponse 43 56 { 44 - $response = $this->atp->client->get('app.bsky.actor.searchActorsTypeahead', compact('q', 'limit')); 57 + $response = $this->atp->client->get( 58 + endpoint: BskyActor::SearchActorsTypeahead, 59 + params: compact('q', 'limit') 60 + ); 45 61 46 62 return SearchActorsTypeaheadResponse::fromArray($response->json()); 47 63 }
+56 -14
src/Client/Public/Requests/Bsky/FeedPublicRequestClient.php
··· 3 3 namespace SocialDept\AtpClient\Client\Public\Requests\Bsky; 4 4 5 5 use SocialDept\AtpClient\Client\Public\Requests\PublicRequest; 6 + use SocialDept\AtpClient\Enums\Nsid\BskyFeed; 6 7 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\DescribeFeedGeneratorResponse; 7 8 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetActorFeedsResponse; 8 9 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetActorLikesResponse; ··· 22 23 { 23 24 public function describeFeedGenerator(): DescribeFeedGeneratorResponse 24 25 { 25 - $response = $this->atp->client->get('app.bsky.feed.describeFeedGenerator'); 26 + $response = $this->atp->client->get( 27 + endpoint: BskyFeed::DescribeFeedGenerator 28 + ); 26 29 27 30 return DescribeFeedGeneratorResponse::fromArray($response->json()); 28 31 } 29 32 30 33 public function getAuthorFeed(string $actor, int $limit = 50, ?string $cursor = null, ?string $filter = null): GetAuthorFeedResponse 31 34 { 32 - $response = $this->atp->client->get('app.bsky.feed.getAuthorFeed', compact('actor', 'limit', 'cursor', 'filter')); 35 + $response = $this->atp->client->get( 36 + endpoint: BskyFeed::GetAuthorFeed, 37 + params: compact('actor', 'limit', 'cursor', 'filter') 38 + ); 33 39 34 40 return GetAuthorFeedResponse::fromArray($response->json()); 35 41 } 36 42 37 43 public function getActorFeeds(string $actor, int $limit = 50, ?string $cursor = null): GetActorFeedsResponse 38 44 { 39 - $response = $this->atp->client->get('app.bsky.feed.getActorFeeds', compact('actor', 'limit', 'cursor')); 45 + $response = $this->atp->client->get( 46 + endpoint: BskyFeed::GetActorFeeds, 47 + params: compact('actor', 'limit', 'cursor') 48 + ); 40 49 41 50 return GetActorFeedsResponse::fromArray($response->json()); 42 51 } 43 52 44 53 public function getActorLikes(string $actor, int $limit = 50, ?string $cursor = null): GetActorLikesResponse 45 54 { 46 - $response = $this->atp->client->get('app.bsky.feed.getActorLikes', compact('actor', 'limit', 'cursor')); 55 + $response = $this->atp->client->get( 56 + endpoint: BskyFeed::GetActorLikes, 57 + params: compact('actor', 'limit', 'cursor') 58 + ); 47 59 48 60 return GetActorLikesResponse::fromArray($response->json()); 49 61 } 50 62 51 63 public function getFeed(string $feed, int $limit = 50, ?string $cursor = null): GetFeedResponse 52 64 { 53 - $response = $this->atp->client->get('app.bsky.feed.getFeed', compact('feed', 'limit', 'cursor')); 65 + $response = $this->atp->client->get( 66 + endpoint: BskyFeed::GetFeed, 67 + params: compact('feed', 'limit', 'cursor') 68 + ); 54 69 55 70 return GetFeedResponse::fromArray($response->json()); 56 71 } 57 72 58 73 public function getFeedGenerator(string $feed): GetFeedGeneratorResponse 59 74 { 60 - $response = $this->atp->client->get('app.bsky.feed.getFeedGenerator', compact('feed')); 75 + $response = $this->atp->client->get( 76 + endpoint: BskyFeed::GetFeedGenerator, 77 + params: compact('feed') 78 + ); 61 79 62 80 return GetFeedGeneratorResponse::fromArray($response->json()); 63 81 } 64 82 65 83 public function getFeedGenerators(array $feeds): GetFeedGeneratorsResponse 66 84 { 67 - $response = $this->atp->client->get('app.bsky.feed.getFeedGenerators', compact('feeds')); 85 + $response = $this->atp->client->get( 86 + endpoint: BskyFeed::GetFeedGenerators, 87 + params: compact('feeds') 88 + ); 68 89 69 90 return GetFeedGeneratorsResponse::fromArray($response->json()); 70 91 } 71 92 72 93 public function getLikes(string $uri, int $limit = 50, ?string $cursor = null, ?string $cid = null): GetLikesResponse 73 94 { 74 - $response = $this->atp->client->get('app.bsky.feed.getLikes', compact('uri', 'limit', 'cursor', 'cid')); 95 + $response = $this->atp->client->get( 96 + endpoint: BskyFeed::GetLikes, 97 + params: compact('uri', 'limit', 'cursor', 'cid') 98 + ); 75 99 76 100 return GetLikesResponse::fromArray($response->json()); 77 101 } 78 102 79 103 public function getPostThread(string $uri, int $depth = 6, int $parentHeight = 80): GetPostThreadResponse 80 104 { 81 - $response = $this->atp->client->get('app.bsky.feed.getPostThread', compact('uri', 'depth', 'parentHeight')); 105 + $response = $this->atp->client->get( 106 + endpoint: BskyFeed::GetPostThread, 107 + params: compact('uri', 'depth', 'parentHeight') 108 + ); 82 109 83 110 return GetPostThreadResponse::fromArray($response->json()); 84 111 } 85 112 86 113 public function getPosts(array $uris): GetPostsResponse 87 114 { 88 - $response = $this->atp->client->get('app.bsky.feed.getPosts', compact('uris')); 115 + $response = $this->atp->client->get( 116 + endpoint: BskyFeed::GetPosts, 117 + params: compact('uris') 118 + ); 89 119 90 120 return GetPostsResponse::fromArray($response->json()); 91 121 } 92 122 93 123 public function getQuotes(string $uri, int $limit = 50, ?string $cursor = null, ?string $cid = null): GetQuotesResponse 94 124 { 95 - $response = $this->atp->client->get('app.bsky.feed.getQuotes', compact('uri', 'limit', 'cursor', 'cid')); 125 + $response = $this->atp->client->get( 126 + endpoint: BskyFeed::GetQuotes, 127 + params: compact('uri', 'limit', 'cursor', 'cid') 128 + ); 96 129 97 130 return GetQuotesResponse::fromArray($response->json()); 98 131 } 99 132 100 133 public function getRepostedBy(string $uri, int $limit = 50, ?string $cursor = null, ?string $cid = null): GetRepostedByResponse 101 134 { 102 - $response = $this->atp->client->get('app.bsky.feed.getRepostedBy', compact('uri', 'limit', 'cursor', 'cid')); 135 + $response = $this->atp->client->get( 136 + endpoint: BskyFeed::GetRepostedBy, 137 + params: compact('uri', 'limit', 'cursor', 'cid') 138 + ); 103 139 104 140 return GetRepostedByResponse::fromArray($response->json()); 105 141 } 106 142 107 143 public function getSuggestedFeeds(int $limit = 50, ?string $cursor = null): GetSuggestedFeedsResponse 108 144 { 109 - $response = $this->atp->client->get('app.bsky.feed.getSuggestedFeeds', compact('limit', 'cursor')); 145 + $response = $this->atp->client->get( 146 + endpoint: BskyFeed::GetSuggestedFeeds, 147 + params: compact('limit', 'cursor') 148 + ); 110 149 111 150 return GetSuggestedFeedsResponse::fromArray($response->json()); 112 151 } 113 152 114 153 public function searchPosts(string $q, int $limit = 25, ?string $cursor = null, ?string $sort = null): SearchPostsResponse 115 154 { 116 - $response = $this->atp->client->get('app.bsky.feed.searchPosts', compact('q', 'limit', 'cursor', 'sort')); 155 + $response = $this->atp->client->get( 156 + endpoint: BskyFeed::SearchPosts, 157 + params: compact('q', 'limit', 'cursor', 'sort') 158 + ); 117 159 118 160 return SearchPostsResponse::fromArray($response->json()); 119 161 }
+37 -9
src/Client/Public/Requests/Bsky/GraphPublicRequestClient.php
··· 3 3 namespace SocialDept\AtpClient\Client\Public\Requests\Bsky; 4 4 5 5 use SocialDept\AtpClient\Client\Public\Requests\PublicRequest; 6 + use SocialDept\AtpClient\Enums\Nsid\BskyGraph; 6 7 use SocialDept\AtpClient\Data\Responses\Bsky\Graph\GetFollowersResponse; 7 8 use SocialDept\AtpClient\Data\Responses\Bsky\Graph\GetFollowsResponse; 8 9 use SocialDept\AtpClient\Data\Responses\Bsky\Graph\GetKnownFollowersResponse; ··· 17 18 { 18 19 public function getFollowers(string $actor, int $limit = 50, ?string $cursor = null): GetFollowersResponse 19 20 { 20 - $response = $this->atp->client->get('app.bsky.graph.getFollowers', compact('actor', 'limit', 'cursor')); 21 + $response = $this->atp->client->get( 22 + endpoint: BskyGraph::GetFollowers, 23 + params: compact('actor', 'limit', 'cursor') 24 + ); 21 25 22 26 return GetFollowersResponse::fromArray($response->json()); 23 27 } 24 28 25 29 public function getFollows(string $actor, int $limit = 50, ?string $cursor = null): GetFollowsResponse 26 30 { 27 - $response = $this->atp->client->get('app.bsky.graph.getFollows', compact('actor', 'limit', 'cursor')); 31 + $response = $this->atp->client->get( 32 + endpoint: BskyGraph::GetFollows, 33 + params: compact('actor', 'limit', 'cursor') 34 + ); 28 35 29 36 return GetFollowsResponse::fromArray($response->json()); 30 37 } 31 38 32 39 public function getKnownFollowers(string $actor, int $limit = 50, ?string $cursor = null): GetKnownFollowersResponse 33 40 { 34 - $response = $this->atp->client->get('app.bsky.graph.getKnownFollowers', compact('actor', 'limit', 'cursor')); 41 + $response = $this->atp->client->get( 42 + endpoint: BskyGraph::GetKnownFollowers, 43 + params: compact('actor', 'limit', 'cursor') 44 + ); 35 45 36 46 return GetKnownFollowersResponse::fromArray($response->json()); 37 47 } 38 48 39 49 public function getList(string $list, int $limit = 50, ?string $cursor = null): GetListResponse 40 50 { 41 - $response = $this->atp->client->get('app.bsky.graph.getList', compact('list', 'limit', 'cursor')); 51 + $response = $this->atp->client->get( 52 + endpoint: BskyGraph::GetList, 53 + params: compact('list', 'limit', 'cursor') 54 + ); 42 55 43 56 return GetListResponse::fromArray($response->json()); 44 57 } 45 58 46 59 public function getLists(string $actor, int $limit = 50, ?string $cursor = null): GetListsResponse 47 60 { 48 - $response = $this->atp->client->get('app.bsky.graph.getLists', compact('actor', 'limit', 'cursor')); 61 + $response = $this->atp->client->get( 62 + endpoint: BskyGraph::GetLists, 63 + params: compact('actor', 'limit', 'cursor') 64 + ); 49 65 50 66 return GetListsResponse::fromArray($response->json()); 51 67 } 52 68 53 69 public function getRelationships(string $actor, array $others = []): GetRelationshipsResponse 54 70 { 55 - $response = $this->atp->client->get('app.bsky.graph.getRelationships', compact('actor', 'others')); 71 + $response = $this->atp->client->get( 72 + endpoint: BskyGraph::GetRelationships, 73 + params: compact('actor', 'others') 74 + ); 56 75 57 76 return GetRelationshipsResponse::fromArray($response->json()); 58 77 } 59 78 60 79 public function getStarterPack(string $starterPack): StarterPackView 61 80 { 62 - $response = $this->atp->client->get('app.bsky.graph.getStarterPack', compact('starterPack')); 81 + $response = $this->atp->client->get( 82 + endpoint: BskyGraph::GetStarterPack, 83 + params: compact('starterPack') 84 + ); 63 85 64 86 return StarterPackView::fromArray($response->json()['starterPack']); 65 87 } 66 88 67 89 public function getStarterPacks(array $uris): GetStarterPacksResponse 68 90 { 69 - $response = $this->atp->client->get('app.bsky.graph.getStarterPacks', compact('uris')); 91 + $response = $this->atp->client->get( 92 + endpoint: BskyGraph::GetStarterPacks, 93 + params: compact('uris') 94 + ); 70 95 71 96 return GetStarterPacksResponse::fromArray($response->json()); 72 97 } 73 98 74 99 public function getSuggestedFollowsByActor(string $actor): GetSuggestedFollowsByActorResponse 75 100 { 76 - $response = $this->atp->client->get('app.bsky.graph.getSuggestedFollowsByActor', compact('actor')); 101 + $response = $this->atp->client->get( 102 + endpoint: BskyGraph::GetSuggestedFollowsByActor, 103 + params: compact('actor') 104 + ); 77 105 78 106 return GetSuggestedFollowsByActorResponse::fromArray($response->json()); 79 107 }
+5 -1
src/Client/Public/Requests/Bsky/LabelerPublicRequestClient.php
··· 4 4 5 5 use SocialDept\AtpClient\Client\Public\Requests\PublicRequest; 6 6 use SocialDept\AtpClient\Data\Responses\Bsky\Labeler\GetServicesResponse; 7 + use SocialDept\AtpClient\Enums\Nsid\BskyLabeler; 7 8 8 9 class LabelerPublicRequestClient extends PublicRequest 9 10 { 10 11 public function getServices(array $dids, bool $detailed = false): GetServicesResponse 11 12 { 12 - $response = $this->atp->client->get('app.bsky.labeler.getServices', compact('dids', 'detailed')); 13 + $response = $this->atp->client->get( 14 + endpoint: BskyLabeler::GetServices, 15 + params: compact('dids', 'detailed') 16 + ); 13 17 14 18 return GetServicesResponse::fromArray($response->json(), $detailed); 15 19 }
+5 -4
src/Client/Records/FollowRecordClient.php
··· 6 6 use SocialDept\AtpClient\Attributes\RequiresScope; 7 7 use SocialDept\AtpClient\Client\Requests\Request; 8 8 use SocialDept\AtpClient\Data\StrongRef; 9 + use SocialDept\AtpClient\Enums\Nsid\BskyGraph; 9 10 use SocialDept\AtpClient\Enums\Scope; 10 11 11 12 class FollowRecordClient extends Request ··· 22 23 ?DateTimeInterface $createdAt = null 23 24 ): StrongRef { 24 25 $record = [ 25 - '$type' => 'app.bsky.graph.follow', 26 + '$type' => BskyGraph::Follow->value, 26 27 'subject' => $subject, // DID 27 28 'createdAt' => ($createdAt ?? now())->format('c'), 28 29 ]; 29 30 30 31 $response = $this->atp->atproto->repo->createRecord( 31 32 repo: $this->atp->client->session()->did(), 32 - collection: 'app.bsky.graph.follow', 33 + collection: BskyGraph::Follow, 33 34 record: $record 34 35 ); 35 36 ··· 47 48 { 48 49 $this->atp->atproto->repo->deleteRecord( 49 50 repo: $this->atp->client->session()->did(), 50 - collection: 'app.bsky.graph.follow', 51 + collection: BskyGraph::Follow, 51 52 rkey: $rkey 52 53 ); 53 54 } ··· 62 63 { 63 64 $response = $this->atp->atproto->repo->getRecord( 64 65 repo: $this->atp->client->session()->did(), 65 - collection: 'app.bsky.graph.follow', 66 + collection: BskyGraph::Follow, 66 67 rkey: $rkey, 67 68 cid: $cid 68 69 );
+5 -4
src/Client/Records/LikeRecordClient.php
··· 6 6 use SocialDept\AtpClient\Attributes\RequiresScope; 7 7 use SocialDept\AtpClient\Client\Requests\Request; 8 8 use SocialDept\AtpClient\Data\StrongRef; 9 + use SocialDept\AtpClient\Enums\Nsid\BskyFeed; 9 10 use SocialDept\AtpClient\Enums\Scope; 10 11 11 12 class LikeRecordClient extends Request ··· 22 23 ?DateTimeInterface $createdAt = null 23 24 ): StrongRef { 24 25 $record = [ 25 - '$type' => 'app.bsky.feed.like', 26 + '$type' => BskyFeed::Like->value, 26 27 'subject' => $subject->toArray(), 27 28 'createdAt' => ($createdAt ?? now())->format('c'), 28 29 ]; 29 30 30 31 $response = $this->atp->atproto->repo->createRecord( 31 32 repo: $this->atp->client->session()->did(), 32 - collection: 'app.bsky.feed.like', 33 + collection: BskyFeed::Like, 33 34 record: $record 34 35 ); 35 36 ··· 47 48 { 48 49 $this->atp->atproto->repo->deleteRecord( 49 50 repo: $this->atp->client->session()->did(), 50 - collection: 'app.bsky.feed.like', 51 + collection: BskyFeed::Like, 51 52 rkey: $rkey 52 53 ); 53 54 } ··· 62 63 { 63 64 $response = $this->atp->atproto->repo->getRecord( 64 65 repo: $this->atp->client->session()->did(), 65 - collection: 'app.bsky.feed.like', 66 + collection: BskyFeed::Like, 66 67 rkey: $rkey, 67 68 cid: $cid 68 69 );
+7 -6
src/Client/Records/PostRecordClient.php
··· 7 7 use SocialDept\AtpClient\Client\Requests\Request; 8 8 use SocialDept\AtpClient\Contracts\Recordable; 9 9 use SocialDept\AtpClient\Data\StrongRef; 10 + use SocialDept\AtpClient\Enums\Nsid\BskyFeed; 10 11 use SocialDept\AtpClient\Enums\Scope; 11 12 use SocialDept\AtpClient\RichText\TextBuilder; 12 13 ··· 55 56 56 57 // Ensure $type is set 57 58 if (! isset($record['$type'])) { 58 - $record['$type'] = 'app.bsky.feed.post'; 59 + $record['$type'] = BskyFeed::Post->value; 59 60 } 60 61 61 62 $response = $this->atp->atproto->repo->createRecord( 62 63 repo: $this->atp->client->session()->did(), 63 - collection: 'app.bsky.feed.post', 64 + collection: BskyFeed::Post, 64 65 record: $record 65 66 ); 66 67 ··· 78 79 { 79 80 // Ensure $type is set 80 81 if (! isset($record['$type'])) { 81 - $record['$type'] = 'app.bsky.feed.post'; 82 + $record['$type'] = BskyFeed::Post->value; 82 83 } 83 84 84 85 $response = $this->atp->atproto->repo->putRecord( 85 86 repo: $this->atp->client->session()->did(), 86 - collection: 'app.bsky.feed.post', 87 + collection: BskyFeed::Post, 87 88 rkey: $rkey, 88 89 record: $record 89 90 ); ··· 102 103 { 103 104 $this->atp->atproto->repo->deleteRecord( 104 105 repo: $this->atp->client->session()->did(), 105 - collection: 'app.bsky.feed.post', 106 + collection: BskyFeed::Post, 106 107 rkey: $rkey 107 108 ); 108 109 } ··· 117 118 { 118 119 $response = $this->atp->atproto->repo->getRecord( 119 120 repo: $this->atp->client->session()->did(), 120 - collection: 'app.bsky.feed.post', 121 + collection: BskyFeed::Post, 121 122 rkey: $rkey, 122 123 cid: $cid 123 124 );
+5 -4
src/Client/Records/ProfileRecordClient.php
··· 5 5 use SocialDept\AtpClient\Attributes\RequiresScope; 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 7 use SocialDept\AtpClient\Data\StrongRef; 8 + use SocialDept\AtpClient\Enums\Nsid\BskyActor; 8 9 use SocialDept\AtpClient\Enums\Scope; 9 10 10 11 class ProfileRecordClient extends Request ··· 20 21 { 21 22 // Ensure $type is set 22 23 if (! isset($profile['$type'])) { 23 - $profile['$type'] = 'app.bsky.actor.profile'; 24 + $profile['$type'] = BskyActor::Profile->value; 24 25 } 25 26 26 27 $response = $this->atp->atproto->repo->putRecord( 27 28 repo: $this->atp->client->session()->did(), 28 - collection: 'app.bsky.actor.profile', 29 + collection: BskyActor::Profile, 29 30 rkey: 'self', // Profile records always use 'self' as rkey 30 31 record: $profile 31 32 ); ··· 43 44 { 44 45 $response = $this->atp->atproto->repo->getRecord( 45 46 repo: $this->atp->client->session()->did(), 46 - collection: 'app.bsky.actor.profile', 47 + collection: BskyActor::Profile, 47 48 rkey: 'self' 48 49 ); 49 50 ··· 120 121 } catch (\Exception $e) { 121 122 // Profile doesn't exist, return empty structure 122 123 return [ 123 - '$type' => 'app.bsky.actor.profile', 124 + '$type' => BskyActor::Profile->value, 124 125 ]; 125 126 } 126 127 }
+3 -2
src/Client/Requests/Atproto/IdentityRequestClient.php
··· 4 4 5 5 use SocialDept\AtpClient\Attributes\RequiresScope; 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 + use SocialDept\AtpClient\Enums\Nsid\AtprotoIdentity; 7 8 use SocialDept\AtpClient\Enums\Scope; 8 9 9 10 class IdentityRequestClient extends Request ··· 19 20 public function resolveHandle(string $handle): string 20 21 { 21 22 $response = $this->atp->client->get( 22 - endpoint: 'com.atproto.identity.resolveHandle', 23 + endpoint: AtprotoIdentity::ResolveHandle, 23 24 params: compact('handle') 24 25 ); 25 26 ··· 37 38 public function updateHandle(string $handle): void 38 39 { 39 40 $this->atp->client->post( 40 - endpoint: 'com.atproto.identity.updateHandle', 41 + endpoint: AtprotoIdentity::UpdateHandle, 41 42 body: compact('handle') 42 43 ); 43 44 }
+8 -7
src/Client/Requests/Atproto/RepoRequestClient.php
··· 13 13 use SocialDept\AtpClient\Data\Responses\Atproto\Repo\GetRecordResponse; 14 14 use SocialDept\AtpClient\Data\Responses\Atproto\Repo\ListRecordsResponse; 15 15 use SocialDept\AtpClient\Data\Responses\Atproto\Repo\PutRecordResponse; 16 + use SocialDept\AtpClient\Enums\Nsid\AtprotoRepo; 16 17 use SocialDept\AtpClient\Enums\Scope; 17 18 use SocialDept\AtpSchema\Data\BlobReference; 18 19 use SplFileInfo; ··· 39 40 $this->checkCollectionScope($collection, 'create'); 40 41 41 42 $response = $this->atp->client->post( 42 - endpoint: 'com.atproto.repo.createRecord', 43 + endpoint: AtprotoRepo::CreateRecord, 43 44 body: array_filter( 44 45 compact('repo', 'collection', 'record', 'rkey', 'validate', 'swapCommit'), 45 46 fn ($v) => ! is_null($v) ··· 67 68 $this->checkCollectionScope($collection, 'delete'); 68 69 69 70 $response = $this->atp->client->post( 70 - endpoint: 'com.atproto.repo.deleteRecord', 71 + endpoint: AtprotoRepo::DeleteRecord, 71 72 body: array_filter( 72 73 compact('repo', 'collection', 'rkey', 'swapRecord', 'swapCommit'), 73 74 fn ($v) => ! is_null($v) ··· 97 98 $this->checkCollectionScope($collection, 'update'); 98 99 99 100 $response = $this->atp->client->post( 100 - endpoint: 'com.atproto.repo.putRecord', 101 + endpoint: AtprotoRepo::PutRecord, 101 102 body: array_filter( 102 103 compact('repo', 'collection', 'rkey', 'record', 'validate', 'swapRecord', 'swapCommit'), 103 104 fn ($v) => ! is_null($v) ··· 122 123 ?string $cid = null 123 124 ): GetRecordResponse { 124 125 $response = $this->atp->client->get( 125 - endpoint: 'com.atproto.repo.getRecord', 126 + endpoint: AtprotoRepo::GetRecord, 126 127 params: compact('repo', 'collection', 'rkey', 'cid') 127 128 ); 128 129 ··· 145 146 bool $reverse = false 146 147 ): ListRecordsResponse { 147 148 $response = $this->atp->client->get( 148 - endpoint: 'com.atproto.repo.listRecords', 149 + endpoint: AtprotoRepo::ListRecords, 149 150 params: compact('repo', 'collection', 'limit', 'cursor', 'reverse') 150 151 ); 151 152 ··· 182 183 } 183 184 184 185 $response = $this->atp->client->postBlob( 185 - endpoint: 'com.atproto.repo.uploadBlob', 186 + endpoint: AtprotoRepo::UploadBlob, 186 187 data: $data, 187 188 mimeType: $mimeType 188 189 ); ··· 201 202 public function describeRepo(string $repo): DescribeRepoResponse 202 203 { 203 204 $response = $this->atp->client->get( 204 - endpoint: 'com.atproto.repo.describeRepo', 205 + endpoint: AtprotoRepo::DescribeRepo, 205 206 params: compact('repo') 206 207 ); 207 208
+3 -2
src/Client/Requests/Atproto/ServerRequestClient.php
··· 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 7 use SocialDept\AtpClient\Data\Responses\Atproto\Server\DescribeServerResponse; 8 8 use SocialDept\AtpClient\Data\Responses\Atproto\Server\GetSessionResponse; 9 + use SocialDept\AtpClient\Enums\Nsid\AtprotoServer; 9 10 use SocialDept\AtpClient\Enums\Scope; 10 11 11 12 class ServerRequestClient extends Request ··· 21 22 public function getSession(): GetSessionResponse 22 23 { 23 24 $response = $this->atp->client->get( 24 - endpoint: 'com.atproto.server.getSession' 25 + endpoint: AtprotoServer::GetSession 25 26 ); 26 27 27 28 return GetSessionResponse::fromArray($response->json()); ··· 38 39 public function describeServer(): DescribeServerResponse 39 40 { 40 41 $response = $this->atp->client->get( 41 - endpoint: 'com.atproto.server.describeServer' 42 + endpoint: AtprotoServer::DescribeServer 42 43 ); 43 44 44 45 return DescribeServerResponse::fromArray($response->json());
+9 -8
src/Client/Requests/Atproto/SyncRequestClient.php
··· 7 7 use SocialDept\AtpClient\Data\Responses\Atproto\Sync\GetRepoStatusResponse; 8 8 use SocialDept\AtpClient\Data\Responses\Atproto\Sync\ListBlobsResponse; 9 9 use SocialDept\AtpClient\Data\Responses\Atproto\Sync\ListReposResponse; 10 + use SocialDept\AtpClient\Enums\Nsid\AtprotoSync; 10 11 use SocialDept\AtpClient\Enums\Scope; 11 12 use SocialDept\AtpClient\Http\Response; 12 13 use SocialDept\AtpSchema\Generated\Com\Atproto\Repo\Defs\CommitMeta; ··· 24 25 public function getBlob(string $did, string $cid): Response 25 26 { 26 27 return $this->atp->client->get( 27 - endpoint: 'com.atproto.sync.getBlob', 28 + endpoint: AtprotoSync::GetBlob, 28 29 params: compact('did', 'cid') 29 30 ); 30 31 } ··· 40 41 public function getRepo(string $did, ?string $since = null): Response 41 42 { 42 43 return $this->atp->client->get( 43 - endpoint: 'com.atproto.sync.getRepo', 44 + endpoint: AtprotoSync::GetRepo, 44 45 params: compact('did', 'since') 45 46 ); 46 47 } ··· 56 57 public function listRepos(int $limit = 500, ?string $cursor = null): ListReposResponse 57 58 { 58 59 $response = $this->atp->client->get( 59 - endpoint: 'com.atproto.sync.listRepos', 60 + endpoint: AtprotoSync::ListRepos, 60 61 params: compact('limit', 'cursor') 61 62 ); 62 63 ··· 74 75 public function getLatestCommit(string $did): CommitMeta 75 76 { 76 77 $response = $this->atp->client->get( 77 - endpoint: 'com.atproto.sync.getLatestCommit', 78 + endpoint: AtprotoSync::GetLatestCommit, 78 79 params: compact('did') 79 80 ); 80 81 ··· 92 93 public function getRecord(string $did, string $collection, string $rkey): Response 93 94 { 94 95 return $this->atp->client->get( 95 - endpoint: 'com.atproto.sync.getRecord', 96 + endpoint: AtprotoSync::GetRecord, 96 97 params: compact('did', 'collection', 'rkey') 97 98 ); 98 99 } ··· 112 113 ?string $cursor = null 113 114 ): ListBlobsResponse { 114 115 $response = $this->atp->client->get( 115 - endpoint: 'com.atproto.sync.listBlobs', 116 + endpoint: AtprotoSync::ListBlobs, 116 117 params: compact('did', 'since', 'limit', 'cursor') 117 118 ); 118 119 ··· 130 131 public function getBlocks(string $did, array $cids): Response 131 132 { 132 133 return $this->atp->client->get( 133 - endpoint: 'com.atproto.sync.getBlocks', 134 + endpoint: AtprotoSync::GetBlocks, 134 135 params: compact('did', 'cids') 135 136 ); 136 137 } ··· 146 147 public function getRepoStatus(string $did): GetRepoStatusResponse 147 148 { 148 149 $response = $this->atp->client->get( 149 - endpoint: 'com.atproto.sync.getRepoStatus', 150 + endpoint: AtprotoSync::GetRepoStatus, 150 151 params: compact('did') 151 152 ); 152 153
+2 -1
src/Client/Requests/Bsky/ActorRequestClient.php
··· 4 4 5 5 use SocialDept\AtpClient\Attributes\RequiresScope; 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 + use SocialDept\AtpClient\Enums\Nsid\BskyActor; 7 8 use SocialDept\AtpClient\Enums\Scope; 8 9 use SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs\ProfileViewDetailed; 9 10 ··· 20 21 public function getProfile(string $actor): ProfileViewDetailed 21 22 { 22 23 $response = $this->atp->client->get( 23 - endpoint: 'app.bsky.actor.getProfile', 24 + endpoint: BskyActor::GetProfile, 24 25 params: compact('actor') 25 26 ); 26 27
+7 -6
src/Client/Requests/Bsky/FeedRequestClient.php
··· 10 10 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetRepostedByResponse; 11 11 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\GetTimelineResponse; 12 12 use SocialDept\AtpClient\Data\Responses\Bsky\Feed\SearchPostsResponse; 13 + use SocialDept\AtpClient\Enums\Nsid\BskyFeed; 13 14 use SocialDept\AtpClient\Enums\Scope; 14 15 15 16 class FeedRequestClient extends Request ··· 25 26 public function getTimeline(int $limit = 50, ?string $cursor = null): GetTimelineResponse 26 27 { 27 28 $response = $this->atp->client->get( 28 - endpoint: 'app.bsky.feed.getTimeline', 29 + endpoint: BskyFeed::GetTimeline, 29 30 params: compact('limit', 'cursor') 30 31 ); 31 32 ··· 46 47 ?string $cursor = null 47 48 ): GetAuthorFeedResponse { 48 49 $response = $this->atp->client->get( 49 - endpoint: 'app.bsky.feed.getAuthorFeed', 50 + endpoint: BskyFeed::GetAuthorFeed, 50 51 params: compact('actor', 'limit', 'cursor') 51 52 ); 52 53 ··· 64 65 public function getPostThread(string $uri, int $depth = 6): GetPostThreadResponse 65 66 { 66 67 $response = $this->atp->client->get( 67 - endpoint: 'app.bsky.feed.getPostThread', 68 + endpoint: BskyFeed::GetPostThread, 68 69 params: compact('uri', 'depth') 69 70 ); 70 71 ··· 85 86 ?string $cursor = null 86 87 ): SearchPostsResponse { 87 88 $response = $this->atp->client->get( 88 - endpoint: 'app.bsky.feed.searchPosts', 89 + endpoint: BskyFeed::SearchPosts, 89 90 params: compact('q', 'limit', 'cursor') 90 91 ); 91 92 ··· 106 107 ?string $cursor = null 107 108 ): GetLikesResponse { 108 109 $response = $this->atp->client->get( 109 - endpoint: 'app.bsky.feed.getLikes', 110 + endpoint: BskyFeed::GetLikes, 110 111 params: compact('uri', 'limit', 'cursor') 111 112 ); 112 113 ··· 127 128 ?string $cursor = null 128 129 ): GetRepostedByResponse { 129 130 $response = $this->atp->client->get( 130 - endpoint: 'app.bsky.feed.getRepostedBy', 131 + endpoint: BskyFeed::GetRepostedBy, 131 132 params: compact('uri', 'limit', 'cursor') 132 133 ); 133 134
+4 -3
src/Client/Requests/Chat/ActorRequestClient.php
··· 4 4 5 5 use SocialDept\AtpClient\Attributes\RequiresScope; 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 + use SocialDept\AtpClient\Enums\Nsid\ChatActor; 7 8 use SocialDept\AtpClient\Enums\Scope; 8 9 use SocialDept\AtpClient\Http\Response; 9 10 ··· 20 21 public function getActorMetadata(): Response 21 22 { 22 23 return $this->atp->client->get( 23 - endpoint: 'chat.bsky.actor.getActorMetadata' 24 + endpoint: ChatActor::GetActorMetadata 24 25 ); 25 26 } 26 27 ··· 35 36 public function exportAccountData(): Response 36 37 { 37 38 return $this->atp->client->get( 38 - endpoint: 'chat.bsky.actor.exportAccountData' 39 + endpoint: ChatActor::ExportAccountData 39 40 ); 40 41 } 41 42 ··· 50 51 public function deleteAccount(): void 51 52 { 52 53 $this->atp->client->post( 53 - endpoint: 'chat.bsky.actor.deleteAccount' 54 + endpoint: ChatActor::DeleteAccount 54 55 ); 55 56 } 56 57 }
+13 -12
src/Client/Requests/Chat/ConvoRequestClient.php
··· 9 9 use SocialDept\AtpClient\Data\Responses\Chat\Convo\LeaveConvoResponse; 10 10 use SocialDept\AtpClient\Data\Responses\Chat\Convo\ListConvosResponse; 11 11 use SocialDept\AtpClient\Data\Responses\Chat\Convo\SendMessageBatchResponse; 12 + use SocialDept\AtpClient\Enums\Nsid\ChatConvo; 12 13 use SocialDept\AtpClient\Enums\Scope; 13 14 use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\ConvoView; 14 15 use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\DeletedMessageView; ··· 27 28 public function getConvo(string $convoId): ConvoView 28 29 { 29 30 $response = $this->atp->client->get( 30 - endpoint: 'chat.bsky.convo.getConvo', 31 + endpoint: ChatConvo::GetConvo, 31 32 params: compact('convoId') 32 33 ); 33 34 ··· 45 46 public function getConvoForMembers(array $members): ConvoView 46 47 { 47 48 $response = $this->atp->client->get( 48 - endpoint: 'chat.bsky.convo.getConvoForMembers', 49 + endpoint: ChatConvo::GetConvoForMembers, 49 50 params: compact('members') 50 51 ); 51 52 ··· 63 64 public function listConvos(int $limit = 50, ?string $cursor = null): ListConvosResponse 64 65 { 65 66 $response = $this->atp->client->get( 66 - endpoint: 'chat.bsky.convo.listConvos', 67 + endpoint: ChatConvo::ListConvos, 67 68 params: compact('limit', 'cursor') 68 69 ); 69 70 ··· 84 85 ?string $cursor = null 85 86 ): GetMessagesResponse { 86 87 $response = $this->atp->client->get( 87 - endpoint: 'chat.bsky.convo.getMessages', 88 + endpoint: ChatConvo::GetMessages, 88 89 params: compact('convoId', 'limit', 'cursor') 89 90 ); 90 91 ··· 102 103 public function sendMessage(string $convoId, array $message): MessageView 103 104 { 104 105 $response = $this->atp->client->post( 105 - endpoint: 'chat.bsky.convo.sendMessage', 106 + endpoint: ChatConvo::SendMessage, 106 107 body: compact('convoId', 'message') 107 108 ); 108 109 ··· 120 121 public function sendMessageBatch(array $items): SendMessageBatchResponse 121 122 { 122 123 $response = $this->atp->client->post( 123 - endpoint: 'chat.bsky.convo.sendMessageBatch', 124 + endpoint: ChatConvo::SendMessageBatch, 124 125 body: compact('items') 125 126 ); 126 127 ··· 138 139 public function deleteMessageForSelf(string $convoId, string $messageId): DeletedMessageView 139 140 { 140 141 $response = $this->atp->client->post( 141 - endpoint: 'chat.bsky.convo.deleteMessageForSelf', 142 + endpoint: ChatConvo::DeleteMessageForSelf, 142 143 body: compact('convoId', 'messageId') 143 144 ); 144 145 ··· 156 157 public function updateRead(string $convoId, ?string $messageId = null): ConvoView 157 158 { 158 159 $response = $this->atp->client->post( 159 - endpoint: 'chat.bsky.convo.updateRead', 160 + endpoint: ChatConvo::UpdateRead, 160 161 body: compact('convoId', 'messageId') 161 162 ); 162 163 ··· 174 175 public function muteConvo(string $convoId): ConvoView 175 176 { 176 177 $response = $this->atp->client->post( 177 - endpoint: 'chat.bsky.convo.muteConvo', 178 + endpoint: ChatConvo::MuteConvo, 178 179 body: compact('convoId') 179 180 ); 180 181 ··· 192 193 public function unmuteConvo(string $convoId): ConvoView 193 194 { 194 195 $response = $this->atp->client->post( 195 - endpoint: 'chat.bsky.convo.unmuteConvo', 196 + endpoint: ChatConvo::UnmuteConvo, 196 197 body: compact('convoId') 197 198 ); 198 199 ··· 210 211 public function leaveConvo(string $convoId): LeaveConvoResponse 211 212 { 212 213 $response = $this->atp->client->post( 213 - endpoint: 'chat.bsky.convo.leaveConvo', 214 + endpoint: ChatConvo::LeaveConvo, 214 215 body: compact('convoId') 215 216 ); 216 217 ··· 228 229 public function getLog(?string $cursor = null): GetLogResponse 229 230 { 230 231 $response = $this->atp->client->get( 231 - endpoint: 'chat.bsky.convo.getLog', 232 + endpoint: ChatConvo::GetLog, 232 233 params: compact('cursor') 233 234 ); 234 235
+9 -8
src/Client/Requests/Ozone/ModerationRequestClient.php
··· 7 7 use SocialDept\AtpClient\Data\Responses\Ozone\Moderation\QueryEventsResponse; 8 8 use SocialDept\AtpClient\Data\Responses\Ozone\Moderation\QueryStatusesResponse; 9 9 use SocialDept\AtpClient\Data\Responses\Ozone\Moderation\SearchReposResponse; 10 + use SocialDept\AtpClient\Enums\Nsid\OzoneModeration; 10 11 use SocialDept\AtpClient\Enums\Scope; 11 12 use SocialDept\AtpClient\Http\Response; 12 13 use SocialDept\AtpSchema\Generated\Tools\Ozone\Moderation\Defs\ModEventView; ··· 27 28 public function getModerationEvent(int $id): ModEventViewDetail 28 29 { 29 30 $response = $this->atp->client->get( 30 - endpoint: 'tools.ozone.moderation.getEvent', 31 + endpoint: OzoneModeration::GetEvent, 31 32 params: compact('id') 32 33 ); 33 34 ··· 50 51 ?string $cursor = null 51 52 ): Response { 52 53 return $this->atp->client->get( 53 - endpoint: 'tools.ozone.moderation.getEvents', 54 + endpoint: OzoneModeration::GetEvents, 54 55 params: array_filter( 55 56 compact('subject', 'types', 'createdBy', 'limit', 'cursor'), 56 57 fn ($v) => ! is_null($v) ··· 69 70 public function getRecord(string $uri, ?string $cid = null): RecordViewDetail 70 71 { 71 72 $response = $this->atp->client->get( 72 - endpoint: 'tools.ozone.moderation.getRecord', 73 + endpoint: OzoneModeration::GetRecord, 73 74 params: compact('uri', 'cid') 74 75 ); 75 76 ··· 87 88 public function getRepo(string $did): RepoViewDetail 88 89 { 89 90 $response = $this->atp->client->get( 90 - endpoint: 'tools.ozone.moderation.getRepo', 91 + endpoint: OzoneModeration::GetRepo, 91 92 params: compact('did') 92 93 ); 93 94 ··· 111 112 bool $sortDirection = false 112 113 ): QueryEventsResponse { 113 114 $response = $this->atp->client->get( 114 - endpoint: 'tools.ozone.moderation.queryEvents', 115 + endpoint: OzoneModeration::QueryEvents, 115 116 params: array_filter( 116 117 compact('types', 'createdBy', 'subject', 'limit', 'cursor', 'sortDirection'), 117 118 fn ($v) => ! is_null($v) ··· 137 138 ?string $cursor = null 138 139 ): QueryStatusesResponse { 139 140 $response = $this->atp->client->get( 140 - endpoint: 'tools.ozone.moderation.queryStatuses', 141 + endpoint: OzoneModeration::QueryStatuses, 141 142 params: array_filter( 142 143 compact('subject', 'tags', 'excludeTags', 'limit', 'cursor'), 143 144 fn ($v) => ! is_null($v) ··· 162 163 ?string $cursor = null 163 164 ): SearchReposResponse { 164 165 $response = $this->atp->client->get( 165 - endpoint: 'tools.ozone.moderation.searchRepos', 166 + endpoint: OzoneModeration::SearchRepos, 166 167 params: array_filter( 167 168 compact('term', 'invitedBy', 'limit', 'cursor'), 168 169 fn ($v) => ! is_null($v) ··· 187 188 ?string $createdBy = null 188 189 ): ModEventView { 189 190 $response = $this->atp->client->post( 190 - endpoint: 'tools.ozone.moderation.emitEvent', 191 + endpoint: OzoneModeration::EmitEvent, 191 192 body: compact('event', 'subject', 'subjectBlobCids', 'createdBy') 192 193 ); 193 194
+3 -2
src/Client/Requests/Ozone/ServerRequestClient.php
··· 5 5 use SocialDept\AtpClient\Attributes\RequiresScope; 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 7 use SocialDept\AtpClient\Data\Responses\Ozone\Server\GetConfigResponse; 8 + use SocialDept\AtpClient\Enums\Nsid\OzoneServer; 8 9 use SocialDept\AtpClient\Enums\Scope; 9 10 use SocialDept\AtpClient\Http\Response; 10 11 ··· 21 22 public function getBlob(string $did, string $cid): Response 22 23 { 23 24 return $this->atp->client->get( 24 - endpoint: 'tools.ozone.server.getBlob', 25 + endpoint: OzoneServer::GetBlob, 25 26 params: compact('did', 'cid') 26 27 ); 27 28 } ··· 37 38 public function getConfig(): GetConfigResponse 38 39 { 39 40 $response = $this->atp->client->get( 40 - endpoint: 'tools.ozone.server.getConfig' 41 + endpoint: OzoneServer::GetConfig 41 42 ); 42 43 43 44 return GetConfigResponse::fromArray($response->json());
+6 -5
src/Client/Requests/Ozone/TeamRequestClient.php
··· 5 5 use SocialDept\AtpClient\Attributes\RequiresScope; 6 6 use SocialDept\AtpClient\Client\Requests\Request; 7 7 use SocialDept\AtpClient\Data\Responses\Ozone\Team\ListMembersResponse; 8 + use SocialDept\AtpClient\Enums\Nsid\OzoneTeam; 8 9 use SocialDept\AtpClient\Enums\Scope; 9 10 10 11 class TeamRequestClient extends Request ··· 22 23 public function getTeamMember(string $did): array 23 24 { 24 25 $response = $this->atp->client->get( 25 - endpoint: 'tools.ozone.team.getMember', 26 + endpoint: OzoneTeam::GetMember, 26 27 params: compact('did') 27 28 ); 28 29 ··· 40 41 public function listTeamMembers(int $limit = 50, ?string $cursor = null): ListMembersResponse 41 42 { 42 43 $response = $this->atp->client->get( 43 - endpoint: 'tools.ozone.team.listMembers', 44 + endpoint: OzoneTeam::ListMembers, 44 45 params: compact('limit', 'cursor') 45 46 ); 46 47 ··· 60 61 public function addTeamMember(string $did, string $role): array 61 62 { 62 63 $response = $this->atp->client->post( 63 - endpoint: 'tools.ozone.team.addMember', 64 + endpoint: OzoneTeam::AddMember, 64 65 body: compact('did', 'role') 65 66 ); 66 67 ··· 83 84 ?string $role = null 84 85 ): array { 85 86 $response = $this->atp->client->post( 86 - endpoint: 'tools.ozone.team.updateMember', 87 + endpoint: OzoneTeam::UpdateMember, 87 88 body: array_filter( 88 89 compact('did', 'disabled', 'role'), 89 90 fn ($v) => ! is_null($v) ··· 104 105 public function deleteTeamMember(string $did): void 105 106 { 106 107 $this->atp->client->post( 107 - endpoint: 'tools.ozone.team.deleteMember', 108 + endpoint: OzoneTeam::DeleteMember, 108 109 body: compact('did') 109 110 ); 110 111 }
+12
src/Enums/Nsid/AtprotoIdentity.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum AtprotoIdentity: string 8 + { 9 + use HasScopeHelpers; 10 + case ResolveHandle = 'com.atproto.identity.resolveHandle'; 11 + case UpdateHandle = 'com.atproto.identity.updateHandle'; 12 + }
+17
src/Enums/Nsid/AtprotoRepo.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum AtprotoRepo: string 8 + { 9 + use HasScopeHelpers; 10 + case CreateRecord = 'com.atproto.repo.createRecord'; 11 + case DeleteRecord = 'com.atproto.repo.deleteRecord'; 12 + case PutRecord = 'com.atproto.repo.putRecord'; 13 + case GetRecord = 'com.atproto.repo.getRecord'; 14 + case ListRecords = 'com.atproto.repo.listRecords'; 15 + case UploadBlob = 'com.atproto.repo.uploadBlob'; 16 + case DescribeRepo = 'com.atproto.repo.describeRepo'; 17 + }
+14
src/Enums/Nsid/AtprotoServer.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum AtprotoServer: string 8 + { 9 + use HasScopeHelpers; 10 + case CreateSession = 'com.atproto.server.createSession'; 11 + case RefreshSession = 'com.atproto.server.refreshSession'; 12 + case GetSession = 'com.atproto.server.getSession'; 13 + case DescribeServer = 'com.atproto.server.describeServer'; 14 + }
+18
src/Enums/Nsid/AtprotoSync.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum AtprotoSync: string 8 + { 9 + use HasScopeHelpers; 10 + case GetBlob = 'com.atproto.sync.getBlob'; 11 + case GetRepo = 'com.atproto.sync.getRepo'; 12 + case ListRepos = 'com.atproto.sync.listRepos'; 13 + case GetLatestCommit = 'com.atproto.sync.getLatestCommit'; 14 + case GetRecord = 'com.atproto.sync.getRecord'; 15 + case ListBlobs = 'com.atproto.sync.listBlobs'; 16 + case GetBlocks = 'com.atproto.sync.getBlocks'; 17 + case GetRepoStatus = 'com.atproto.sync.getRepoStatus'; 18 + }
+18
src/Enums/Nsid/BskyActor.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum BskyActor: string 8 + { 9 + use HasScopeHelpers; 10 + case GetProfile = 'app.bsky.actor.getProfile'; 11 + case GetProfiles = 'app.bsky.actor.getProfiles'; 12 + case GetSuggestions = 'app.bsky.actor.getSuggestions'; 13 + case SearchActors = 'app.bsky.actor.searchActors'; 14 + case SearchActorsTypeahead = 'app.bsky.actor.searchActorsTypeahead'; 15 + 16 + // Record type 17 + case Profile = 'app.bsky.actor.profile'; 18 + }
+29
src/Enums/Nsid/BskyFeed.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum BskyFeed: string 8 + { 9 + use HasScopeHelpers; 10 + case DescribeFeedGenerator = 'app.bsky.feed.describeFeedGenerator'; 11 + case GetAuthorFeed = 'app.bsky.feed.getAuthorFeed'; 12 + case GetActorFeeds = 'app.bsky.feed.getActorFeeds'; 13 + case GetActorLikes = 'app.bsky.feed.getActorLikes'; 14 + case GetFeed = 'app.bsky.feed.getFeed'; 15 + case GetFeedGenerator = 'app.bsky.feed.getFeedGenerator'; 16 + case GetFeedGenerators = 'app.bsky.feed.getFeedGenerators'; 17 + case GetLikes = 'app.bsky.feed.getLikes'; 18 + case GetPostThread = 'app.bsky.feed.getPostThread'; 19 + case GetPosts = 'app.bsky.feed.getPosts'; 20 + case GetQuotes = 'app.bsky.feed.getQuotes'; 21 + case GetRepostedBy = 'app.bsky.feed.getRepostedBy'; 22 + case GetSuggestedFeeds = 'app.bsky.feed.getSuggestedFeeds'; 23 + case GetTimeline = 'app.bsky.feed.getTimeline'; 24 + case SearchPosts = 'app.bsky.feed.searchPosts'; 25 + 26 + // Record types 27 + case Post = 'app.bsky.feed.post'; 28 + case Like = 'app.bsky.feed.like'; 29 + }
+22
src/Enums/Nsid/BskyGraph.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum BskyGraph: string 8 + { 9 + use HasScopeHelpers; 10 + case GetFollowers = 'app.bsky.graph.getFollowers'; 11 + case GetFollows = 'app.bsky.graph.getFollows'; 12 + case GetKnownFollowers = 'app.bsky.graph.getKnownFollowers'; 13 + case GetList = 'app.bsky.graph.getList'; 14 + case GetLists = 'app.bsky.graph.getLists'; 15 + case GetRelationships = 'app.bsky.graph.getRelationships'; 16 + case GetStarterPack = 'app.bsky.graph.getStarterPack'; 17 + case GetStarterPacks = 'app.bsky.graph.getStarterPacks'; 18 + case GetSuggestedFollowsByActor = 'app.bsky.graph.getSuggestedFollowsByActor'; 19 + 20 + // Record type 21 + case Follow = 'app.bsky.graph.follow'; 22 + }
+11
src/Enums/Nsid/BskyLabeler.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum BskyLabeler: string 8 + { 9 + use HasScopeHelpers; 10 + case GetServices = 'app.bsky.labeler.getServices'; 11 + }
+13
src/Enums/Nsid/ChatActor.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum ChatActor: string 8 + { 9 + use HasScopeHelpers; 10 + case GetActorMetadata = 'chat.bsky.actor.getActorMetadata'; 11 + case ExportAccountData = 'chat.bsky.actor.exportAccountData'; 12 + case DeleteAccount = 'chat.bsky.actor.deleteAccount'; 13 + }
+22
src/Enums/Nsid/ChatConvo.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum ChatConvo: string 8 + { 9 + use HasScopeHelpers; 10 + case GetConvo = 'chat.bsky.convo.getConvo'; 11 + case GetConvoForMembers = 'chat.bsky.convo.getConvoForMembers'; 12 + case ListConvos = 'chat.bsky.convo.listConvos'; 13 + case GetMessages = 'chat.bsky.convo.getMessages'; 14 + case SendMessage = 'chat.bsky.convo.sendMessage'; 15 + case SendMessageBatch = 'chat.bsky.convo.sendMessageBatch'; 16 + case DeleteMessageForSelf = 'chat.bsky.convo.deleteMessageForSelf'; 17 + case UpdateRead = 'chat.bsky.convo.updateRead'; 18 + case MuteConvo = 'chat.bsky.convo.muteConvo'; 19 + case UnmuteConvo = 'chat.bsky.convo.unmuteConvo'; 20 + case LeaveConvo = 'chat.bsky.convo.leaveConvo'; 21 + case GetLog = 'chat.bsky.convo.getLog'; 22 + }
+34
src/Enums/Nsid/Concerns/HasScopeHelpers.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid\Concerns; 4 + 5 + trait HasScopeHelpers 6 + { 7 + /** 8 + * Get the RPC scope format for this NSID. 9 + * 10 + * @example BskyActor::GetProfile->rpc() // "rpc:app.bsky.actor.getProfile" 11 + */ 12 + public function rpc(): string 13 + { 14 + return 'rpc:' . $this->value; 15 + } 16 + 17 + /** 18 + * Get the repo scope format for this NSID. 19 + * 20 + * @example BskyGraph::Follow->repo(['create']) // "repo:app.bsky.graph.follow?action=create" 21 + * @example BskyFeed::Post->repo(['create', 'delete']) // "repo:app.bsky.feed.post?action=create&action=delete" 22 + * @example BskyFeed::Post->repo() // "repo:app.bsky.feed.post" 23 + */ 24 + public function repo(array $actions = []): string 25 + { 26 + $scope = 'repo:' . $this->value; 27 + 28 + if (! empty($actions)) { 29 + $scope .= '?' . implode('&', array_map(fn ($action) => "action={$action}", $actions)); 30 + } 31 + 32 + return $scope; 33 + } 34 + }
+18
src/Enums/Nsid/OzoneModeration.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum OzoneModeration: string 8 + { 9 + use HasScopeHelpers; 10 + case GetEvent = 'tools.ozone.moderation.getEvent'; 11 + case GetEvents = 'tools.ozone.moderation.getEvents'; 12 + case GetRecord = 'tools.ozone.moderation.getRecord'; 13 + case GetRepo = 'tools.ozone.moderation.getRepo'; 14 + case QueryEvents = 'tools.ozone.moderation.queryEvents'; 15 + case QueryStatuses = 'tools.ozone.moderation.queryStatuses'; 16 + case SearchRepos = 'tools.ozone.moderation.searchRepos'; 17 + case EmitEvent = 'tools.ozone.moderation.emitEvent'; 18 + }
+12
src/Enums/Nsid/OzoneServer.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum OzoneServer: string 8 + { 9 + use HasScopeHelpers; 10 + case GetBlob = 'tools.ozone.server.getBlob'; 11 + case GetConfig = 'tools.ozone.server.getConfig'; 12 + }
+15
src/Enums/Nsid/OzoneTeam.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Enums\Nsid; 4 + 5 + use SocialDept\AtpClient\Enums\Nsid\Concerns\HasScopeHelpers; 6 + 7 + enum OzoneTeam: string 8 + { 9 + use HasScopeHelpers; 10 + case GetMember = 'tools.ozone.team.getMember'; 11 + case ListMembers = 'tools.ozone.team.listMembers'; 12 + case AddMember = 'tools.ozone.team.addMember'; 13 + case UpdateMember = 'tools.ozone.team.updateMember'; 14 + case DeleteMember = 'tools.ozone.team.deleteMember'; 15 + }
+8 -5
src/Http/HasHttp.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Http; 4 4 5 + use BackedEnum; 5 6 use Illuminate\Http\Client\Response as LaravelResponse; 6 7 use Illuminate\Support\Facades\Http; 7 8 use InvalidArgumentException; ··· 27 28 * Make XRPC call 28 29 */ 29 30 protected function call( 30 - string $endpoint, 31 + string|BackedEnum $endpoint, 31 32 string $method, 32 33 ?array $params = null, 33 34 ?array $body = null 34 35 ): Response { 36 + $endpoint = $endpoint instanceof BackedEnum ? $endpoint->value : $endpoint; 35 37 $session = $this->sessions->ensureValid($this->did); 36 38 $url = rtrim($session->pdsEndpoint(), '/').'/xrpc/'.$endpoint; 37 39 ··· 102 104 /** 103 105 * Make GET request 104 106 */ 105 - public function get(string $endpoint, array $params = []): Response 107 + public function get(string|BackedEnum $endpoint, array $params = []): Response 106 108 { 107 109 return $this->call($endpoint, 'GET', $params); 108 110 } ··· 110 112 /** 111 113 * Make POST request 112 114 */ 113 - public function post(string $endpoint, array $body = []): Response 115 + public function post(string|BackedEnum $endpoint, array $body = []): Response 114 116 { 115 117 return $this->call($endpoint, 'POST', null, $body); 116 118 } ··· 118 120 /** 119 121 * Make DELETE request 120 122 */ 121 - public function delete(string $endpoint, array $params = []): Response 123 + public function delete(string|BackedEnum $endpoint, array $params = []): Response 122 124 { 123 125 return $this->call($endpoint, 'DELETE', $params); 124 126 } ··· 126 128 /** 127 129 * Make POST request with raw binary body (for blob uploads) 128 130 */ 129 - public function postBlob(string $endpoint, string $data, string $mimeType): Response 131 + public function postBlob(string|BackedEnum $endpoint, string $data, string $mimeType): Response 130 132 { 133 + $endpoint = $endpoint instanceof BackedEnum ? $endpoint->value : $endpoint; 131 134 $session = $this->sessions->ensureValid($this->did); 132 135 $url = rtrim($session->pdsEndpoint(), '/').'/xrpc/'.$endpoint; 133 136