mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 20:52:32 +00:00
chore: Add retrofit & adopt in Overseerr (#608)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
export 'api/overseerr.dart';
|
||||
export 'api/commands.dart';
|
||||
export 'api/models.dart';
|
||||
export 'api/types.dart';
|
||||
export 'api/utilities.dart';
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/// Library containing all logic and accessors to make calls to Overseerr's API.
|
||||
library overseerr_commands;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'models.dart';
|
||||
import 'types.dart';
|
||||
|
||||
// Requests
|
||||
part 'src/commands/requests.dart';
|
||||
part 'src/commands/requests/get_request_count.dart';
|
||||
part 'src/commands/requests/get_request.dart';
|
||||
part 'src/commands/requests/get_requests.dart';
|
||||
|
||||
// Status
|
||||
part 'src/commands/status.dart';
|
||||
part 'src/commands/status/get_status.dart';
|
||||
part 'src/commands/status/get_status_appdata.dart';
|
||||
|
||||
// User
|
||||
part 'src/commands/users.dart';
|
||||
part 'src/commands/users/get_user_quota.dart';
|
||||
part 'src/commands/users/get_user.dart';
|
||||
part 'src/commands/users/get_users.dart';
|
||||
@@ -1,23 +1,12 @@
|
||||
/// Library containing all model definitions for Overseerr data.
|
||||
library overseerr_models;
|
||||
|
||||
// Media
|
||||
export 'src/models/media/media.dart';
|
||||
|
||||
// Requests
|
||||
export 'src/models/requests/request_count.dart';
|
||||
export 'src/models/requests/request_page.dart';
|
||||
export 'src/models/requests/request.dart';
|
||||
|
||||
// Status
|
||||
export 'src/models/status/status.dart';
|
||||
export 'src/models/status/status_appdata.dart';
|
||||
|
||||
// User
|
||||
export 'src/models/users/user_page.dart';
|
||||
export 'src/models/users/user_quota.dart';
|
||||
export 'src/models/users/user.dart';
|
||||
|
||||
// General
|
||||
export 'src/models/page.dart';
|
||||
export 'src/models/quota.dart';
|
||||
export 'models/media/media.dart';
|
||||
export 'models/media/season.dart';
|
||||
export 'models/requests/request_count.dart';
|
||||
export 'models/requests/request_page.dart';
|
||||
export 'models/requests/request.dart';
|
||||
export 'models/status/status.dart';
|
||||
export 'models/status/status_appdata.dart';
|
||||
export 'models/users/user_page.dart';
|
||||
export 'models/users/user_quota.dart';
|
||||
export 'models/users/user.dart';
|
||||
export 'models/page.dart';
|
||||
export 'models/quota.dart';
|
||||
|
||||
133
lib/modules/overseerr/api/models/media/media.dart
Normal file
133
lib/modules/overseerr/api/models/media/media.dart
Normal file
@@ -0,0 +1,133 @@
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/overseerr.dart';
|
||||
|
||||
part 'media.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
class OverseerrMedia {
|
||||
@JsonKey(name: 'id')
|
||||
int? id;
|
||||
|
||||
@JsonKey(
|
||||
name: 'mediaType',
|
||||
fromJson: OverseerrUtilities.mediaTypeFromJson,
|
||||
toJson: OverseerrUtilities.mediaTypeToJson,
|
||||
)
|
||||
OverseerrMediaType? mediaType;
|
||||
|
||||
@JsonKey(name: 'tmdbId')
|
||||
int? tmdbId;
|
||||
|
||||
@JsonKey(name: 'tvdbId')
|
||||
int? tvdbId;
|
||||
|
||||
@JsonKey(name: 'imdbId')
|
||||
String? imdbId;
|
||||
|
||||
@JsonKey(
|
||||
name: 'status',
|
||||
fromJson: OverseerrUtilities.requestStatusFromJson,
|
||||
toJson: OverseerrUtilities.requestStatusToJson,
|
||||
)
|
||||
OverseerrRequestStatus? status;
|
||||
|
||||
@JsonKey(
|
||||
name: 'status4k',
|
||||
fromJson: OverseerrUtilities.requestStatusFromJson,
|
||||
toJson: OverseerrUtilities.requestStatusToJson,
|
||||
)
|
||||
OverseerrRequestStatus? status4k;
|
||||
|
||||
@JsonKey(
|
||||
name: 'createdAt',
|
||||
fromJson: OverseerrUtilities.dateTimeFromJson,
|
||||
toJson: OverseerrUtilities.dateTimeToJson,
|
||||
)
|
||||
DateTime? createdAt;
|
||||
|
||||
@JsonKey(
|
||||
name: 'updatedAt',
|
||||
fromJson: OverseerrUtilities.dateTimeFromJson,
|
||||
toJson: OverseerrUtilities.dateTimeToJson,
|
||||
)
|
||||
DateTime? updatedAt;
|
||||
|
||||
@JsonKey(
|
||||
name: 'lastSeasonChange',
|
||||
fromJson: OverseerrUtilities.dateTimeFromJson,
|
||||
toJson: OverseerrUtilities.dateTimeToJson,
|
||||
)
|
||||
DateTime? lastSeasonChange;
|
||||
|
||||
@JsonKey(
|
||||
name: 'mediaAddedAt',
|
||||
fromJson: OverseerrUtilities.dateTimeFromJson,
|
||||
toJson: OverseerrUtilities.dateTimeToJson,
|
||||
)
|
||||
DateTime? mediaAddedAt;
|
||||
|
||||
@JsonKey(name: 'serviceId')
|
||||
int? serviceId;
|
||||
|
||||
@JsonKey(name: 'serviceId4k')
|
||||
int? serviceId4k;
|
||||
|
||||
@JsonKey(name: 'externalServiceId')
|
||||
int? externalServiceId;
|
||||
|
||||
@JsonKey(name: 'externalServiceId4k')
|
||||
int? externalServiceId4k;
|
||||
|
||||
@JsonKey(name: 'externalServiceSlug')
|
||||
String? externalServiceSlug;
|
||||
|
||||
@JsonKey(name: 'externalServiceSlug4k')
|
||||
String? externalServiceSlug4k;
|
||||
|
||||
@JsonKey(name: 'ratingKey')
|
||||
String? ratingKey;
|
||||
|
||||
@JsonKey(name: 'ratingKey4k')
|
||||
String? ratingKey4k;
|
||||
|
||||
@JsonKey(name: 'plexUrl')
|
||||
String? plexUrl;
|
||||
|
||||
@JsonKey(name: 'serviceUrl')
|
||||
String? serviceUrl;
|
||||
|
||||
OverseerrMedia({
|
||||
this.id,
|
||||
this.mediaType,
|
||||
this.tmdbId,
|
||||
this.tvdbId,
|
||||
this.imdbId,
|
||||
this.status,
|
||||
this.status4k,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.lastSeasonChange,
|
||||
this.mediaAddedAt,
|
||||
this.serviceId,
|
||||
this.serviceId4k,
|
||||
this.externalServiceId,
|
||||
this.externalServiceId4k,
|
||||
this.externalServiceSlug,
|
||||
this.externalServiceSlug4k,
|
||||
this.ratingKey,
|
||||
this.ratingKey4k,
|
||||
this.plexUrl,
|
||||
this.serviceUrl,
|
||||
});
|
||||
|
||||
/// Returns a JSON-encoded string version of this object.
|
||||
@override
|
||||
String toString() => json.encode(this.toJson());
|
||||
|
||||
/// Deserialize a JSON map to a [OverseerrMedia] object.
|
||||
factory OverseerrMedia.fromJson(Map<String, dynamic> json) =>
|
||||
_$OverseerrMediaFromJson(json);
|
||||
|
||||
/// Serialize a [OverseerrMedia] object to a JSON map.
|
||||
Map<String, dynamic> toJson() => _$OverseerrMediaToJson(this);
|
||||
}
|
||||
53
lib/modules/overseerr/api/models/media/season.dart
Normal file
53
lib/modules/overseerr/api/models/media/season.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/overseerr.dart';
|
||||
|
||||
part 'season.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
class OverseerrSeason {
|
||||
@JsonKey(name: 'id')
|
||||
int? id;
|
||||
|
||||
@JsonKey(name: 'seasonNumber')
|
||||
int? seasonNumber;
|
||||
|
||||
@JsonKey(
|
||||
name: 'status',
|
||||
fromJson: OverseerrUtilities.requestStatusFromJson,
|
||||
toJson: OverseerrUtilities.requestStatusToJson,
|
||||
)
|
||||
OverseerrRequestStatus? status;
|
||||
|
||||
@JsonKey(
|
||||
name: 'createdAt',
|
||||
fromJson: OverseerrUtilities.dateTimeFromJson,
|
||||
toJson: OverseerrUtilities.dateTimeToJson,
|
||||
)
|
||||
DateTime? createdAt;
|
||||
|
||||
@JsonKey(
|
||||
name: 'updatedAt',
|
||||
fromJson: OverseerrUtilities.dateTimeFromJson,
|
||||
toJson: OverseerrUtilities.dateTimeToJson,
|
||||
)
|
||||
DateTime? updatedAt;
|
||||
|
||||
OverseerrSeason({
|
||||
this.id,
|
||||
this.seasonNumber,
|
||||
this.status,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
/// Returns a JSON-encoded string version of this object.
|
||||
@override
|
||||
String toString() => json.encode(this.toJson());
|
||||
|
||||
/// Deserialize a JSON map to a [OverseerrSeason] object.
|
||||
factory OverseerrSeason.fromJson(Map<String, dynamic> json) =>
|
||||
_$OverseerrSeasonFromJson(json);
|
||||
|
||||
/// Serialize a [OverseerrSeason] object to a JSON map.
|
||||
Map<String, dynamic> toJson() => _$OverseerrSeasonToJson(this);
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import '../../../types.dart';
|
||||
import '../../../utilities.dart';
|
||||
import '../media/media.dart';
|
||||
import '../users/user.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/overseerr.dart';
|
||||
|
||||
part 'request.g.dart';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
part 'request_count.g.dart';
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import '../page.dart';
|
||||
import './request.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/overseerr.dart';
|
||||
|
||||
part 'request_page.g.dart';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
part 'status.g.dart';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
part 'status_appdata.g.dart';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import '../../../utilities.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/overseerr.dart';
|
||||
|
||||
part 'user.g.dart';
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import '../page.dart';
|
||||
import './user.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/overseerr.dart';
|
||||
|
||||
part 'user_page.g.dart';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import '../quota.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/overseerr.dart';
|
||||
|
||||
part 'user_quota.g.dart';
|
||||
|
||||
@@ -1,112 +1,67 @@
|
||||
/// Dart library package to facilitate the communication to and from [Overseerr](https://overseerr.dev)'s API:
|
||||
/// A request management and media discovery tool for the Plex ecosystem
|
||||
///
|
||||
/// This library gives access to [overseerr_commands], and is needed as the only entrypoint.
|
||||
library overseerr;
|
||||
|
||||
// Imports
|
||||
import 'package:dio/dio.dart';
|
||||
import 'commands.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
import 'models.dart';
|
||||
|
||||
/// The core class to handle all connections to Overseerr.
|
||||
/// Gives you easy access to all implemented command handlers, initialized and ready to call.
|
||||
///
|
||||
/// [Overseerr] handles the creation of the initial [Dio] HTTP client & command handlers.
|
||||
/// You can optionally use the factory `.from()` to define your own [Dio] HTTP client.
|
||||
class Overseerr {
|
||||
/// Internal constructor
|
||||
Overseerr._internal({
|
||||
required this.httpClient,
|
||||
required this.requests,
|
||||
required this.status,
|
||||
required this.users,
|
||||
});
|
||||
part 'overseerr.g.dart';
|
||||
|
||||
/// Create a new Overseerr API connection manager to connection to your instance.
|
||||
/// This default factory/constructor will create the [Dio] HTTP client for you given the parameters.
|
||||
///
|
||||
/// Required Parameters:
|
||||
/// - `host`: String that contains the protocol (http:// or https://), the host itself, and the base URL (if applicable)
|
||||
/// - `apiKey`: The API key fetched from Overseerr's web interface
|
||||
///
|
||||
/// Optional Parameters:
|
||||
/// - `headers`: Map that contains additional headers that should be attached to all requests
|
||||
/// - `followRedirects`: If the HTTP client should follow URL redirects
|
||||
/// - `maxRedirects`: The maximum amount of redirects the client should follow (does nothing if `followRedirects` is false)
|
||||
@RestApi()
|
||||
abstract class Overseerr {
|
||||
factory Overseerr({
|
||||
required String host,
|
||||
required String apiKey,
|
||||
Map<String, dynamic>? headers,
|
||||
bool followRedirects = true,
|
||||
int maxRedirects = 5,
|
||||
Map<String, dynamic> headers = const {},
|
||||
}) {
|
||||
// Build the HTTP client
|
||||
String _baseUrl = host.endsWith('/') ? '${host}api/v1/' : '$host/api/v1/';
|
||||
Dio _dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: host.endsWith('/') ? '${host}api/v1/' : '$host/api/v1/',
|
||||
headers: {
|
||||
'X-Api-Key': apiKey,
|
||||
if (headers != null) ...headers,
|
||||
...headers,
|
||||
},
|
||||
followRedirects: followRedirects,
|
||||
maxRedirects: maxRedirects,
|
||||
followRedirects: true,
|
||||
maxRedirects: 5,
|
||||
),
|
||||
);
|
||||
return Overseerr._internal(
|
||||
httpClient: _dio,
|
||||
requests: OverseerrCommandHandlerRequests(_dio),
|
||||
status: OverseerrCommandHandlerStatus(_dio),
|
||||
users: OverseerrCommandHandlerUsers(_dio),
|
||||
);
|
||||
return _Overseerr(_dio, baseUrl: _baseUrl);
|
||||
}
|
||||
|
||||
/// Create a new Overseerr API connection manager to connection to your instance.
|
||||
///
|
||||
/// This factory allows you to define your own [Dio] HTTP client.
|
||||
/// Please ensure you set [BaseOptions] to include:
|
||||
/// - `baseUrl`: The URL to your Overseerr instance
|
||||
/// - `queryParameters`: The key `apikey` with the value of your API key.
|
||||
///
|
||||
/// Without these you will not be able to achieve a successful connection. See example below for bare minimum [Dio] configuration:
|
||||
/// ```dart
|
||||
/// Dio(
|
||||
/// BaseOptions(
|
||||
/// baseUrl: '<your instance URL>',
|
||||
/// queryParameters: {
|
||||
/// 'apikey': '<your API key>',
|
||||
/// },
|
||||
/// ),
|
||||
/// );
|
||||
/// ```
|
||||
factory Overseerr.from({
|
||||
required Dio client,
|
||||
}) {
|
||||
return Overseerr._internal(
|
||||
httpClient: client,
|
||||
requests: OverseerrCommandHandlerRequests(client),
|
||||
status: OverseerrCommandHandlerStatus(client),
|
||||
users: OverseerrCommandHandlerUsers(client),
|
||||
);
|
||||
}
|
||||
@GET('request')
|
||||
Future<OverseerrRequestPage> getRequests({
|
||||
@Query('take') int? take,
|
||||
@Query('skip') int? skip,
|
||||
@Query('filter') String? filter,
|
||||
@Query('sort') String? sort,
|
||||
@Query('requestedBy') int? requestedBy,
|
||||
});
|
||||
|
||||
/// The [Dio] HTTP client built during initialization.
|
||||
///
|
||||
/// Making changes to the [Dio] client should propogate to the command handlers, but is not recommended.
|
||||
/// The recommended way to make changes to the HTTP client is to use the `.from()` factory to build your own [Dio] HTTP client.
|
||||
final Dio httpClient;
|
||||
@GET('request/{id}')
|
||||
Future<OverseerrRequest> getRequest({
|
||||
@Path('id') required String id,
|
||||
});
|
||||
|
||||
/// Command handler for all request command-related API calls.
|
||||
///
|
||||
/// _Check the documentation to see all API calls that fall under this category._
|
||||
final OverseerrCommandHandlerRequests requests;
|
||||
@GET('request/count')
|
||||
Future<OverseerrRequestCount> getRequestCount();
|
||||
|
||||
/// Command handler for all status command-related API calls.
|
||||
///
|
||||
/// _Check the documentation to see all API calls that fall under this category._
|
||||
final OverseerrCommandHandlerStatus status;
|
||||
@GET('status')
|
||||
Future<OverseerrStatus> getStatus();
|
||||
|
||||
/// Command handler for all user command-related API calls.
|
||||
///
|
||||
/// _Check the documentation to see all API calls that fall under this category._
|
||||
final OverseerrCommandHandlerUsers users;
|
||||
@GET('status/appdata')
|
||||
Future<OverseerrStatusAppData> getStatusAppData();
|
||||
|
||||
@GET('user')
|
||||
Future<OverseerrUserPage> getUsers({
|
||||
@Query('take') int? take,
|
||||
@Query('skip') int? skip,
|
||||
@Query('sort') String? sort,
|
||||
});
|
||||
|
||||
@GET('user/{id}')
|
||||
Future<OverseerrUserPage> getUser({
|
||||
@Path('id') required String id,
|
||||
});
|
||||
|
||||
@GET('user/{id}/quota')
|
||||
Future<OverseerrUserQuota> getUserQuota({
|
||||
@Path('id') required String id,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
/// Facilitates, encapsulates, and manages individual calls related to requests within Overseerr.
|
||||
///
|
||||
/// [OverseerrCommandHandlerRequests] internally handles routing the HTTP client to the API calls.
|
||||
// ignore: camel_case_types
|
||||
class OverseerrCommandHandlerRequests {
|
||||
final Dio _client;
|
||||
|
||||
/// Create a command handler using an initialized [Dio] client.
|
||||
OverseerrCommandHandlerRequests(this._client);
|
||||
|
||||
/// Handler for [request/count](https://api-docs.overseerr.dev/#/request/get_request_count).
|
||||
///
|
||||
/// Returns the number of pending and approved requests.
|
||||
Future<OverseerrRequestCount> getRequestCount() async =>
|
||||
_commandGetRequestCount(_client);
|
||||
|
||||
/// Handler for [request/${requestId}](https://api-docs.overseerr.dev/#/request/get_request__requestId_).
|
||||
///
|
||||
/// Returns a specific media request.
|
||||
Future<OverseerrRequest> getRequestByID({
|
||||
required int id,
|
||||
}) async =>
|
||||
_commandGetRequest(
|
||||
_client,
|
||||
id: id,
|
||||
);
|
||||
|
||||
/// Handler for [request](https://api-docs.overseerr.dev/#/request/get_request).
|
||||
///
|
||||
/// Returns all requests.
|
||||
///
|
||||
/// - [take] a specific amount of requests
|
||||
/// - [skip] to a different page
|
||||
/// - [sort] the incoming list
|
||||
/// - [filter] the incoming list
|
||||
/// - [requestBy] the given user
|
||||
Future<OverseerrRequestPage> getRequests({
|
||||
int? take,
|
||||
int? skip,
|
||||
OverseerrRequestFilterType? filter,
|
||||
OverseerrRequestSortType? sort,
|
||||
OverseerrUser? requestedBy,
|
||||
}) async =>
|
||||
_commandGetRequests(
|
||||
_client,
|
||||
take: take,
|
||||
skip: skip,
|
||||
sort: sort,
|
||||
filter: filter,
|
||||
requestedBy: requestedBy,
|
||||
);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
Future<OverseerrRequest> _commandGetRequest(
|
||||
Dio client, {
|
||||
required int id,
|
||||
}) async {
|
||||
Response response = await client.get('request/$id');
|
||||
return OverseerrRequest.fromJson(response.data);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
Future<OverseerrRequestCount> _commandGetRequestCount(Dio client) async {
|
||||
Response response = await client.get('request/count');
|
||||
return OverseerrRequestCount.fromJson(response.data);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
Future<OverseerrRequestPage> _commandGetRequests(
|
||||
Dio client, {
|
||||
int? take,
|
||||
int? skip,
|
||||
OverseerrRequestFilterType? filter,
|
||||
OverseerrRequestSortType? sort,
|
||||
OverseerrUser? requestedBy,
|
||||
}) async {
|
||||
Response response = await client.get(
|
||||
'request',
|
||||
queryParameters: {
|
||||
if (take != null) 'take': take,
|
||||
if (skip != null) 'skip': skip,
|
||||
if (sort != null) 'sort': sort.value,
|
||||
if (filter != null) 'filter': filter.value,
|
||||
if (requestedBy != null) 'requestedBy': requestedBy.id,
|
||||
},
|
||||
);
|
||||
return OverseerrRequestPage.fromJson(response.data);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
/// Facilitates, encapsulates, and manages individual calls related to statuses within Overseerr.
|
||||
///
|
||||
/// [OverseerrCommandHandlerStatus] internally handles routing the HTTP client to the API calls.
|
||||
class OverseerrCommandHandlerStatus {
|
||||
final Dio _client;
|
||||
|
||||
/// Create a command handler using an initialized [Dio] client.
|
||||
OverseerrCommandHandlerStatus(this._client);
|
||||
|
||||
/// Handler for [status](https://api-docs.overseerr.dev/#/public/get_status).
|
||||
///
|
||||
/// Returns the current Overseerr version and commit hash.
|
||||
Future<OverseerrStatus> getStatus() async => _commandGetStatus(_client);
|
||||
|
||||
/// Handler for [status/appdata](https://api-docs.overseerr.dev/#/public/get_status_appdata).
|
||||
///
|
||||
/// For Docker installs, returns whether or not the volume mount was configured properly.
|
||||
/// Always returns true for non-Docker installs.
|
||||
Future<OverseerrStatusAppData> getAppData() async =>
|
||||
_commandGetStatusAppData(_client);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
Future<OverseerrStatus> _commandGetStatus(Dio client) async {
|
||||
Response response = await client.get('status');
|
||||
return OverseerrStatus.fromJson(response.data);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
Future<OverseerrStatusAppData> _commandGetStatusAppData(Dio client) async {
|
||||
Response response = await client.get('status/appdata');
|
||||
return OverseerrStatusAppData.fromJson(response.data);
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
/// Facilitates, encapsulates, and manages individual calls related to users within Overseerr.
|
||||
///
|
||||
/// [OverseerrCommandHandlerUsers] internally handles routing the HTTP client to the API calls.
|
||||
class OverseerrCommandHandlerUsers {
|
||||
final Dio _client;
|
||||
|
||||
/// Create a command handler using an initialized [Dio] client.
|
||||
OverseerrCommandHandlerUsers(this._client);
|
||||
|
||||
/// Handler for [user](https://api-docs.overseerr.dev/#/users/get_user).
|
||||
///
|
||||
/// Returns all users.
|
||||
///
|
||||
/// - [take] a specific amount of users
|
||||
/// - [skip] to a different page
|
||||
/// - [sort] the incoming list
|
||||
Future<OverseerrUserPage> getUsers({
|
||||
int? take,
|
||||
int? skip,
|
||||
OverseerrUserSortType? sort,
|
||||
}) async =>
|
||||
_commandGetUsers(
|
||||
_client,
|
||||
take: take,
|
||||
skip: skip,
|
||||
sort: sort,
|
||||
);
|
||||
|
||||
/// Handler for [user/${userId}](https://api-docs.overseerr.dev/#/users/get_user__userId_).
|
||||
///
|
||||
/// Returns a single user.
|
||||
Future<OverseerrUser> getUserByID({
|
||||
required int id,
|
||||
}) async =>
|
||||
_commandGetUser(
|
||||
_client,
|
||||
id: id,
|
||||
);
|
||||
|
||||
/// Handler for [user/${userId}/quota](https://api-docs.overseerr.dev/#/users/get_user__userId__quota).
|
||||
///
|
||||
/// Returns quota details for a user.
|
||||
Future<OverseerrUserQuota> getUserQuota({
|
||||
required int id,
|
||||
}) async =>
|
||||
_commandGetUserQuota(
|
||||
_client,
|
||||
id: id,
|
||||
);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
Future<OverseerrUser> _commandGetUser(
|
||||
Dio client, {
|
||||
required int id,
|
||||
}) async {
|
||||
Response response = await client.get('user/$id');
|
||||
return OverseerrUser.fromJson(response.data);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
Future<OverseerrUserQuota> _commandGetUserQuota(
|
||||
Dio client, {
|
||||
required int id,
|
||||
}) async {
|
||||
Response response = await client.get('user/$id/quota');
|
||||
return OverseerrUserQuota.fromJson(response.data);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
part of overseerr_commands;
|
||||
|
||||
Future<OverseerrUserPage> _commandGetUsers(
|
||||
Dio client, {
|
||||
int? take,
|
||||
int? skip,
|
||||
OverseerrUserSortType? sort,
|
||||
}) async {
|
||||
Response response = await client.get(
|
||||
'user',
|
||||
queryParameters: {
|
||||
if (take != null) 'take': take,
|
||||
if (skip != null) 'skip': skip,
|
||||
if (sort != null) 'sort': sort.value,
|
||||
},
|
||||
);
|
||||
return OverseerrUserPage.fromJson(response.data);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import '../../../types.dart';
|
||||
import '../../../utilities.dart';
|
||||
|
||||
part 'media.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
class OverseerrMedia {
|
||||
@JsonKey(name: 'id')
|
||||
int? id;
|
||||
|
||||
@JsonKey(
|
||||
name: 'mediaType',
|
||||
fromJson: OverseerrUtilities.mediaTypeFromJson,
|
||||
toJson: OverseerrUtilities.mediaTypeToJson,
|
||||
)
|
||||
OverseerrMediaType? mediaType;
|
||||
|
||||
@JsonKey(name: 'tmdbId')
|
||||
int? tmdbId;
|
||||
|
||||
@JsonKey(name: 'tvdbId')
|
||||
int? tvdbId;
|
||||
|
||||
@JsonKey(name: 'imdbId')
|
||||
String? imdbId;
|
||||
|
||||
OverseerrMedia({
|
||||
this.id,
|
||||
this.mediaType,
|
||||
this.tmdbId,
|
||||
this.tvdbId,
|
||||
this.imdbId,
|
||||
});
|
||||
|
||||
/// Returns a JSON-encoded string version of this object.
|
||||
@override
|
||||
String toString() => json.encode(this.toJson());
|
||||
|
||||
/// Deserialize a JSON map to a [OverseerrMedia] object.
|
||||
factory OverseerrMedia.fromJson(Map<String, dynamic> json) =>
|
||||
_$OverseerrMediaFromJson(json);
|
||||
|
||||
/// Serialize a [OverseerrMedia] object to a JSON map.
|
||||
Map<String, dynamic> toJson() => _$OverseerrMediaToJson(this);
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
/// Library containing all type definitions for Overseerr data.
|
||||
library overseerr_types;
|
||||
|
||||
part './src/types/media_status.dart';
|
||||
part './src/types/media_type.dart';
|
||||
part './src/types/request_filter_type.dart';
|
||||
part './src/types/request_sort_type.dart';
|
||||
part './src/types/request_status.dart';
|
||||
part './src/types/user_sort_type.dart';
|
||||
export 'types/media_status.dart';
|
||||
export 'types/media_type.dart';
|
||||
export 'types/request_filter_type.dart';
|
||||
export 'types/request_sort_type.dart';
|
||||
export 'types/request_status.dart';
|
||||
export 'types/user_sort_type.dart';
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
part of overseerr_types;
|
||||
|
||||
enum OverseerrMediaStatus {
|
||||
UNKNOWN,
|
||||
PENDING,
|
||||
@@ -1,5 +1,3 @@
|
||||
part of overseerr_types;
|
||||
|
||||
enum OverseerrMediaType {
|
||||
MOVIE,
|
||||
TV,
|
||||
@@ -1,5 +1,3 @@
|
||||
part of overseerr_types;
|
||||
|
||||
enum OverseerrRequestFilterType {
|
||||
ALL,
|
||||
APPROVED,
|
||||
@@ -1,5 +1,3 @@
|
||||
part of overseerr_types;
|
||||
|
||||
enum OverseerrRequestSortType {
|
||||
ADDED,
|
||||
MODIFIED,
|
||||
@@ -1,5 +1,3 @@
|
||||
part of overseerr_types;
|
||||
|
||||
enum OverseerrRequestStatus {
|
||||
PENDING,
|
||||
APPROVED,
|
||||
@@ -1,5 +1,3 @@
|
||||
part of overseerr_types;
|
||||
|
||||
enum OverseerrUserSortType {
|
||||
CREATED,
|
||||
DISPLAY_NAME,
|
||||
@@ -1,14 +1,6 @@
|
||||
/// Library containing all utility functions for Overseerr data.
|
||||
library overseerr_utilities;
|
||||
|
||||
import 'types.dart';
|
||||
|
||||
/// [OverseerrUtilities] gives access to static, functional operations. These are mainly used for the (de)serialization of received JSON data.
|
||||
///
|
||||
/// [OverseerrUtilities] cannot be initialized, all available functions are available statically.
|
||||
class OverseerrUtilities {
|
||||
OverseerrUtilities._();
|
||||
|
||||
abstract class OverseerrUtilities {
|
||||
static DateTime? dateTimeFromJson(String? date) =>
|
||||
DateTime.tryParse(date ?? '');
|
||||
static String? dateTimeToJson(DateTime? date) => date?.toIso8601String();
|
||||
|
||||
@@ -28,8 +28,7 @@ class _State extends State<OverseerrRequestsListView> {
|
||||
await context
|
||||
.read<OverseerrState>()
|
||||
.api
|
||||
?.requests
|
||||
.getRequests(
|
||||
?.getRequests(
|
||||
take: OverseerrDatabaseValue.CONTENT_PAGE_SIZE.data,
|
||||
skip: pageKey * pageSize,
|
||||
)
|
||||
|
||||
@@ -27,9 +27,8 @@ class _State extends State<OverseerrUserListView> {
|
||||
final int pageSize = OverseerrDatabaseValue.CONTENT_PAGE_SIZE.data;
|
||||
await context
|
||||
.read<OverseerrState>()
|
||||
.api!
|
||||
.users
|
||||
.getUsers(
|
||||
.api
|
||||
?.getUsers(
|
||||
take: OverseerrDatabaseValue.CONTENT_PAGE_SIZE.data,
|
||||
skip: pageKey * pageSize,
|
||||
)
|
||||
|
||||
@@ -132,11 +132,10 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
|
||||
return;
|
||||
}
|
||||
Overseerr(
|
||||
host: _profile.overseerrHost!,
|
||||
apiKey: _profile.overseerrKey!,
|
||||
host: _profile.overseerrHost ?? '',
|
||||
apiKey: _profile.overseerrKey ?? '',
|
||||
headers: Map<String, dynamic>.from(_profile.overseerrHeaders ?? {}),
|
||||
)
|
||||
.status
|
||||
.getStatus()
|
||||
.then(
|
||||
(_) => showLunaSuccessSnackBar(
|
||||
|
||||
Reference in New Issue
Block a user