All in GraphQL #34

Merged
timw4mail merged 87 commits from develop into master 2020-12-01 10:07:49 -05:00
4 changed files with 44 additions and 25 deletions
Showing only changes of commit 4c1c78577e - Show all commits

View File

@ -0,0 +1,32 @@
mutation(
$id: ID!,
$notes: String,
$private: Boolean,
$progress: Int,
$ratingTwenty: Int,
$reconsumeCount: Int!,
$reconsuming: Boolean,
$status: LibraryEntryStatus!,
) {
updateLibraryEntry(input: {
id: $id,
notes: $notes
private: $private
progress: $progress
rating: $ratingTwenty
reconsumeCount: $reconsumeCount
reconsuming: $reconsuming
status: $status
}) {
libraryEntry {
id
notes
private
progress
rating
reconsumeCount
reconsuming
status
}
}
}

View File

@ -151,29 +151,16 @@ final class ListItem extends AbstractListItem {
*/
public function update(string $id, FormItemData $data): Request
{
$authHeader = $this->getAuthHeader();
$requestData = [
'data' => [
'id' => $id,
'type' => 'libraryEntries',
'attributes' => $data
]
];
if (((int) $data->progress) === 0)
{
$data->progress = 0;
}
$request = $this->requestBuilder->newRequest('PATCH', "library-entries/{$id}")
->setJsonBody($requestData);
if ($authHeader !== NULL)
{
$request = $request->setHeader('Authorization', $authHeader);
}
return $request->getFullRequest();
return $this->requestBuilder->mutateRequest('UpdateLibraryItem', [
'id' => $id,
'notes' => $data['notes'],
'private' => (bool)$data['private'],
'progress' => (int)$data['progress'],
'ratingTwenty' => (int)$data['ratingTwenty'],
'reconsumeCount' => (int)$data['reconsumeCount'],
'reconsuming' => (bool)$data['reconsuming'],
'status' => strtoupper($data['status']),
]);
}
/**

View File

@ -255,7 +255,7 @@ class Anime extends API {
$results = $requester->makeRequests();
$body = Json::decode($results['kitsu']);
$statusCode = array_key_exists('error', $body) ? 400: 200;
$statusCode = array_key_exists('errors', $body) ? 400: 200;
return [
'body' => Json::decode($results['kitsu']),

View File

@ -171,7 +171,7 @@ class Manga extends API {
$results = $requester->makeRequests();
$body = Json::decode($results['kitsu']);
$statusCode = array_key_exists('error', $body) ? 400: 200;
$statusCode = array_key_exists('errors', $body) ? 400: 200;
return [
'body' => Json::decode($results['kitsu']),