Skip to content

Commit

Permalink
upgrade sdk to dart 3
Browse files Browse the repository at this point in the history
  • Loading branch information
javoeria committed Dec 14, 2023
1 parent 94ecdee commit 2c6c6a6
Show file tree
Hide file tree
Showing 50 changed files with 126 additions and 115 deletions.
38 changes: 26 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
# Files and directories created by pub
.dart_tool/
.packages
# Remove the following pattern if you wish to check in your lock file
pubspec.lock
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# Conventional directory for build outputs
build/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Directory created by dartdoc
doc/api/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

.vscode/
.idea/
*.iml
# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
build/
10 changes: 10 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "b0366e0a3f089e15fd89c97604ab402fe26b724c"
channel: "stable"

project_type: package
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.2.0

* Requires Dart 3.0 or later.
* Replace `TopType` enum with `AnimeType` and `MangaType` respectively.

## 2.1.0

* Updated `Review` and `UserReview` models.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# jikan_api

[Jikan](https://jikan.moe/) is an **Unofficial** MyAnimeList API. It scrapes the website to satisfy the need for a complete API - which MyAnimeList lacks.

[![Build Status](https://github.com/javoeria/jikan-dart/actions/workflows/dart.yml/badge.svg?branch=master)](https://github.com/javoeria/jikan-dart/actions/workflows/dart.yml)
[![pub package](https://img.shields.io/pub/v/jikan_api.svg)](https://pub.dev/packages/jikan_api)

Expand Down Expand Up @@ -78,8 +80,8 @@ Future<BuiltList<Anime>> getSchedules({WeekDay? weekday, int page = 1});
### Top

```dart
Future<BuiltList<Anime>> getTopAnime({TopType? type, TopFilter? filter, int page = 1});
Future<BuiltList<Manga>> getTopManga({TopType? type, TopFilter? filter, int page = 1});
Future<BuiltList<Anime>> getTopAnime({AnimeType? type, TopFilter? filter, int page = 1});
Future<BuiltList<Manga>> getTopManga({MangaType? type, TopFilter? filter, int page = 1});
Future<BuiltList<Person>> getTopPeople({int page = 1});
Future<BuiltList<Character>> getTopCharacters({int page = 1});
Future<BuiltList<UserReview>> getTopReviews({int page = 1});
Expand Down
4 changes: 2 additions & 2 deletions example/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:jikan_api/jikan_api.dart';

void main() async {
var jikan = Jikan();
var top = await jikan.getTopAnime(type: TopType.tv, filter: TopFilter.airing);
final jikan = Jikan();
final top = await jikan.getTopAnime(type: AnimeType.tv);
print(top);
}
48 changes: 23 additions & 25 deletions lib/src/jikan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ class Jikan {
return json.decode(response.body);
}

String _enumToString(Object o) => o.toString().split('.')[1];

Future<Anime> getAnime(int id) async {
var url = '/anime/$id/full';
var url = id == 0 ? '/random/anime' : '/anime/$id/full';
var response = await _getResponse(url);

return Anime.fromJson(response['data']);
Expand Down Expand Up @@ -88,7 +86,7 @@ class Jikan {

Future<BuiltList<Forum>> getAnimeForum(int id, {ForumType? type}) async {
var url = '/anime/$id/forum';
if (type != null) url += '?filter=${_enumToString(type)}';
if (type != null) url += '?filter=${type.name}';
var response = await _getResponse(url);

final topics = response['data'] ?? [];
Expand Down Expand Up @@ -143,15 +141,15 @@ class Jikan {
}

Future<BuiltList<Review>> getAnimeReviews(int id, {int page = 1}) async {
var url = '/anime/$id/reviews?page=$page';
var url = '/anime/$id/reviews?page=$page&preliminary=true&spoilers=true';
var response = await _getResponse(url);

final reviews = response['data'] ?? [];
return BuiltList(reviews.map((i) => Review.fromJson(i)));
}

Future<Manga> getManga(int id) async {
var url = '/manga/$id/full';
var url = id == 0 ? '/random/manga' : '/manga/$id/full';
var response = await _getResponse(url);

return Manga.fromJson(response['data']);
Expand All @@ -175,7 +173,7 @@ class Jikan {

Future<BuiltList<Forum>> getMangaForum(int id, {ForumType? type}) async {
var url = '/manga/$id/forum';
if (type != null) url += '?filter=${_enumToString(type)}';
if (type != null) url += '?filter=${type.name}';
var response = await _getResponse(url);

final topics = response['data'] ?? [];
Expand Down Expand Up @@ -222,15 +220,15 @@ class Jikan {
}

Future<BuiltList<Review>> getMangaReviews(int id, {int page = 1}) async {
var url = '/manga/$id/reviews?page=$page';
var url = '/manga/$id/reviews?page=$page&preliminary=true&spoilers=true';
var response = await _getResponse(url);

final reviews = response['data'] ?? [];
return BuiltList(reviews.map((i) => Review.fromJson(i)));
}

Future<Person> getPerson(int id) async {
var url = '/people/$id/full';
var url = id == 0 ? '/random/people' : '/people/$id/full';
var response = await _getResponse(url);

return Person.fromJson(response['data']);
Expand All @@ -245,7 +243,7 @@ class Jikan {
}

Future<Character> getCharacter(int id) async {
var url = '/characters/$id/full';
var url = id == 0 ? '/random/characters' : '/characters/$id/full';
var response = await _getResponse(url);

return Character.fromJson(response['data']);
Expand All @@ -270,7 +268,7 @@ class Jikan {
int page = 1}) async {
var url = '/anime?page=$page';
if (query != null) url += '&q=$query';
if (type != null) url += '&type=${_enumToString(type)}';
if (type != null) url += '&type=${type.name}';
if (genres != null) url += '&genres=${genres.join(',')}';
if (producers != null) url += '&producers=${producers.join(',')}';
if (orderBy != null) url += '&order_by=$orderBy';
Expand All @@ -293,7 +291,7 @@ class Jikan {
int page = 1}) async {
var url = '/manga?page=$page';
if (query != null) url += '&q=$query';
if (type != null) url += '&type=${_enumToString(type)}';
if (type != null) url += '&type=${type.name}';
if (genres != null) url += '&genres=${genres.join(',')}';
if (magazines != null) url += '&magazines=${magazines.join(',')}';
if (orderBy != null) url += '&order_by=$orderBy';
Expand Down Expand Up @@ -333,7 +331,7 @@ class Jikan {
{int? year, SeasonType? season, int page = 1}) async {
var url = '/seasons';
if (year != null && season != null) {
url += '/$year/${_enumToString(season)}?page=$page';
url += '/$year/${season.name}?page=$page';
} else {
url += '/now?page=$page';
}
Expand Down Expand Up @@ -362,29 +360,29 @@ class Jikan {
Future<BuiltList<Anime>> getSchedules(
{WeekDay? weekday, int page = 1}) async {
var url = '/schedules?page=$page';
if (weekday != null) url += '&filter=${_enumToString(weekday)}';
if (weekday != null) url += '&filter=${weekday.name}';
var response = await _getResponse(url);

final anime = response['data'] ?? [];
return BuiltList(anime.map((i) => Anime.fromJson(i)));
}

Future<BuiltList<Anime>> getTopAnime(
{TopType? type, TopFilter? filter, int page = 1}) async {
{AnimeType? type, TopFilter? filter, int page = 1}) async {
var url = '/top/anime?page=$page';
if (type != null) url += '&type=${_enumToString(type)}';
if (filter != null) url += '&filter=${_enumToString(filter)}';
if (type != null) url += '&type=${type.name}';
if (filter != null) url += '&filter=${filter.name}';
var response = await _getResponse(url);

final top = response['data'] ?? [];
return BuiltList(top.map((i) => Anime.fromJson(i)));
}

Future<BuiltList<Manga>> getTopManga(
{TopType? type, TopFilter? filter, int page = 1}) async {
{MangaType? type, TopFilter? filter, int page = 1}) async {
var url = '/top/manga?page=$page';
if (type != null) url += '&type=${_enumToString(type)}';
if (filter != null) url += '&filter=${_enumToString(filter)}';
if (type != null) url += '&type=${type.name}';
if (filter != null) url += '&filter=${filter.name}';
var response = await _getResponse(url);

final top = response['data'] ?? [];
Expand Down Expand Up @@ -417,7 +415,7 @@ class Jikan {

Future<BuiltList<Genre>> getAnimeGenres({GenreType? type}) async {
var url = '/genres/anime';
if (type != null) url += '?filter=${_enumToString(type)}';
if (type != null) url += '?filter=${type.name}';
var response = await _getResponse(url);

final genres = response['data'] ?? [];
Expand All @@ -426,7 +424,7 @@ class Jikan {

Future<BuiltList<Genre>> getMangaGenres({GenreType? type}) async {
var url = '/genres/manga';
if (type != null) url += '?filter=${_enumToString(type)}';
if (type != null) url += '?filter=${type.name}';
var response = await _getResponse(url);

final genres = response['data'] ?? [];
Expand Down Expand Up @@ -467,7 +465,7 @@ class Jikan {
Future<BuiltList<History>> getUserHistory(String username,
{HistoryType? type}) async {
var url = '/users/$username/history';
if (type != null) url += '?type=${_enumToString(type)}';
if (type != null) url += '?type=${type.name}';
var response = await _getResponse(url);

final history = response['data'] ?? [];
Expand Down Expand Up @@ -510,15 +508,15 @@ class Jikan {
}

Future<BuiltList<UserReview>> getRecentAnimeReviews({int page = 1}) async {
var url = '/reviews/anime?page=$page';
var url = '/reviews/anime?page=$page&preliminary=true&spoilers=true';
var response = await _getResponse(url);

final reviews = response['data'] ?? [];
return BuiltList(reviews.map((i) => UserReview.fromJson(i)));
}

Future<BuiltList<UserReview>> getRecentMangaReviews({int page = 1}) async {
var url = '/reviews/manga?page=$page';
var url = '/reviews/manga?page=$page&preliminary=true&spoilers=true';
var response = await _getResponse(url);

final reviews = response['data'] ?? [];
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/anime/anime.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/anime/anime_meta.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/anime/episode.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/anime/promo.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/character/character.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/character/character_meta.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/common/archive.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/common/article.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/common/entry_meta.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/common/forum.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/common/meta.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/common/picture.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/common/reactions.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/model/common/recommendation.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2c6c6a6

Please sign in to comment.