Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

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

Add public repo client with getRecord, listRecords, and describeRepo

+68
+3
src/Client/Public/AtprotoPublicClient.php
··· 3 3 namespace SocialDept\AtpClient\Client\Public; 4 4 5 5 use SocialDept\AtpClient\Client\Public\Requests\Atproto\IdentityPublicRequestClient; 6 + use SocialDept\AtpClient\Client\Public\Requests\Atproto\RepoPublicRequestClient; 6 7 use SocialDept\AtpClient\Concerns\HasDomainExtensions; 7 8 8 9 class AtprotoPublicClient ··· 11 12 12 13 public AtpPublicClient $atp; 13 14 public IdentityPublicRequestClient $identity; 15 + public RepoPublicRequestClient $repo; 14 16 15 17 public function __construct(AtpPublicClient $parent) 16 18 { 17 19 $this->atp = $parent; 18 20 $this->identity = new IdentityPublicRequestClient($this); 21 + $this->repo = new RepoPublicRequestClient($this); 19 22 } 20 23 21 24 protected function getDomainName(): string
+65
src/Client/Public/Requests/Atproto/RepoPublicRequestClient.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Public\Requests\Atproto; 4 + 5 + use SocialDept\AtpClient\Client\Public\Requests\PublicRequest; 6 + use SocialDept\AtpClient\Data\Responses\Atproto\Repo\DescribeRepoResponse; 7 + use SocialDept\AtpClient\Data\Responses\Atproto\Repo\GetRecordResponse; 8 + use SocialDept\AtpClient\Data\Responses\Atproto\Repo\ListRecordsResponse; 9 + 10 + class RepoPublicRequestClient extends PublicRequest 11 + { 12 + /** 13 + * Get a record 14 + * 15 + * @see https://docs.bsky.app/docs/api/com-atproto-repo-get-record 16 + */ 17 + public function getRecord( 18 + string $repo, 19 + string $collection, 20 + string $rkey, 21 + ?string $cid = null 22 + ): GetRecordResponse { 23 + $response = $this->atp->client->get( 24 + 'com.atproto.repo.getRecord', 25 + compact('repo', 'collection', 'rkey', 'cid') 26 + ); 27 + 28 + return GetRecordResponse::fromArray($response->json()); 29 + } 30 + 31 + /** 32 + * List records in a collection 33 + * 34 + * @see https://docs.bsky.app/docs/api/com-atproto-repo-list-records 35 + */ 36 + public function listRecords( 37 + string $repo, 38 + string $collection, 39 + int $limit = 50, 40 + ?string $cursor = null, 41 + bool $reverse = false 42 + ): ListRecordsResponse { 43 + $response = $this->atp->client->get( 44 + 'com.atproto.repo.listRecords', 45 + compact('repo', 'collection', 'limit', 'cursor', 'reverse') 46 + ); 47 + 48 + return ListRecordsResponse::fromArray($response->json()); 49 + } 50 + 51 + /** 52 + * Describe the repository 53 + * 54 + * @see https://docs.bsky.app/docs/api/com-atproto-repo-describe-repo 55 + */ 56 + public function describeRepo(string $repo): DescribeRepoResponse 57 + { 58 + $response = $this->atp->client->get( 59 + 'com.atproto.repo.describeRepo', 60 + compact('repo') 61 + ); 62 + 63 + return DescribeRepoResponse::fromArray($response->json()); 64 + } 65 + }