+15
-12
src/Client/Records/PostRecordClient.php
+15
-12
src/Client/Records/PostRecordClient.php
···
7
7
use SocialDept\AtpClient\Builders\PostBuilder;
8
8
use SocialDept\AtpClient\Client\Requests\Request;
9
9
use SocialDept\AtpClient\Contracts\Recordable;
10
+
use SocialDept\AtpClient\Data\Record;
11
+
use SocialDept\AtpClient\Data\Responses\Atproto\Repo\CreateRecordResponse;
12
+
use SocialDept\AtpClient\Data\Responses\Atproto\Repo\DeleteRecordResponse;
13
+
use SocialDept\AtpClient\Data\Responses\Atproto\Repo\PutRecordResponse;
10
14
use SocialDept\AtpClient\Data\StrongRef;
11
15
use SocialDept\AtpClient\Enums\Nsid\BskyFeed;
12
16
use SocialDept\AtpClient\Enums\Scope;
···
37
41
?array $reply = null,
38
42
?array $langs = null,
39
43
?DateTimeInterface $createdAt = null
40
-
): StrongRef {
44
+
): CreateRecordResponse {
41
45
// Handle different input types
42
46
if (is_string($content)) {
43
47
$record = [
···
72
76
$record['$type'] = BskyFeed::Post->value;
73
77
}
74
78
75
-
$response = $this->atp->atproto->repo->createRecord(
79
+
return $this->atp->atproto->repo->createRecord(
76
80
repo: $this->atp->client->session()->did(),
77
81
collection: BskyFeed::Post,
78
82
record: $record
79
83
);
80
-
81
-
return StrongRef::fromResponse($response->json());
82
84
}
83
85
84
86
/**
···
88
90
*/
89
91
#[ScopedEndpoint(Scope::TransitionGeneric, granular: 'rpc:com.atproto.repo.putRecord')]
90
92
#[ScopedEndpoint(Scope::TransitionGeneric, granular: 'repo:app.bsky.feed.post?action=update')]
91
-
public function update(string $rkey, array $record): StrongRef
93
+
public function update(string $rkey, array $record): PutRecordResponse
92
94
{
93
95
// Ensure $type is set
94
96
if (! isset($record['$type'])) {
95
97
$record['$type'] = BskyFeed::Post->value;
96
98
}
97
99
98
-
$response = $this->atp->atproto->repo->putRecord(
100
+
return $this->atp->atproto->repo->putRecord(
99
101
repo: $this->atp->client->session()->did(),
100
102
collection: BskyFeed::Post,
101
103
rkey: $rkey,
102
104
record: $record
103
105
);
104
-
105
-
return StrongRef::fromResponse($response->toArray());
106
106
}
107
107
108
108
/**
···
112
112
*/
113
113
#[ScopedEndpoint(Scope::TransitionGeneric, granular: 'rpc:com.atproto.repo.deleteRecord')]
114
114
#[ScopedEndpoint(Scope::TransitionGeneric, granular: 'repo:app.bsky.feed.post?action=delete')]
115
-
public function delete(string $rkey): void
115
+
public function delete(string $rkey): DeleteRecordResponse
116
116
{
117
-
$this->atp->atproto->repo->deleteRecord(
117
+
return $this->atp->atproto->repo->deleteRecord(
118
118
repo: $this->atp->client->session()->did(),
119
119
collection: BskyFeed::Post,
120
120
rkey: $rkey
···
127
127
* @requires transition:generic (rpc:com.atproto.repo.getRecord)
128
128
*/
129
129
#[ScopedEndpoint(Scope::TransitionGeneric, granular: 'rpc:com.atproto.repo.getRecord')]
130
-
public function get(string $rkey, ?string $cid = null): PostView
130
+
public function get(string $rkey, ?string $cid = null): Record
131
131
{
132
132
$response = $this->atp->atproto->repo->getRecord(
133
133
repo: $this->atp->client->session()->did(),
···
136
136
cid: $cid
137
137
);
138
138
139
-
return PostView::fromArray($response->value);
139
+
return Record::fromArray(
140
+
data: $response->toArray(),
141
+
transformer: fn($value) => PostView::fromArray($response->value)
142
+
);
140
143
}
141
144
142
145
}