Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

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

Restructure client architecture with namespace-based NSID partials

+678 -506
+48 -2
src/AtpClient.php
··· 2 2 3 3 namespace SocialDept\AtpClient; 4 4 5 + use Illuminate\Http\Client\Factory; 6 + use SocialDept\AtpClient\Client\Client; 7 + use SocialDept\AtpClient\Client\AtprotoClient; 8 + use SocialDept\AtpClient\Client\BskyClient; 9 + use SocialDept\AtpClient\Client\ChatClient; 10 + use SocialDept\AtpClient\Client\OzoneClient; 11 + use SocialDept\AtpClient\Session\SessionManager; 12 + 5 13 class AtpClient 6 14 { 7 - // Build wonderful things 8 - } 15 + /** 16 + * Raw API communication/networking class 17 + */ 18 + public Client $client; 19 + 20 + /** 21 + * Collection of Bluesky (app.bsky.*) related functions 22 + */ 23 + public BskyClient $bsky; 24 + 25 + /** 26 + * Collection of AT Protocol (com.atproto.*) related functions 27 + */ 28 + public AtprotoClient $atproto; 29 + 30 + /** 31 + * Collection of Chat (chat.bsky.*) related functions 32 + */ 33 + public ChatClient $chat; 34 + 35 + /** 36 + * Collection of Ozone (tools.ozone.*) related functions 37 + */ 38 + public OzoneClient $ozone; 39 + 40 + public function __construct( 41 + SessionManager $sessions, 42 + Factory $http, 43 + string $identifier, 44 + ) { 45 + // Load the network client 46 + $this->client = new Client($this, $sessions, $http, $identifier); 47 + 48 + // Load all function collections 49 + $this->bsky = new BskyClient($this); 50 + $this->atproto = new AtprotoClient($this); 51 + $this->chat = new ChatClient($this); 52 + $this->ozone = new OzoneClient($this); 53 + } 54 + }
-1
src/AtpClientServiceProvider.php
··· 9 9 use SocialDept\AtpClient\Auth\DPoPNonceManager; 10 10 use SocialDept\AtpClient\Auth\OAuthEngine; 11 11 use SocialDept\AtpClient\Auth\TokenRefresher; 12 - use SocialDept\AtpClient\Client\AtpClient; 13 12 use SocialDept\AtpClient\Contracts\CredentialProvider; 14 13 use SocialDept\AtpClient\Contracts\KeyStore; 15 14 use SocialDept\AtpClient\Providers\ArrayCredentialProvider;
-64
src/Client/AtpClient.php
··· 1 - <?php 2 - 3 - namespace SocialDept\AtpClient\Client; 4 - 5 - use Illuminate\Http\Client\Factory; 6 - use SocialDept\AtpClient\Auth\DPoPNonceManager; 7 - use SocialDept\AtpClient\Session\SessionManager; 8 - 9 - class AtpClient 10 - { 11 - public function __construct( 12 - protected SessionManager $sessions, 13 - protected Factory $http, 14 - protected string $identifier, 15 - ) {} 16 - 17 - /** 18 - * Get Bluesky client (app.bsky.*) 19 - */ 20 - public function bsky(): BskyClient 21 - { 22 - return new BskyClient($this->sessions, $this->http, $this->identifier); 23 - } 24 - 25 - /** 26 - * Get AT Protocol client (com.atproto.*) 27 - */ 28 - public function atproto(): AtprotoClient 29 - { 30 - return new AtprotoClient($this->sessions, $this->http, $this->identifier); 31 - } 32 - 33 - /** 34 - * Get Chat client (chat.bsky.*) 35 - */ 36 - public function chat(): ChatClient 37 - { 38 - return new ChatClient($this->sessions, $this->http, $this->identifier); 39 - } 40 - 41 - /** 42 - * Get Ozone client (tools.ozone.*) 43 - */ 44 - public function ozone(): OzoneClient 45 - { 46 - return new OzoneClient($this->sessions, $this->http, $this->identifier); 47 - } 48 - 49 - /** 50 - * Get the current session identifier 51 - */ 52 - public function getIdentifier(): string 53 - { 54 - return $this->identifier; 55 - } 56 - 57 - /** 58 - * Get the session manager 59 - */ 60 - public function getSessionManager(): SessionManager 61 - { 62 - return $this->sessions; 63 - } 64 - }
+18 -128
src/Client/AtprotoClient.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Client; 4 4 5 - use Illuminate\Http\Client\Factory; 6 - use SocialDept\AtpClient\Auth\DPoPNonceManager; 7 - use SocialDept\AtpClient\Http\HasHttp; 8 - use SocialDept\AtpClient\Http\Response; 9 - use SocialDept\AtpClient\Session\SessionManager; 5 + use SocialDept\AtpClient\AtpClient; 6 + use SocialDept\AtpClient\Client\Requests\Atproto; 10 7 11 8 class AtprotoClient 12 9 { 13 - use HasHttp; 14 - 15 - public function __construct( 16 - SessionManager $sessions, 17 - Factory $http, 18 - string $identifier, 19 - ) { 20 - $this->sessions = $sessions; 21 - $this->http = $http; 22 - $this->identifier = $identifier; 23 - $this->nonceManager = app(DPoPNonceManager::class); 24 - } 25 - 26 10 /** 27 - * Create a record 28 - */ 29 - public function createRecord(string $repo, string $collection, array $record, ?string $rkey = null, bool $validate = true, ?string $swapCommit = null): Response 30 - { 31 - return $this->post('com.atproto.repo.createRecord', array_filter(compact('repo', 'collection', 'record', 'rkey', 'validate', 'swapCommit'), fn ($v) => ! is_null($v))); 32 - } 33 - 34 - /** 35 - * Delete a record 36 - */ 37 - public function deleteRecord(string $repo, string $collection, string $rkey, ?string $swapRecord = null, ?string $swapCommit = null): Response 38 - { 39 - return $this->post('com.atproto.repo.deleteRecord', array_filter(compact('repo', 'collection', 'rkey', 'swapRecord', 'swapCommit'), fn ($v) => ! is_null($v))); 40 - } 41 - 42 - /** 43 - * Put (upsert) a record 44 - */ 45 - public function putRecord(string $repo, string $collection, string $rkey, array $record, bool $validate = true, ?string $swapRecord = null, ?string $swapCommit = null): Response 46 - { 47 - return $this->post('com.atproto.repo.putRecord', array_filter(compact('repo', 'collection', 'rkey', 'record', 'validate', 'swapRecord', 'swapCommit'), fn ($v) => ! is_null($v))); 48 - } 49 - 50 - /** 51 - * Get a record 52 - */ 53 - public function getRecord(string $repo, string $collection, string $rkey, ?string $cid = null): Response 54 - { 55 - return $this->get('com.atproto.repo.getRecord', compact('repo', 'collection', 'rkey', 'cid')); 56 - } 57 - 58 - /** 59 - * List records in a collection 60 - */ 61 - public function listRecords(string $repo, string $collection, int $limit = 50, ?string $cursor = null, bool $reverse = false): Response 62 - { 63 - return $this->get('com.atproto.repo.listRecords', compact('repo', 'collection', 'limit', 'cursor', 'reverse')); 64 - } 65 - 66 - /** 67 - * Upload a blob 68 - */ 69 - public function uploadBlob(string $data, string $mimeType): Response 70 - { 71 - return $this->post('com.atproto.repo.uploadBlob', ['blob' => $data, 'mimeType' => $mimeType]); 72 - } 73 - 74 - /** 75 - * Describe the repository 76 - */ 77 - public function describeRepo(string $repo): Response 78 - { 79 - return $this->get('com.atproto.repo.describeRepo', compact('repo')); 80 - } 81 - 82 - /** 83 - * Get current session 11 + * The parent AtpClient instance 84 12 */ 85 - public function getSession(): Response 86 - { 87 - return $this->get('com.atproto.server.getSession'); 88 - } 13 + public AtpClient $atp; 89 14 90 15 /** 91 - * Describe server 16 + * Repository operations (com.atproto.repo.*) 92 17 */ 93 - public function describeServer(): Response 94 - { 95 - return $this->get('com.atproto.server.describeServer'); 96 - } 18 + public Atproto\Repo $repo; 97 19 98 20 /** 99 - * Resolve handle to DID 21 + * Server operations (com.atproto.server.*) 100 22 */ 101 - public function resolveHandle(string $handle): Response 102 - { 103 - return $this->get('com.atproto.identity.resolveHandle', compact('handle')); 104 - } 23 + public Atproto\Server $server; 105 24 106 25 /** 107 - * Update handle 26 + * Identity operations (com.atproto.identity.*) 108 27 */ 109 - public function updateHandle(string $handle): Response 110 - { 111 - return $this->post('com.atproto.identity.updateHandle', compact('handle')); 112 - } 28 + public Atproto\Identity $identity; 113 29 114 30 /** 115 - * Get blob from sync 31 + * Sync operations (com.atproto.sync.*) 116 32 */ 117 - public function getBlob(string $did, string $cid): Response 118 - { 119 - return $this->get('com.atproto.sync.getBlob', compact('did', 'cid')); 120 - } 33 + public Atproto\Sync $sync; 121 34 122 - /** 123 - * Get checkout from sync 124 - */ 125 - public function getCheckout(string $did): Response 126 - { 127 - return $this->get('com.atproto.sync.getCheckout', compact('did')); 128 - } 129 - 130 - /** 131 - * Get commit path from sync 132 - */ 133 - public function getCommitPath(string $did, ?string $latest = null, ?string $earliest = null): Response 134 - { 135 - return $this->get('com.atproto.sync.getCommitPath', compact('did', 'latest', 'earliest')); 136 - } 137 - 138 - /** 139 - * Get repo from sync 140 - */ 141 - public function getRepo(string $did, ?string $since = null): Response 142 - { 143 - return $this->get('com.atproto.sync.getRepo', compact('did', 'since')); 144 - } 145 - 146 - /** 147 - * List repos from sync 148 - */ 149 - public function listRepos(int $limit = 500, ?string $cursor = null): Response 35 + public function __construct(AtpClient $parent) 150 36 { 151 - return $this->get('com.atproto.sync.listRepos', compact('limit', 'cursor')); 37 + $this->atp = $parent; 38 + $this->repo = new Atproto\Repo($this); 39 + $this->server = new Atproto\Server($this); 40 + $this->identity = new Atproto\Identity($this); 41 + $this->sync = new Atproto\Sync($this); 152 42 } 153 43 }
+12 -62
src/Client/BskyClient.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Client; 4 4 5 - use Illuminate\Http\Client\Factory; 6 - use SocialDept\AtpClient\Auth\DPoPNonceManager; 7 - use SocialDept\AtpClient\Http\HasHttp; 8 - use SocialDept\AtpClient\Http\Response; 9 - use SocialDept\AtpClient\Session\SessionManager; 5 + use SocialDept\AtpClient\AtpClient; 6 + use SocialDept\AtpClient\Client\Requests\Bsky; 10 7 11 8 class BskyClient 12 9 { 13 - use HasHttp; 14 - 15 - public function __construct( 16 - SessionManager $sessions, 17 - Factory $http, 18 - string $identifier, 19 - ) { 20 - $this->sessions = $sessions; 21 - $this->http = $http; 22 - $this->identifier = $identifier; 23 - $this->nonceManager = app(DPoPNonceManager::class); 24 - } 25 - 26 10 /** 27 - * Get timeline feed 28 - */ 29 - public function getTimeline(int $limit = 50, ?string $cursor = null): Response 30 - { 31 - return $this->get('app.bsky.feed.getTimeline', compact('limit', 'cursor')); 32 - } 33 - 34 - /** 35 - * Get author feed 36 - */ 37 - public function getAuthorFeed(string $actor, int $limit = 50, ?string $cursor = null): Response 38 - { 39 - return $this->get('app.bsky.feed.getAuthorFeed', compact('actor', 'limit', 'cursor')); 40 - } 41 - 42 - /** 43 - * Get post thread 11 + * The parent AtpClient instance 44 12 */ 45 - public function getPostThread(string $uri, int $depth = 6): Response 46 - { 47 - return $this->get('app.bsky.feed.getPostThread', compact('uri', 'depth')); 48 - } 13 + public AtpClient $atp; 49 14 50 15 /** 51 - * Get actor profile 16 + * Feed operations (app.bsky.feed.*) 52 17 */ 53 - public function getProfile(string $actor): Response 54 - { 55 - return $this->get('app.bsky.actor.getProfile', compact('actor')); 56 - } 18 + public Bsky\Feed $feed; 57 19 58 20 /** 59 - * Search posts 21 + * Actor operations (app.bsky.actor.*) 60 22 */ 61 - public function searchPosts(string $q, int $limit = 25, ?string $cursor = null): Response 62 - { 63 - return $this->get('app.bsky.feed.searchPosts', compact('q', 'limit', 'cursor')); 64 - } 65 - 66 - /** 67 - * Get likes for a post 68 - */ 69 - public function getLikes(string $uri, int $limit = 50, ?string $cursor = null): Response 70 - { 71 - return $this->get('app.bsky.feed.getLikes', compact('uri', 'limit', 'cursor')); 72 - } 23 + public Bsky\Actor $actor; 73 24 74 - /** 75 - * Get reposts for a post 76 - */ 77 - public function getRepostedBy(string $uri, int $limit = 50, ?string $cursor = null): Response 25 + public function __construct(AtpClient $parent) 78 26 { 79 - return $this->get('app.bsky.feed.getRepostedBy', compact('uri', 'limit', 'cursor')); 27 + $this->atp = $parent; 28 + $this->feed = new Bsky\Feed($this); 29 + $this->actor = new Bsky\Actor($this); 80 30 } 81 31 }
+12 -126
src/Client/ChatClient.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Client; 4 4 5 - use Illuminate\Http\Client\Factory; 6 - use SocialDept\AtpClient\Auth\DPoPNonceManager; 7 - use SocialDept\AtpClient\Http\HasHttp; 8 - use SocialDept\AtpClient\Http\Response; 9 - use SocialDept\AtpClient\Session\SessionManager; 5 + use SocialDept\AtpClient\AtpClient; 6 + use SocialDept\AtpClient\Client\Requests\Chat; 10 7 11 8 class ChatClient 12 9 { 13 - use HasHttp; 14 - 15 - public function __construct( 16 - SessionManager $sessions, 17 - Factory $http, 18 - string $identifier, 19 - ) { 20 - $this->sessions = $sessions; 21 - $this->http = $http; 22 - $this->identifier = $identifier; 23 - $this->nonceManager = app(DPoPNonceManager::class); 24 - } 25 - 26 10 /** 27 - * Get conversation 28 - */ 29 - public function getConvo(string $convoId): Response 30 - { 31 - return $this->get('chat.bsky.convo.getConvo', compact('convoId')); 32 - } 33 - 34 - /** 35 - * Get conversation for members 36 - */ 37 - public function getConvoForMembers(array $members): Response 38 - { 39 - return $this->get('chat.bsky.convo.getConvoForMembers', compact('members')); 40 - } 41 - 42 - /** 43 - * List conversations 44 - */ 45 - public function listConvos(int $limit = 50, ?string $cursor = null): Response 46 - { 47 - return $this->get('chat.bsky.convo.listConvos', compact('limit', 'cursor')); 48 - } 49 - 50 - /** 51 - * Get messages 52 - */ 53 - public function getMessages(string $convoId, int $limit = 50, ?string $cursor = null): Response 54 - { 55 - return $this->get('chat.bsky.convo.getMessages', compact('convoId', 'limit', 'cursor')); 56 - } 57 - 58 - /** 59 - * Send message 60 - */ 61 - public function sendMessage(string $convoId, array $message): Response 62 - { 63 - return $this->post('chat.bsky.convo.sendMessage', compact('convoId', 'message')); 64 - } 65 - 66 - /** 67 - * Send message batch 68 - */ 69 - public function sendMessageBatch(array $items): Response 70 - { 71 - return $this->post('chat.bsky.convo.sendMessageBatch', compact('items')); 72 - } 73 - 74 - /** 75 - * Delete message 11 + * The parent AtpClient instance 76 12 */ 77 - public function deleteMessageForSelf(string $convoId, string $messageId): Response 78 - { 79 - return $this->post('chat.bsky.convo.deleteMessageForSelf', compact('convoId', 'messageId')); 80 - } 13 + public AtpClient $atp; 81 14 82 15 /** 83 - * Update read status 16 + * Conversation operations (chat.bsky.convo.*) 84 17 */ 85 - public function updateRead(string $convoId, ?string $messageId = null): Response 86 - { 87 - return $this->post('chat.bsky.convo.updateRead', compact('convoId', 'messageId')); 88 - } 18 + public Chat\Convo $convo; 89 19 90 20 /** 91 - * Mute conversation 21 + * Actor operations (chat.bsky.actor.*) 92 22 */ 93 - public function muteConvo(string $convoId): Response 94 - { 95 - return $this->post('chat.bsky.convo.muteConvo', compact('convoId')); 96 - } 23 + public Chat\Actor $actor; 97 24 98 - /** 99 - * Unmute conversation 100 - */ 101 - public function unmuteConvo(string $convoId): Response 25 + public function __construct(AtpClient $parent) 102 26 { 103 - return $this->post('chat.bsky.convo.unmuteConvo', compact('convoId')); 104 - } 105 - 106 - /** 107 - * Leave conversation 108 - */ 109 - public function leaveConvo(string $convoId): Response 110 - { 111 - return $this->post('chat.bsky.convo.leaveConvo', compact('convoId')); 112 - } 113 - 114 - /** 115 - * Get log 116 - */ 117 - public function getLog(?string $cursor = null): Response 118 - { 119 - return $this->get('chat.bsky.convo.getLog', compact('cursor')); 120 - } 121 - 122 - /** 123 - * Get actor metadata 124 - */ 125 - public function getActorMetadata(): Response 126 - { 127 - return $this->get('chat.bsky.actor.getActorMetadata'); 128 - } 129 - 130 - /** 131 - * Export account data 132 - */ 133 - public function exportAccountData(): Response 134 - { 135 - return $this->get('chat.bsky.actor.exportAccountData'); 136 - } 137 - 138 - /** 139 - * Delete account 140 - */ 141 - public function deleteAccount(): Response 142 - { 143 - return $this->post('chat.bsky.actor.deleteAccount'); 27 + $this->atp = $parent; 28 + $this->convo = new Chat\Convo($this); 29 + $this->actor = new Chat\Actor($this); 144 30 } 145 31 }
+32
src/Client/Client.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client; 4 + 5 + use Illuminate\Http\Client\Factory; 6 + use SocialDept\AtpClient\AtpClient; 7 + use SocialDept\AtpClient\Auth\DPoPNonceManager; 8 + use SocialDept\AtpClient\Http\HasHttp; 9 + use SocialDept\AtpClient\Session\SessionManager; 10 + 11 + class Client 12 + { 13 + use HasHttp; 14 + 15 + /** 16 + * The parent AtpClient instance we belong to 17 + */ 18 + public AtpClient $atp; 19 + 20 + public function __construct( 21 + AtpClient $parent, 22 + SessionManager $sessions, 23 + Factory $http, 24 + string $identifier, 25 + ) { 26 + $this->atp = $parent; 27 + $this->sessions = $sessions; 28 + $this->http = $http; 29 + $this->identifier = $identifier; 30 + $this->nonceManager = app(DPoPNonceManager::class); 31 + } 32 + }
+15 -123
src/Client/OzoneClient.php
··· 2 2 3 3 namespace SocialDept\AtpClient\Client; 4 4 5 - use Illuminate\Http\Client\Factory; 6 - use SocialDept\AtpClient\Auth\DPoPNonceManager; 7 - use SocialDept\AtpClient\Http\HasHttp; 8 - use SocialDept\AtpClient\Http\Response; 9 - use SocialDept\AtpClient\Session\SessionManager; 5 + use SocialDept\AtpClient\AtpClient; 6 + use SocialDept\AtpClient\Client\Requests\Ozone; 10 7 11 8 class OzoneClient 12 9 { 13 - use HasHttp; 14 - 15 - public function __construct( 16 - SessionManager $sessions, 17 - Factory $http, 18 - string $identifier, 19 - ) { 20 - $this->sessions = $sessions; 21 - $this->http = $http; 22 - $this->identifier = $identifier; 23 - $this->nonceManager = app(DPoPNonceManager::class); 24 - } 25 - 26 10 /** 27 - * Get moderation event 28 - */ 29 - public function getModerationEvent(int $id): Response 30 - { 31 - return $this->get('tools.ozone.moderation.getEvent', compact('id')); 32 - } 33 - 34 - /** 35 - * Get moderation events 36 - */ 37 - public function getModerationEvents(?string $subject = null, ?array $types = null, ?string $createdBy = null, int $limit = 50, ?string $cursor = null): Response 38 - { 39 - return $this->get('tools.ozone.moderation.getEvents', array_filter(compact('subject', 'types', 'createdBy', 'limit', 'cursor'), fn ($v) => ! is_null($v))); 40 - } 41 - 42 - /** 43 - * Get record 44 - */ 45 - public function getRecord(string $uri, ?string $cid = null): Response 46 - { 47 - return $this->get('tools.ozone.moderation.getRecord', compact('uri', 'cid')); 48 - } 49 - 50 - /** 51 - * Get repo 52 - */ 53 - public function getRepo(string $did): Response 54 - { 55 - return $this->get('tools.ozone.moderation.getRepo', compact('did')); 56 - } 57 - 58 - /** 59 - * Query events 60 - */ 61 - public function queryEvents(?array $types = null, ?string $createdBy = null, ?string $subject = null, int $limit = 50, ?string $cursor = null, bool $sortDirection = false): Response 62 - { 63 - return $this->get('tools.ozone.moderation.queryEvents', array_filter(compact('types', 'createdBy', 'subject', 'limit', 'cursor', 'sortDirection'), fn ($v) => ! is_null($v))); 64 - } 65 - 66 - /** 67 - * Query statuses 68 - */ 69 - public function queryStatuses(?string $subject = null, ?array $tags = null, ?string $excludeTags = null, int $limit = 50, ?string $cursor = null): Response 70 - { 71 - return $this->get('tools.ozone.moderation.queryStatuses', array_filter(compact('subject', 'tags', 'excludeTags', 'limit', 'cursor'), fn ($v) => ! is_null($v))); 72 - } 73 - 74 - /** 75 - * Search repos 11 + * The parent AtpClient instance 76 12 */ 77 - public function searchRepos(?string $term = null, ?string $invitedBy = null, int $limit = 50, ?string $cursor = null): Response 78 - { 79 - return $this->get('tools.ozone.moderation.searchRepos', array_filter(compact('term', 'invitedBy', 'limit', 'cursor'), fn ($v) => ! is_null($v))); 80 - } 13 + public AtpClient $atp; 81 14 82 15 /** 83 - * Emit moderation event 16 + * Moderation operations (tools.ozone.moderation.*) 84 17 */ 85 - public function emitEvent(array $event, string $subject, array $subjectBlobCids = [], ?string $createdBy = null): Response 86 - { 87 - return $this->post('tools.ozone.moderation.emitEvent', compact('event', 'subject', 'subjectBlobCids', 'createdBy')); 88 - } 18 + public Ozone\Moderation $moderation; 89 19 90 20 /** 91 - * Get blob 21 + * Server operations (tools.ozone.server.*) 92 22 */ 93 - public function getBlob(string $did, string $cid): Response 94 - { 95 - return $this->get('tools.ozone.server.getBlob', compact('did', 'cid')); 96 - } 23 + public Ozone\Server $server; 97 24 98 25 /** 99 - * Get config 26 + * Team operations (tools.ozone.team.*) 100 27 */ 101 - public function getConfig(): Response 102 - { 103 - return $this->get('tools.ozone.server.getConfig'); 104 - } 28 + public Ozone\Team $team; 105 29 106 - /** 107 - * Get team member 108 - */ 109 - public function getTeamMember(string $did): Response 30 + public function __construct(AtpClient $parent) 110 31 { 111 - return $this->get('tools.ozone.team.getMember', compact('did')); 112 - } 113 - 114 - /** 115 - * List team members 116 - */ 117 - public function listTeamMembers(int $limit = 50, ?string $cursor = null): Response 118 - { 119 - return $this->get('tools.ozone.team.listMembers', compact('limit', 'cursor')); 120 - } 121 - 122 - /** 123 - * Add team member 124 - */ 125 - public function addTeamMember(string $did, string $role): Response 126 - { 127 - return $this->post('tools.ozone.team.addMember', compact('did', 'role')); 128 - } 129 - 130 - /** 131 - * Update team member 132 - */ 133 - public function updateTeamMember(string $did, ?bool $disabled = null, ?string $role = null): Response 134 - { 135 - return $this->post('tools.ozone.team.updateMember', array_filter(compact('did', 'disabled', 'role'), fn ($v) => ! is_null($v))); 136 - } 137 - 138 - /** 139 - * Delete team member 140 - */ 141 - public function deleteTeamMember(string $did): Response 142 - { 143 - return $this->post('tools.ozone.team.deleteMember', compact('did')); 32 + $this->atp = $parent; 33 + $this->moderation = new Ozone\Moderation($this); 34 + $this->server = new Ozone\Server($this); 35 + $this->team = new Ozone\Team($this); 144 36 } 145 37 }
+25
src/Client/Requests/Atproto/Identity.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Atproto; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Identity extends Request 9 + { 10 + /** 11 + * Resolve handle to DID 12 + */ 13 + public function resolveHandle(string $handle): Response 14 + { 15 + return $this->atp->client->get('com.atproto.identity.resolveHandle', compact('handle')); 16 + } 17 + 18 + /** 19 + * Update handle 20 + */ 21 + public function updateHandle(string $handle): Response 22 + { 23 + return $this->atp->client->post('com.atproto.identity.updateHandle', compact('handle')); 24 + } 25 + }
+65
src/Client/Requests/Atproto/Repo.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Atproto; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Repo extends Request 9 + { 10 + /** 11 + * Create a record 12 + */ 13 + public function createRecord(string $repo, string $collection, array $record, ?string $rkey = null, bool $validate = true, ?string $swapCommit = null): Response 14 + { 15 + return $this->atp->client->post('com.atproto.repo.createRecord', array_filter(compact('repo', 'collection', 'record', 'rkey', 'validate', 'swapCommit'), fn ($v) => ! is_null($v))); 16 + } 17 + 18 + /** 19 + * Delete a record 20 + */ 21 + public function deleteRecord(string $repo, string $collection, string $rkey, ?string $swapRecord = null, ?string $swapCommit = null): Response 22 + { 23 + return $this->atp->client->post('com.atproto.repo.deleteRecord', array_filter(compact('repo', 'collection', 'rkey', 'swapRecord', 'swapCommit'), fn ($v) => ! is_null($v))); 24 + } 25 + 26 + /** 27 + * Put (upsert) a record 28 + */ 29 + public function putRecord(string $repo, string $collection, string $rkey, array $record, bool $validate = true, ?string $swapRecord = null, ?string $swapCommit = null): Response 30 + { 31 + return $this->atp->client->post('com.atproto.repo.putRecord', array_filter(compact('repo', 'collection', 'rkey', 'record', 'validate', 'swapRecord', 'swapCommit'), fn ($v) => ! is_null($v))); 32 + } 33 + 34 + /** 35 + * Get a record 36 + */ 37 + public function getRecord(string $repo, string $collection, string $rkey, ?string $cid = null): Response 38 + { 39 + return $this->atp->client->get('com.atproto.repo.getRecord', compact('repo', 'collection', 'rkey', 'cid')); 40 + } 41 + 42 + /** 43 + * List records in a collection 44 + */ 45 + public function listRecords(string $repo, string $collection, int $limit = 50, ?string $cursor = null, bool $reverse = false): Response 46 + { 47 + return $this->atp->client->get('com.atproto.repo.listRecords', compact('repo', 'collection', 'limit', 'cursor', 'reverse')); 48 + } 49 + 50 + /** 51 + * Upload a blob 52 + */ 53 + public function uploadBlob(string $data, string $mimeType): Response 54 + { 55 + return $this->atp->client->post('com.atproto.repo.uploadBlob', ['blob' => $data, 'mimeType' => $mimeType]); 56 + } 57 + 58 + /** 59 + * Describe the repository 60 + */ 61 + public function describeRepo(string $repo): Response 62 + { 63 + return $this->atp->client->get('com.atproto.repo.describeRepo', compact('repo')); 64 + } 65 + }
+25
src/Client/Requests/Atproto/Server.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Atproto; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Server extends Request 9 + { 10 + /** 11 + * Get current session 12 + */ 13 + public function getSession(): Response 14 + { 15 + return $this->atp->client->get('com.atproto.server.getSession'); 16 + } 17 + 18 + /** 19 + * Describe server 20 + */ 21 + public function describeServer(): Response 22 + { 23 + return $this->atp->client->get('com.atproto.server.describeServer'); 24 + } 25 + }
+49
src/Client/Requests/Atproto/Sync.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Atproto; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Sync extends Request 9 + { 10 + /** 11 + * Get blob from sync 12 + */ 13 + public function getBlob(string $did, string $cid): Response 14 + { 15 + return $this->atp->client->get('com.atproto.sync.getBlob', compact('did', 'cid')); 16 + } 17 + 18 + /** 19 + * Get checkout from sync 20 + */ 21 + public function getCheckout(string $did): Response 22 + { 23 + return $this->atp->client->get('com.atproto.sync.getCheckout', compact('did')); 24 + } 25 + 26 + /** 27 + * Get commit path from sync 28 + */ 29 + public function getCommitPath(string $did, ?string $latest = null, ?string $earliest = null): Response 30 + { 31 + return $this->atp->client->get('com.atproto.sync.getCommitPath', compact('did', 'latest', 'earliest')); 32 + } 33 + 34 + /** 35 + * Get repo from sync 36 + */ 37 + public function getRepo(string $did, ?string $since = null): Response 38 + { 39 + return $this->atp->client->get('com.atproto.sync.getRepo', compact('did', 'since')); 40 + } 41 + 42 + /** 43 + * List repos from sync 44 + */ 45 + public function listRepos(int $limit = 500, ?string $cursor = null): Response 46 + { 47 + return $this->atp->client->get('com.atproto.sync.listRepos', compact('limit', 'cursor')); 48 + } 49 + }
+17
src/Client/Requests/Bsky/Actor.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Bsky; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Actor extends Request 9 + { 10 + /** 11 + * Get actor profile 12 + */ 13 + public function getProfile(string $actor): Response 14 + { 15 + return $this->atp->client->get('app.bsky.actor.getProfile', compact('actor')); 16 + } 17 + }
+57
src/Client/Requests/Bsky/Feed.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Bsky; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Feed extends Request 9 + { 10 + /** 11 + * Get timeline feed 12 + */ 13 + public function getTimeline(int $limit = 50, ?string $cursor = null): Response 14 + { 15 + return $this->atp->client->get('app.bsky.feed.getTimeline', compact('limit', 'cursor')); 16 + } 17 + 18 + /** 19 + * Get author feed 20 + */ 21 + public function getAuthorFeed(string $actor, int $limit = 50, ?string $cursor = null): Response 22 + { 23 + return $this->atp->client->get('app.bsky.feed.getAuthorFeed', compact('actor', 'limit', 'cursor')); 24 + } 25 + 26 + /** 27 + * Get post thread 28 + */ 29 + public function getPostThread(string $uri, int $depth = 6): Response 30 + { 31 + return $this->atp->client->get('app.bsky.feed.getPostThread', compact('uri', 'depth')); 32 + } 33 + 34 + /** 35 + * Search posts 36 + */ 37 + public function searchPosts(string $q, int $limit = 25, ?string $cursor = null): Response 38 + { 39 + return $this->atp->client->get('app.bsky.feed.searchPosts', compact('q', 'limit', 'cursor')); 40 + } 41 + 42 + /** 43 + * Get likes for a post 44 + */ 45 + public function getLikes(string $uri, int $limit = 50, ?string $cursor = null): Response 46 + { 47 + return $this->atp->client->get('app.bsky.feed.getLikes', compact('uri', 'limit', 'cursor')); 48 + } 49 + 50 + /** 51 + * Get reposts for a post 52 + */ 53 + public function getRepostedBy(string $uri, int $limit = 50, ?string $cursor = null): Response 54 + { 55 + return $this->atp->client->get('app.bsky.feed.getRepostedBy', compact('uri', 'limit', 'cursor')); 56 + } 57 + }
+33
src/Client/Requests/Chat/Actor.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Chat; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Actor extends Request 9 + { 10 + /** 11 + * Get actor metadata 12 + */ 13 + public function getActorMetadata(): Response 14 + { 15 + return $this->atp->client->get('chat.bsky.actor.getActorMetadata'); 16 + } 17 + 18 + /** 19 + * Export account data 20 + */ 21 + public function exportAccountData(): Response 22 + { 23 + return $this->atp->client->get('chat.bsky.actor.exportAccountData'); 24 + } 25 + 26 + /** 27 + * Delete account 28 + */ 29 + public function deleteAccount(): Response 30 + { 31 + return $this->atp->client->post('chat.bsky.actor.deleteAccount'); 32 + } 33 + }
+105
src/Client/Requests/Chat/Convo.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Chat; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Convo extends Request 9 + { 10 + /** 11 + * Get conversation 12 + */ 13 + public function getConvo(string $convoId): Response 14 + { 15 + return $this->atp->client->get('chat.bsky.convo.getConvo', compact('convoId')); 16 + } 17 + 18 + /** 19 + * Get conversation for members 20 + */ 21 + public function getConvoForMembers(array $members): Response 22 + { 23 + return $this->atp->client->get('chat.bsky.convo.getConvoForMembers', compact('members')); 24 + } 25 + 26 + /** 27 + * List conversations 28 + */ 29 + public function listConvos(int $limit = 50, ?string $cursor = null): Response 30 + { 31 + return $this->atp->client->get('chat.bsky.convo.listConvos', compact('limit', 'cursor')); 32 + } 33 + 34 + /** 35 + * Get messages 36 + */ 37 + public function getMessages(string $convoId, int $limit = 50, ?string $cursor = null): Response 38 + { 39 + return $this->atp->client->get('chat.bsky.convo.getMessages', compact('convoId', 'limit', 'cursor')); 40 + } 41 + 42 + /** 43 + * Send message 44 + */ 45 + public function sendMessage(string $convoId, array $message): Response 46 + { 47 + return $this->atp->client->post('chat.bsky.convo.sendMessage', compact('convoId', 'message')); 48 + } 49 + 50 + /** 51 + * Send message batch 52 + */ 53 + public function sendMessageBatch(array $items): Response 54 + { 55 + return $this->atp->client->post('chat.bsky.convo.sendMessageBatch', compact('items')); 56 + } 57 + 58 + /** 59 + * Delete message 60 + */ 61 + public function deleteMessageForSelf(string $convoId, string $messageId): Response 62 + { 63 + return $this->atp->client->post('chat.bsky.convo.deleteMessageForSelf', compact('convoId', 'messageId')); 64 + } 65 + 66 + /** 67 + * Update read status 68 + */ 69 + public function updateRead(string $convoId, ?string $messageId = null): Response 70 + { 71 + return $this->atp->client->post('chat.bsky.convo.updateRead', compact('convoId', 'messageId')); 72 + } 73 + 74 + /** 75 + * Mute conversation 76 + */ 77 + public function muteConvo(string $convoId): Response 78 + { 79 + return $this->atp->client->post('chat.bsky.convo.muteConvo', compact('convoId')); 80 + } 81 + 82 + /** 83 + * Unmute conversation 84 + */ 85 + public function unmuteConvo(string $convoId): Response 86 + { 87 + return $this->atp->client->post('chat.bsky.convo.unmuteConvo', compact('convoId')); 88 + } 89 + 90 + /** 91 + * Leave conversation 92 + */ 93 + public function leaveConvo(string $convoId): Response 94 + { 95 + return $this->atp->client->post('chat.bsky.convo.leaveConvo', compact('convoId')); 96 + } 97 + 98 + /** 99 + * Get log 100 + */ 101 + public function getLog(?string $cursor = null): Response 102 + { 103 + return $this->atp->client->get('chat.bsky.convo.getLog', compact('cursor')); 104 + } 105 + }
+73
src/Client/Requests/Ozone/Moderation.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Ozone; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Moderation extends Request 9 + { 10 + /** 11 + * Get moderation event 12 + */ 13 + public function getModerationEvent(int $id): Response 14 + { 15 + return $this->atp->client->get('tools.ozone.moderation.getEvent', compact('id')); 16 + } 17 + 18 + /** 19 + * Get moderation events 20 + */ 21 + public function getModerationEvents(?string $subject = null, ?array $types = null, ?string $createdBy = null, int $limit = 50, ?string $cursor = null): Response 22 + { 23 + return $this->atp->client->get('tools.ozone.moderation.getEvents', array_filter(compact('subject', 'types', 'createdBy', 'limit', 'cursor'), fn ($v) => ! is_null($v))); 24 + } 25 + 26 + /** 27 + * Get record 28 + */ 29 + public function getRecord(string $uri, ?string $cid = null): Response 30 + { 31 + return $this->atp->client->get('tools.ozone.moderation.getRecord', compact('uri', 'cid')); 32 + } 33 + 34 + /** 35 + * Get repo 36 + */ 37 + public function getRepo(string $did): Response 38 + { 39 + return $this->atp->client->get('tools.ozone.moderation.getRepo', compact('did')); 40 + } 41 + 42 + /** 43 + * Query events 44 + */ 45 + public function queryEvents(?array $types = null, ?string $createdBy = null, ?string $subject = null, int $limit = 50, ?string $cursor = null, bool $sortDirection = false): Response 46 + { 47 + return $this->atp->client->get('tools.ozone.moderation.queryEvents', array_filter(compact('types', 'createdBy', 'subject', 'limit', 'cursor', 'sortDirection'), fn ($v) => ! is_null($v))); 48 + } 49 + 50 + /** 51 + * Query statuses 52 + */ 53 + public function queryStatuses(?string $subject = null, ?array $tags = null, ?string $excludeTags = null, int $limit = 50, ?string $cursor = null): Response 54 + { 55 + return $this->atp->client->get('tools.ozone.moderation.queryStatuses', array_filter(compact('subject', 'tags', 'excludeTags', 'limit', 'cursor'), fn ($v) => ! is_null($v))); 56 + } 57 + 58 + /** 59 + * Search repos 60 + */ 61 + public function searchRepos(?string $term = null, ?string $invitedBy = null, int $limit = 50, ?string $cursor = null): Response 62 + { 63 + return $this->atp->client->get('tools.ozone.moderation.searchRepos', array_filter(compact('term', 'invitedBy', 'limit', 'cursor'), fn ($v) => ! is_null($v))); 64 + } 65 + 66 + /** 67 + * Emit moderation event 68 + */ 69 + public function emitEvent(array $event, string $subject, array $subjectBlobCids = [], ?string $createdBy = null): Response 70 + { 71 + return $this->atp->client->post('tools.ozone.moderation.emitEvent', compact('event', 'subject', 'subjectBlobCids', 'createdBy')); 72 + } 73 + }
+25
src/Client/Requests/Ozone/Server.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Ozone; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Server extends Request 9 + { 10 + /** 11 + * Get blob 12 + */ 13 + public function getBlob(string $did, string $cid): Response 14 + { 15 + return $this->atp->client->get('tools.ozone.server.getBlob', compact('did', 'cid')); 16 + } 17 + 18 + /** 19 + * Get config 20 + */ 21 + public function getConfig(): Response 22 + { 23 + return $this->atp->client->get('tools.ozone.server.getConfig'); 24 + } 25 + }
+49
src/Client/Requests/Ozone/Team.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests\Ozone; 4 + 5 + use SocialDept\AtpClient\Client\Requests\Request; 6 + use SocialDept\AtpClient\Http\Response; 7 + 8 + class Team extends Request 9 + { 10 + /** 11 + * Get team member 12 + */ 13 + public function getTeamMember(string $did): Response 14 + { 15 + return $this->atp->client->get('tools.ozone.team.getMember', compact('did')); 16 + } 17 + 18 + /** 19 + * List team members 20 + */ 21 + public function listTeamMembers(int $limit = 50, ?string $cursor = null): Response 22 + { 23 + return $this->atp->client->get('tools.ozone.team.listMembers', compact('limit', 'cursor')); 24 + } 25 + 26 + /** 27 + * Add team member 28 + */ 29 + public function addTeamMember(string $did, string $role): Response 30 + { 31 + return $this->atp->client->post('tools.ozone.team.addMember', compact('did', 'role')); 32 + } 33 + 34 + /** 35 + * Update team member 36 + */ 37 + public function updateTeamMember(string $did, ?bool $disabled = null, ?string $role = null): Response 38 + { 39 + return $this->atp->client->post('tools.ozone.team.updateMember', array_filter(compact('did', 'disabled', 'role'), fn ($v) => ! is_null($v))); 40 + } 41 + 42 + /** 43 + * Delete team member 44 + */ 45 + public function deleteTeamMember(string $did): Response 46 + { 47 + return $this->atp->client->post('tools.ozone.team.deleteMember', compact('did')); 48 + } 49 + }
+18
src/Client/Requests/Request.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Client\Requests; 4 + 5 + use SocialDept\AtpClient\AtpClient; 6 + 7 + class Request 8 + { 9 + /** 10 + * The parent AtpClient instance we belong to 11 + */ 12 + public AtpClient $atp; 13 + 14 + public function __construct($parent) 15 + { 16 + $this->atp = $parent->atp; 17 + } 18 + }