Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the discover api #89

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/utils/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ enum SortTvShowsBy {
firstAirDateDesc
}

enum FilterTvShowsByStatus {
returningSeries,
planned,
inProduction,
ended,
cancelled,
pilot
}

enum FilterTvShowsByType {
documentary,
news,
miniseries,
reality,
scripted,
talkShow,
video,
}

//find.dart
enum ExternalId { imdbId, tvdbId, facebookId, twitterId, instagramId }

Expand Down
90 changes: 90 additions & 0 deletions lib/versions/v3/category/discover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class Discover extends Category<V3> {
int? withRunTimeGreaterThan,
int? withRuntimeLessThan,
String? withOrginalLanguage,
String? withWatchProviders,
String? watchRegion,
String? withWatchMonetizationTypes,
String? withoutCompanies,
}) {
//all the default values
final queries = <String>[
Expand Down Expand Up @@ -170,6 +174,22 @@ class Discover extends Category<V3> {
queries.add('with_original_language=$withOrginalLanguage');
}

if (withWatchProviders != null) {
queries.add('with_watch_providers=$withWatchProviders');
}

if (watchRegion != null) {
queries.add('watch_region=$watchRegion');
}

if (withWatchMonetizationTypes != null) {
queries.add('with_watch_monetization_types=$withWatchMonetizationTypes');
}

if (withoutCompanies != null) {
queries.add('without_companies=$withoutCompanies');
}

return _v._query('$_endPoint/movie', optionalQueries: queries);
}

Expand Down Expand Up @@ -212,6 +232,12 @@ class Discover extends Category<V3> {
String? withoutKeywords,
bool? screenedTheatrically,
String? withCompanies,
String? withWatchProviders,
String? watchRegion,
String? withWatchMonetizationTypes,
String? withoutCompanies,
FilterTvShowsByStatus? withStatus,
FilterTvShowsByType? withType,
}) {
//all the default values
final queries = <String>[
Expand Down Expand Up @@ -297,6 +323,30 @@ class Discover extends Category<V3> {
queries.add('without_keywords=$withoutKeywords');
}

if (withWatchProviders != null) {
queries.add('with_watch_providers=$withWatchProviders');
}

if (watchRegion != null) {
queries.add('watch_region=$watchRegion');
}

if (withWatchMonetizationTypes != null) {
queries.add('with_watch_monetization_types=$withWatchMonetizationTypes');
}

if (withoutCompanies != null) {
queries.add('without_companies=$withoutCompanies');
}

if (withStatus != null) {
queries.add('with_status=${_getFilterTvShowsByStatus(withStatus)}');
}

if (withType != null) {
queries.add('with_status=${_getFilterTvShowsByType(withType)}');
}

return _v._query('$_endPoint/tv', optionalQueries: queries);
}

Expand Down Expand Up @@ -353,4 +403,44 @@ class Discover extends Category<V3> {
return 'popularity.asc';
}
}

String _getFilterTvShowsByStatus(FilterTvShowsByStatus filter) {
switch (filter) {
case FilterTvShowsByStatus.returningSeries:
return '0';
case FilterTvShowsByStatus.planned:
return '1';
case FilterTvShowsByStatus.inProduction:
return '2';
case FilterTvShowsByStatus.ended:
return '3';
case FilterTvShowsByStatus.cancelled:
return '4';
case FilterTvShowsByStatus.pilot:
return '5';
default:
return '0';
}
}

String _getFilterTvShowsByType(FilterTvShowsByType filter) {
switch (filter) {
case FilterTvShowsByType.documentary:
return '0';
case FilterTvShowsByType.news:
return '1';
case FilterTvShowsByType.miniseries:
return '2';
case FilterTvShowsByType.reality:
return '3';
case FilterTvShowsByType.scripted:
return '4';
case FilterTvShowsByType.talkShow:
return '5';
case FilterTvShowsByType.video:
return '6';
default:
return '0';
}
}
}