mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-24 12:46:49 +08:00
add login client type
This commit is contained in:
@@ -98,6 +98,23 @@ abstract class _EHApi {
|
||||
// ignore: unused_element
|
||||
@Part(name: "secure") bool? secure,
|
||||
// ignore: unused_element
|
||||
@Part(name: "client") String? client,
|
||||
// ignore: unused_element
|
||||
@Part(name: "device") String? device,
|
||||
// ignore: unused_element
|
||||
@Part(name: "client_version") String? clientVersion,
|
||||
// ignore: unused_element
|
||||
@Part(name: "client_platform") String? clientPlatform,
|
||||
// ignore: unused_element
|
||||
@CancelRequest() CancelToken? cancel});
|
||||
@PATCH('/token')
|
||||
@MultiPart()
|
||||
Future<ApiResult<Token>> updateToken(
|
||||
{@Part(name: "token") String? token,
|
||||
@Part(name: "client") String? client,
|
||||
@Part(name: "device") String? device,
|
||||
@Part(name: "client_version") String? clientVersion,
|
||||
@Part(name: "client_platform") String? clientPlatform,
|
||||
@CancelRequest() CancelToken? cancel});
|
||||
@DELETE('/token')
|
||||
@MultiPart()
|
||||
@@ -210,6 +227,10 @@ class EHApi extends __EHApi {
|
||||
bool? setCookie,
|
||||
bool? httpOnly,
|
||||
bool? secure,
|
||||
String? client,
|
||||
String? device,
|
||||
String? clientVersion,
|
||||
String? clientPlatform,
|
||||
CancelToken? cancel}) async {
|
||||
int t = DateTime.now().millisecondsSinceEpoch;
|
||||
final p =
|
||||
@@ -224,6 +245,10 @@ class EHApi extends __EHApi {
|
||||
setCookie: setCookie,
|
||||
httpOnly: httpOnly,
|
||||
secure: secure,
|
||||
client: client,
|
||||
device: device,
|
||||
clientVersion: clientVersion,
|
||||
clientPlatform: clientPlatform,
|
||||
cancel: cancel);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,6 +156,10 @@ class __EHApi implements _EHApi {
|
||||
bool? setCookie,
|
||||
bool? httpOnly,
|
||||
bool? secure,
|
||||
String? client,
|
||||
String? device,
|
||||
String? clientVersion,
|
||||
String? clientPlatform,
|
||||
CancelToken? cancel,
|
||||
}) async {
|
||||
const _extra = <String, dynamic>{};
|
||||
@@ -193,6 +197,30 @@ class __EHApi implements _EHApi {
|
||||
secure.toString(),
|
||||
));
|
||||
}
|
||||
if (client != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'client',
|
||||
client,
|
||||
));
|
||||
}
|
||||
if (device != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'device',
|
||||
device,
|
||||
));
|
||||
}
|
||||
if (clientVersion != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'client_version',
|
||||
clientVersion,
|
||||
));
|
||||
}
|
||||
if (clientPlatform != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'client_platform',
|
||||
clientPlatform,
|
||||
));
|
||||
}
|
||||
final _result = await _dio
|
||||
.fetch<Map<String, dynamic>>(_setStreamType<ApiResult<Token>>(Options(
|
||||
method: 'PUT',
|
||||
@@ -219,6 +247,76 @@ class __EHApi implements _EHApi {
|
||||
return value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ApiResult<Token>> updateToken({
|
||||
String? token,
|
||||
String? client,
|
||||
String? device,
|
||||
String? clientVersion,
|
||||
String? clientPlatform,
|
||||
CancelToken? cancel,
|
||||
}) async {
|
||||
const _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
queryParameters.removeWhere((k, v) => v == null);
|
||||
final _headers = <String, dynamic>{};
|
||||
final _data = FormData();
|
||||
if (token != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'token',
|
||||
token,
|
||||
));
|
||||
}
|
||||
if (client != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'client',
|
||||
client,
|
||||
));
|
||||
}
|
||||
if (device != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'device',
|
||||
device,
|
||||
));
|
||||
}
|
||||
if (clientVersion != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'client_version',
|
||||
clientVersion,
|
||||
));
|
||||
}
|
||||
if (clientPlatform != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'client_platform',
|
||||
clientPlatform,
|
||||
));
|
||||
}
|
||||
final _result = await _dio
|
||||
.fetch<Map<String, dynamic>>(_setStreamType<ApiResult<Token>>(Options(
|
||||
method: 'PATCH',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
contentType: 'multipart/form-data',
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/token',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
cancelToken: cancel,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final value = ApiResult<Token>.fromJson(
|
||||
_result.data!,
|
||||
(json) => Token.fromJson(json as Map<String, dynamic>),
|
||||
);
|
||||
return value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ApiResult<bool>> deleteToken({
|
||||
String? token,
|
||||
|
||||
@@ -12,6 +12,11 @@ class Token {
|
||||
required this.expired,
|
||||
required this.httpOnly,
|
||||
required this.secure,
|
||||
required this.lastUsed,
|
||||
this.client,
|
||||
this.device,
|
||||
this.clientVersion,
|
||||
this.clientPlatform,
|
||||
});
|
||||
final int id;
|
||||
final int uid;
|
||||
@@ -21,6 +26,14 @@ class Token {
|
||||
@JsonKey(name: 'http_only')
|
||||
final bool httpOnly;
|
||||
final bool secure;
|
||||
@JsonKey(fromJson: _fromJson, toJson: _toJson, name: 'last_used')
|
||||
final DateTime lastUsed;
|
||||
final String? client;
|
||||
final String? device;
|
||||
@JsonKey(name: 'client_version')
|
||||
final String? clientVersion;
|
||||
@JsonKey(name: 'client_platform')
|
||||
final String? clientPlatform;
|
||||
static DateTime _fromJson(String d) => DateTime.parse(d);
|
||||
static String _toJson(DateTime d) => d.toIso8601String();
|
||||
factory Token.fromJson(Map<String, dynamic> json) => _$TokenFromJson(json);
|
||||
|
||||
@@ -13,6 +13,11 @@ Token _$TokenFromJson(Map<String, dynamic> json) => Token(
|
||||
expired: Token._fromJson(json['expired'] as String),
|
||||
httpOnly: json['http_only'] as bool,
|
||||
secure: json['secure'] as bool,
|
||||
lastUsed: Token._fromJson(json['last_used'] as String),
|
||||
client: json['client'] as String?,
|
||||
device: json['device'] as String?,
|
||||
clientVersion: json['client_version'] as String?,
|
||||
clientPlatform: json['client_platform'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TokenToJson(Token instance) => <String, dynamic>{
|
||||
@@ -22,6 +27,11 @@ Map<String, dynamic> _$TokenToJson(Token instance) => <String, dynamic>{
|
||||
'expired': Token._toJson(instance.expired),
|
||||
'http_only': instance.httpOnly,
|
||||
'secure': instance.secure,
|
||||
'last_used': Token._toJson(instance.lastUsed),
|
||||
'client': instance.client,
|
||||
'device': instance.device,
|
||||
'client_version': instance.clientVersion,
|
||||
'client_platform': instance.clientPlatform,
|
||||
};
|
||||
|
||||
TokenWithUserInfo _$TokenWithUserInfoFromJson(Map<String, dynamic> json) =>
|
||||
|
||||
Reference in New Issue
Block a user