mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
add login client type
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user