login.m.dart 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. import 'authentication.m.dart';
  2. enum LoginStateEnum {
  3. Succeed,
  4. PasswordIncorrect,
  5. }
  6. class LoginResult {
  7. LoginStateEnum loginState;
  8. String? token;
  9. int? lockRemainingTimes;
  10. bool passwordExpired;
  11. LoginResult({
  12. this.loginState = LoginStateEnum.Succeed,
  13. this.token,
  14. this.lockRemainingTimes,
  15. this.passwordExpired = false,
  16. });
  17. factory LoginResult.fromJson(Map<String, dynamic> map) {
  18. return LoginResult(
  19. loginState: LoginStateEnum.values.firstWhere((e) => e.index == map['LoginState']),
  20. token: map['Token'],
  21. lockRemainingTimes: map['LockRemainingTimes'],
  22. passwordExpired: map['PasswordExpired'],
  23. );
  24. }
  25. Map<String, dynamic> toJson() {
  26. final map = Map<String, dynamic>();
  27. map['LoginState'] = loginState.index;
  28. if(token != null)
  29. map['Token'] = token;
  30. if(lockRemainingTimes != null)
  31. map['LockRemainingTimes'] = lockRemainingTimes;
  32. map['PasswordExpired'] = passwordExpired;
  33. return map;
  34. }
  35. }
  36. class CommonLoginRequest {
  37. String? anyAccount;
  38. String? anyCode;
  39. String? password;
  40. Map<String,String>? headerMap;
  41. Platform platform;
  42. LoginSource loginSource;
  43. CommonLoginRequest({
  44. this.anyAccount,
  45. this.anyCode,
  46. this.password,
  47. this.headerMap,
  48. this.platform = Platform.Windows,
  49. this.loginSource = LoginSource.PC,
  50. });
  51. factory CommonLoginRequest.fromJson(Map<String, dynamic> map) {
  52. return CommonLoginRequest(
  53. anyAccount: map['AnyAccount'],
  54. anyCode: map['AnyCode'],
  55. password: map['Password'],
  56. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  57. platform: Platform.values.firstWhere((e) => e.index == map['Platform']),
  58. loginSource: LoginSource.values.firstWhere((e) => e.index == map['LoginSource']),
  59. );
  60. }
  61. Map<String, dynamic> toJson() {
  62. final map = Map<String, dynamic>();
  63. if(anyAccount != null)
  64. map['AnyAccount'] = anyAccount;
  65. if(anyCode != null)
  66. map['AnyCode'] = anyCode;
  67. if(password != null)
  68. map['Password'] = password;
  69. if(headerMap != null)
  70. map['HeaderMap'] = headerMap;
  71. map['Platform'] = platform.index;
  72. map['LoginSource'] = loginSource.index;
  73. return map;
  74. }
  75. }
  76. class CheckLoginTypeRequest {
  77. String? anyAccount;
  78. CheckLoginTypeRequest({
  79. this.anyAccount,
  80. });
  81. factory CheckLoginTypeRequest.fromJson(Map<String, dynamic> map) {
  82. return CheckLoginTypeRequest(
  83. anyAccount: map['AnyAccount'],
  84. );
  85. }
  86. Map<String, dynamic> toJson() {
  87. final map = Map<String, dynamic>();
  88. if(anyAccount != null)
  89. map['AnyAccount'] = anyAccount;
  90. return map;
  91. }
  92. }
  93. class CommonSignUpRequest {
  94. String? anyAccount;
  95. String? anyCode;
  96. String? password;
  97. Map<String,String>? headerMap;
  98. CommonSignUpRequest({
  99. this.anyAccount,
  100. this.anyCode,
  101. this.password,
  102. this.headerMap,
  103. });
  104. factory CommonSignUpRequest.fromJson(Map<String, dynamic> map) {
  105. return CommonSignUpRequest(
  106. anyAccount: map['AnyAccount'],
  107. anyCode: map['AnyCode'],
  108. password: map['Password'],
  109. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  110. );
  111. }
  112. Map<String, dynamic> toJson() {
  113. final map = Map<String, dynamic>();
  114. if(anyAccount != null)
  115. map['AnyAccount'] = anyAccount;
  116. if(anyCode != null)
  117. map['AnyCode'] = anyCode;
  118. if(password != null)
  119. map['Password'] = password;
  120. if(headerMap != null)
  121. map['HeaderMap'] = headerMap;
  122. return map;
  123. }
  124. }
  125. class CheckSMSVerificationCodeRequest {
  126. String? userPhone;
  127. String? verifyCode;
  128. CheckSMSVerificationCodeRequest({
  129. this.userPhone,
  130. this.verifyCode,
  131. });
  132. factory CheckSMSVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  133. return CheckSMSVerificationCodeRequest(
  134. userPhone: map['UserPhone'],
  135. verifyCode: map['VerifyCode'],
  136. );
  137. }
  138. Map<String, dynamic> toJson() {
  139. final map = Map<String, dynamic>();
  140. if(userPhone != null)
  141. map['UserPhone'] = userPhone;
  142. if(verifyCode != null)
  143. map['VerifyCode'] = verifyCode;
  144. return map;
  145. }
  146. }
  147. class SendSMSVerificationCodeRequest {
  148. String? userPhone;
  149. SendSMSVerificationCodeRequest({
  150. this.userPhone,
  151. });
  152. factory SendSMSVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  153. return SendSMSVerificationCodeRequest(
  154. userPhone: map['UserPhone'],
  155. );
  156. }
  157. Map<String, dynamic> toJson() {
  158. final map = Map<String, dynamic>();
  159. if(userPhone != null)
  160. map['UserPhone'] = userPhone;
  161. return map;
  162. }
  163. }
  164. class SendEmailVerificationCodeRequest {
  165. String? emailAddress;
  166. String? languageCode;
  167. SendEmailVerificationCodeRequest({
  168. this.emailAddress,
  169. this.languageCode,
  170. });
  171. factory SendEmailVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  172. return SendEmailVerificationCodeRequest(
  173. emailAddress: map['EmailAddress'],
  174. languageCode: map['LanguageCode'],
  175. );
  176. }
  177. Map<String, dynamic> toJson() {
  178. final map = Map<String, dynamic>();
  179. if(emailAddress != null)
  180. map['EmailAddress'] = emailAddress;
  181. if(languageCode != null)
  182. map['LanguageCode'] = languageCode;
  183. return map;
  184. }
  185. }
  186. class CheckEmailVerificationCodeRequest {
  187. String? emailAddress;
  188. String? verifyCode;
  189. CheckEmailVerificationCodeRequest({
  190. this.emailAddress,
  191. this.verifyCode,
  192. });
  193. factory CheckEmailVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  194. return CheckEmailVerificationCodeRequest(
  195. emailAddress: map['EmailAddress'],
  196. verifyCode: map['VerifyCode'],
  197. );
  198. }
  199. Map<String, dynamic> toJson() {
  200. final map = Map<String, dynamic>();
  201. if(emailAddress != null)
  202. map['EmailAddress'] = emailAddress;
  203. if(verifyCode != null)
  204. map['VerifyCode'] = verifyCode;
  205. return map;
  206. }
  207. }
  208. class RetrievePasswordByPhoneRequest {
  209. String? phone;
  210. String? verifyCode;
  211. String? newPassword;
  212. RetrievePasswordByPhoneRequest({
  213. this.phone,
  214. this.verifyCode,
  215. this.newPassword,
  216. });
  217. factory RetrievePasswordByPhoneRequest.fromJson(Map<String, dynamic> map) {
  218. return RetrievePasswordByPhoneRequest(
  219. phone: map['Phone'],
  220. verifyCode: map['VerifyCode'],
  221. newPassword: map['NewPassword'],
  222. );
  223. }
  224. Map<String, dynamic> toJson() {
  225. final map = Map<String, dynamic>();
  226. if(phone != null)
  227. map['Phone'] = phone;
  228. if(verifyCode != null)
  229. map['VerifyCode'] = verifyCode;
  230. if(newPassword != null)
  231. map['NewPassword'] = newPassword;
  232. return map;
  233. }
  234. }
  235. class RetrievePasswordByEmailRequest {
  236. String? mail;
  237. String? verifyCode;
  238. String? newPassword;
  239. RetrievePasswordByEmailRequest({
  240. this.mail,
  241. this.verifyCode,
  242. this.newPassword,
  243. });
  244. factory RetrievePasswordByEmailRequest.fromJson(Map<String, dynamic> map) {
  245. return RetrievePasswordByEmailRequest(
  246. mail: map['Mail'],
  247. verifyCode: map['VerifyCode'],
  248. newPassword: map['NewPassword'],
  249. );
  250. }
  251. Map<String, dynamic> toJson() {
  252. final map = Map<String, dynamic>();
  253. if(mail != null)
  254. map['Mail'] = mail;
  255. if(verifyCode != null)
  256. map['VerifyCode'] = verifyCode;
  257. if(newPassword != null)
  258. map['NewPassword'] = newPassword;
  259. return map;
  260. }
  261. }
  262. class VerifyAccountRequest {
  263. String? userName;
  264. VerifyAccountRequest({
  265. this.userName,
  266. });
  267. factory VerifyAccountRequest.fromJson(Map<String, dynamic> map) {
  268. return VerifyAccountRequest(
  269. userName: map['UserName'],
  270. );
  271. }
  272. Map<String, dynamic> toJson() {
  273. final map = Map<String, dynamic>();
  274. if(userName != null)
  275. map['UserName'] = userName;
  276. return map;
  277. }
  278. }
  279. class ModifyPasswordRequest extends CommonSignUpRequest{
  280. String? token;
  281. String? newPassword;
  282. ModifyPasswordRequest({
  283. this.token,
  284. this.newPassword,
  285. String? anyAccount,
  286. String? anyCode,
  287. String? password,
  288. Map<String,String>? headerMap,
  289. }) : super(
  290. anyAccount: anyAccount,
  291. anyCode: anyCode,
  292. password: password,
  293. headerMap: headerMap,
  294. );
  295. factory ModifyPasswordRequest.fromJson(Map<String, dynamic> map) {
  296. return ModifyPasswordRequest(
  297. token: map['Token'],
  298. newPassword: map['NewPassword'],
  299. anyAccount: map['AnyAccount'],
  300. anyCode: map['AnyCode'],
  301. password: map['Password'],
  302. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  303. );
  304. }
  305. Map<String, dynamic> toJson() {
  306. final map = super.toJson();
  307. if(token != null)
  308. map['Token'] = token;
  309. if(newPassword != null)
  310. map['NewPassword'] = newPassword;
  311. return map;
  312. }
  313. }