setMangaReadingStatus method

Future<Result> setMangaReadingStatus(
  1. String sessionToken,
  2. String mangaId,
  3. ReadingStatus? status
)
inherited

Endpoint used: POST /manga/{id}/status

Set the reading status for a certain manga to status If no reading status is supplied to it, the reading status is set as 'reading'

Implementation

Future<Result> setMangaReadingStatus(
    String sessionToken, String mangaId, ReadingStatus? status) async {
  var statusString =
      status != null ? EnumUtils.parseStatusFromEnum(status) : 'reading';
  var unencodedPath = '/manga/$mangaId/status';
  final uri = 'https://$AUTHORITY$unencodedPath';
  var response = await http.post(Uri.parse(uri),
      headers: {
        HttpHeaders.contentTypeHeader: 'application/json',
        HttpHeaders.authorizationHeader: 'Bearer $sessionToken',
      },
      body: jsonEncode({
        'status': '$statusString',
      }));
  try {
    return Result.fromJson(jsonDecode(response.body));
  } on Exception {
    throw MangadexServerException(jsonDecode(response.body));
  }
}