mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-12 02:09:12 +08:00
ec9062f505
Signed-off-by: 21pages <pages21@163.com>
122 lines
3.0 KiB
Dart
122 lines
3.0 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter_hbb/models/peer_model.dart';
|
|
|
|
import '../../models/platform_model.dart';
|
|
|
|
class HttpType {
|
|
static const kAuthReqTypeAccount = "account";
|
|
static const kAuthReqTypeMobile = "mobile";
|
|
static const kAuthReqTypeSMSCode = "sms_code";
|
|
static const kAuthReqTypeEmailCode = "email_code";
|
|
|
|
static const kAuthResTypeToken = "access_token";
|
|
static const kAuthResTypeEmailCheck = "email_check";
|
|
}
|
|
|
|
class UserPayload {
|
|
String id = '';
|
|
String name = '';
|
|
String email = '';
|
|
String note = '';
|
|
int? status;
|
|
bool isAdmin = false;
|
|
|
|
UserPayload.fromJson(Map<String, dynamic> json)
|
|
: id = json['id'] ?? '',
|
|
name = json['name'] ?? '',
|
|
email = json['email'] ?? '',
|
|
note = json['note'] ?? '',
|
|
status = json['status'],
|
|
isAdmin = json['is_admin'] == true;
|
|
}
|
|
|
|
class PeerPayload {
|
|
String id = '';
|
|
String info = '';
|
|
int? status;
|
|
String user = '';
|
|
String user_name = '';
|
|
String note = '';
|
|
|
|
PeerPayload.fromJson(Map<String, dynamic> json)
|
|
: id = json['id'] ?? '',
|
|
info = json['info'] ?? '',
|
|
status = json['status'],
|
|
user = json['user'] ?? '',
|
|
user_name = json['user_name'] ?? '',
|
|
note = json['note'] ?? '';
|
|
|
|
static Peer toPeer(PeerPayload p) {
|
|
return Peer.fromJson({"id": p.id, "username": p.user_name});
|
|
}
|
|
}
|
|
|
|
class DeviceInfo {
|
|
static Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['os'] = Platform.operatingSystem;
|
|
data['type'] = "client";
|
|
data['name'] = bind.mainGetHostname();
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class LoginRequest {
|
|
String? username;
|
|
String? password;
|
|
String? id;
|
|
String? uuid;
|
|
bool? trustThisDevice;
|
|
String? type;
|
|
String? verificationCode;
|
|
Map<String, dynamic> deviceInfo = DeviceInfo.toJson();
|
|
|
|
LoginRequest(
|
|
{this.username,
|
|
this.password,
|
|
this.id,
|
|
this.uuid,
|
|
this.trustThisDevice,
|
|
this.type,
|
|
this.verificationCode});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['username'] = username ?? '';
|
|
data['password'] = password ?? '';
|
|
data['id'] = id ?? '';
|
|
data['uuid'] = uuid ?? '';
|
|
data['trustThisDevice'] = trustThisDevice ?? '';
|
|
data['type'] = type ?? '';
|
|
data['verificationCode'] = verificationCode ?? '';
|
|
data['deviceInfo'] = deviceInfo;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class LoginResponse {
|
|
String? access_token;
|
|
String? type;
|
|
UserPayload? user;
|
|
|
|
LoginResponse({this.access_token, this.type, this.user});
|
|
|
|
LoginResponse.fromJson(Map<String, dynamic> json) {
|
|
access_token = json['access_token'];
|
|
type = json['type'];
|
|
user = json['user'] != null ? UserPayload.fromJson(json['user']) : null;
|
|
}
|
|
}
|
|
|
|
class RequestException implements Exception {
|
|
int statusCode;
|
|
String cause;
|
|
RequestException(this.statusCode, this.cause);
|
|
|
|
@override
|
|
String toString() {
|
|
return "RequestException, statusCode: $statusCode, error: $cause";
|
|
}
|
|
}
|