login.m.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. import 'authentication.m.dart';
  2. import 'notification.m.dart';
  3. import 'liveConsultation.m.dart';
  4. enum LoginStateEnum {
  5. Succeed,
  6. PasswordIncorrect,
  7. }
  8. class LoginResult {
  9. LoginStateEnum loginState;
  10. String? token;
  11. int? lockRemainingTimes;
  12. bool passwordExpired;
  13. String? accountName;
  14. LoginResult({
  15. this.loginState = LoginStateEnum.Succeed,
  16. this.token,
  17. this.lockRemainingTimes,
  18. this.passwordExpired = false,
  19. this.accountName,
  20. });
  21. factory LoginResult.fromJson(Map<String, dynamic> map) {
  22. return LoginResult(
  23. loginState: LoginStateEnum.values.firstWhere((e) => e.index == map['LoginState']),
  24. token: map['Token'],
  25. lockRemainingTimes: map['LockRemainingTimes'],
  26. passwordExpired: map['PasswordExpired'],
  27. accountName: map['AccountName'],
  28. );
  29. }
  30. Map<String, dynamic> toJson() {
  31. final map = Map<String, dynamic>();
  32. map['LoginState'] = loginState.index;
  33. if(token != null)
  34. map['Token'] = token;
  35. if(lockRemainingTimes != null)
  36. map['LockRemainingTimes'] = lockRemainingTimes;
  37. map['PasswordExpired'] = passwordExpired;
  38. if(accountName != null)
  39. map['AccountName'] = accountName;
  40. return map;
  41. }
  42. }
  43. class CommonLoginRequest {
  44. String? anyAccount;
  45. String? anyCode;
  46. String? password;
  47. Map<String,String>? headerMap;
  48. Platform platform;
  49. LoginSource loginSource;
  50. String? installVersion;
  51. CommonLoginRequest({
  52. this.anyAccount,
  53. this.anyCode,
  54. this.password,
  55. this.headerMap,
  56. this.platform = Platform.Windows,
  57. this.loginSource = LoginSource.PC,
  58. this.installVersion,
  59. });
  60. factory CommonLoginRequest.fromJson(Map<String, dynamic> map) {
  61. return CommonLoginRequest(
  62. anyAccount: map['AnyAccount'],
  63. anyCode: map['AnyCode'],
  64. password: map['Password'],
  65. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  66. platform: Platform.values.firstWhere((e) => e.index == map['Platform']),
  67. loginSource: LoginSource.values.firstWhere((e) => e.index == map['LoginSource']),
  68. installVersion: map['InstallVersion'],
  69. );
  70. }
  71. Map<String, dynamic> toJson() {
  72. final map = Map<String, dynamic>();
  73. if(anyAccount != null)
  74. map['AnyAccount'] = anyAccount;
  75. if(anyCode != null)
  76. map['AnyCode'] = anyCode;
  77. if(password != null)
  78. map['Password'] = password;
  79. if(headerMap != null)
  80. map['HeaderMap'] = headerMap;
  81. map['Platform'] = platform.index;
  82. map['LoginSource'] = loginSource.index;
  83. if(installVersion != null)
  84. map['InstallVersion'] = installVersion;
  85. return map;
  86. }
  87. }
  88. class CheckLoginTypeRequest {
  89. String? anyAccount;
  90. CheckLoginTypeRequest({
  91. this.anyAccount,
  92. });
  93. factory CheckLoginTypeRequest.fromJson(Map<String, dynamic> map) {
  94. return CheckLoginTypeRequest(
  95. anyAccount: map['AnyAccount'],
  96. );
  97. }
  98. Map<String, dynamic> toJson() {
  99. final map = Map<String, dynamic>();
  100. if(anyAccount != null)
  101. map['AnyAccount'] = anyAccount;
  102. return map;
  103. }
  104. }
  105. class CommonSignUpRequest {
  106. String? anyAccount;
  107. String? anyCode;
  108. String? password;
  109. Map<String,String>? headerMap;
  110. CommonSignUpRequest({
  111. this.anyAccount,
  112. this.anyCode,
  113. this.password,
  114. this.headerMap,
  115. });
  116. factory CommonSignUpRequest.fromJson(Map<String, dynamic> map) {
  117. return CommonSignUpRequest(
  118. anyAccount: map['AnyAccount'],
  119. anyCode: map['AnyCode'],
  120. password: map['Password'],
  121. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  122. );
  123. }
  124. Map<String, dynamic> toJson() {
  125. final map = Map<String, dynamic>();
  126. if(anyAccount != null)
  127. map['AnyAccount'] = anyAccount;
  128. if(anyCode != null)
  129. map['AnyCode'] = anyCode;
  130. if(password != null)
  131. map['Password'] = password;
  132. if(headerMap != null)
  133. map['HeaderMap'] = headerMap;
  134. return map;
  135. }
  136. }
  137. class CheckSMSVerificationCodeRequest {
  138. String? userPhone;
  139. String? verifyCode;
  140. CheckSMSVerificationCodeRequest({
  141. this.userPhone,
  142. this.verifyCode,
  143. });
  144. factory CheckSMSVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  145. return CheckSMSVerificationCodeRequest(
  146. userPhone: map['UserPhone'],
  147. verifyCode: map['VerifyCode'],
  148. );
  149. }
  150. Map<String, dynamic> toJson() {
  151. final map = Map<String, dynamic>();
  152. if(userPhone != null)
  153. map['UserPhone'] = userPhone;
  154. if(verifyCode != null)
  155. map['VerifyCode'] = verifyCode;
  156. return map;
  157. }
  158. }
  159. class SendSMSVerificationCodeRequest {
  160. String? userPhone;
  161. SendSMSVerificationCodeRequest({
  162. this.userPhone,
  163. });
  164. factory SendSMSVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  165. return SendSMSVerificationCodeRequest(
  166. userPhone: map['UserPhone'],
  167. );
  168. }
  169. Map<String, dynamic> toJson() {
  170. final map = Map<String, dynamic>();
  171. if(userPhone != null)
  172. map['UserPhone'] = userPhone;
  173. return map;
  174. }
  175. }
  176. class SendEmailVerificationCodeRequest {
  177. String? emailAddress;
  178. String? languageCode;
  179. SendEmailVerificationCodeRequest({
  180. this.emailAddress,
  181. this.languageCode,
  182. });
  183. factory SendEmailVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  184. return SendEmailVerificationCodeRequest(
  185. emailAddress: map['EmailAddress'],
  186. languageCode: map['LanguageCode'],
  187. );
  188. }
  189. Map<String, dynamic> toJson() {
  190. final map = Map<String, dynamic>();
  191. if(emailAddress != null)
  192. map['EmailAddress'] = emailAddress;
  193. if(languageCode != null)
  194. map['LanguageCode'] = languageCode;
  195. return map;
  196. }
  197. }
  198. class CheckEmailVerificationCodeRequest {
  199. String? emailAddress;
  200. String? verifyCode;
  201. CheckEmailVerificationCodeRequest({
  202. this.emailAddress,
  203. this.verifyCode,
  204. });
  205. factory CheckEmailVerificationCodeRequest.fromJson(Map<String, dynamic> map) {
  206. return CheckEmailVerificationCodeRequest(
  207. emailAddress: map['EmailAddress'],
  208. verifyCode: map['VerifyCode'],
  209. );
  210. }
  211. Map<String, dynamic> toJson() {
  212. final map = Map<String, dynamic>();
  213. if(emailAddress != null)
  214. map['EmailAddress'] = emailAddress;
  215. if(verifyCode != null)
  216. map['VerifyCode'] = verifyCode;
  217. return map;
  218. }
  219. }
  220. class RetrievePasswordByPhoneRequest {
  221. String? phone;
  222. String? verifyCode;
  223. String? newPassword;
  224. RetrievePasswordByPhoneRequest({
  225. this.phone,
  226. this.verifyCode,
  227. this.newPassword,
  228. });
  229. factory RetrievePasswordByPhoneRequest.fromJson(Map<String, dynamic> map) {
  230. return RetrievePasswordByPhoneRequest(
  231. phone: map['Phone'],
  232. verifyCode: map['VerifyCode'],
  233. newPassword: map['NewPassword'],
  234. );
  235. }
  236. Map<String, dynamic> toJson() {
  237. final map = Map<String, dynamic>();
  238. if(phone != null)
  239. map['Phone'] = phone;
  240. if(verifyCode != null)
  241. map['VerifyCode'] = verifyCode;
  242. if(newPassword != null)
  243. map['NewPassword'] = newPassword;
  244. return map;
  245. }
  246. }
  247. class RetrievePasswordByEmailRequest {
  248. String? mail;
  249. String? verifyCode;
  250. String? newPassword;
  251. RetrievePasswordByEmailRequest({
  252. this.mail,
  253. this.verifyCode,
  254. this.newPassword,
  255. });
  256. factory RetrievePasswordByEmailRequest.fromJson(Map<String, dynamic> map) {
  257. return RetrievePasswordByEmailRequest(
  258. mail: map['Mail'],
  259. verifyCode: map['VerifyCode'],
  260. newPassword: map['NewPassword'],
  261. );
  262. }
  263. Map<String, dynamic> toJson() {
  264. final map = Map<String, dynamic>();
  265. if(mail != null)
  266. map['Mail'] = mail;
  267. if(verifyCode != null)
  268. map['VerifyCode'] = verifyCode;
  269. if(newPassword != null)
  270. map['NewPassword'] = newPassword;
  271. return map;
  272. }
  273. }
  274. class VerifyAccountRequest {
  275. String? userName;
  276. VerifyAccountRequest({
  277. this.userName,
  278. });
  279. factory VerifyAccountRequest.fromJson(Map<String, dynamic> map) {
  280. return VerifyAccountRequest(
  281. userName: map['UserName'],
  282. );
  283. }
  284. Map<String, dynamic> toJson() {
  285. final map = Map<String, dynamic>();
  286. if(userName != null)
  287. map['UserName'] = userName;
  288. return map;
  289. }
  290. }
  291. class ModifyPasswordRequest extends CommonSignUpRequest{
  292. String? token;
  293. String? newPassword;
  294. ModifyPasswordRequest({
  295. this.token,
  296. this.newPassword,
  297. String? anyAccount,
  298. String? anyCode,
  299. String? password,
  300. Map<String,String>? headerMap,
  301. }) : super(
  302. anyAccount: anyAccount,
  303. anyCode: anyCode,
  304. password: password,
  305. headerMap: headerMap,
  306. );
  307. factory ModifyPasswordRequest.fromJson(Map<String, dynamic> map) {
  308. return ModifyPasswordRequest(
  309. token: map['Token'],
  310. newPassword: map['NewPassword'],
  311. anyAccount: map['AnyAccount'],
  312. anyCode: map['AnyCode'],
  313. password: map['Password'],
  314. headerMap: map['HeaderMap'] != null ? map['HeaderMap'].cast<String,String>() : null,
  315. );
  316. }
  317. Map<String, dynamic> toJson() {
  318. final map = super.toJson();
  319. if(token != null)
  320. map['Token'] = token;
  321. if(newPassword != null)
  322. map['NewPassword'] = newPassword;
  323. return map;
  324. }
  325. }
  326. class GenerateNewPasswordRequest extends TokenRequest{
  327. GenerateNewPasswordRequest({
  328. String? token,
  329. }) : super(
  330. token: token,
  331. );
  332. factory GenerateNewPasswordRequest.fromJson(Map<String, dynamic> map) {
  333. return GenerateNewPasswordRequest(
  334. token: map['Token'],
  335. );
  336. }
  337. Map<String, dynamic> toJson() {
  338. final map = super.toJson();
  339. return map;
  340. }
  341. }
  342. enum AssociatedAccountResultEnum {
  343. Success,
  344. UserNotFind,
  345. UserNameIsEmpty,
  346. Error,
  347. }
  348. class StartAssociatedWithAccountResult {
  349. bool isSuccess;
  350. AssociatedAccountResultEnum state;
  351. StartAssociatedWithAccountResult({
  352. this.isSuccess = false,
  353. this.state = AssociatedAccountResultEnum.Success,
  354. });
  355. factory StartAssociatedWithAccountResult.fromJson(Map<String, dynamic> map) {
  356. return StartAssociatedWithAccountResult(
  357. isSuccess: map['IsSuccess'],
  358. state: AssociatedAccountResultEnum.values.firstWhere((e) => e.index == map['State']),
  359. );
  360. }
  361. Map<String, dynamic> toJson() {
  362. final map = Map<String, dynamic>();
  363. map['IsSuccess'] = isSuccess;
  364. map['State'] = state.index;
  365. return map;
  366. }
  367. }
  368. class StartAssociatedWithAccountRequest extends TokenRequest{
  369. String? wingUserName;
  370. String? thirdPartyUserId;
  371. String? languageCode;
  372. StartAssociatedWithAccountRequest({
  373. this.wingUserName,
  374. this.thirdPartyUserId,
  375. this.languageCode,
  376. String? token,
  377. }) : super(
  378. token: token,
  379. );
  380. factory StartAssociatedWithAccountRequest.fromJson(Map<String, dynamic> map) {
  381. return StartAssociatedWithAccountRequest(
  382. wingUserName: map['WingUserName'],
  383. thirdPartyUserId: map['ThirdPartyUserId'],
  384. languageCode: map['LanguageCode'],
  385. token: map['Token'],
  386. );
  387. }
  388. Map<String, dynamic> toJson() {
  389. final map = super.toJson();
  390. if(wingUserName != null)
  391. map['WingUserName'] = wingUserName;
  392. if(thirdPartyUserId != null)
  393. map['ThirdPartyUserId'] = thirdPartyUserId;
  394. if(languageCode != null)
  395. map['LanguageCode'] = languageCode;
  396. return map;
  397. }
  398. }
  399. class AssociatedFeatureInfoDTO extends AssociatedInfoDTO{
  400. String? featureCode;
  401. AssociatedFeatureInfoDTO({
  402. this.featureCode,
  403. String? id,
  404. String? title,
  405. String? cTitle,
  406. String? eTitle,
  407. String? icon,
  408. String? description,
  409. String? url,
  410. int index = 0,
  411. }) : super(
  412. id: id,
  413. title: title,
  414. cTitle: cTitle,
  415. eTitle: eTitle,
  416. icon: icon,
  417. description: description,
  418. url: url,
  419. index: index,
  420. );
  421. factory AssociatedFeatureInfoDTO.fromJson(Map<String, dynamic> map) {
  422. return AssociatedFeatureInfoDTO(
  423. featureCode: map['FeatureCode'],
  424. id: map['Id'],
  425. title: map['Title'],
  426. cTitle: map['CTitle'],
  427. eTitle: map['ETitle'],
  428. icon: map['Icon'],
  429. description: map['Description'],
  430. url: map['Url'],
  431. index: map['Index'],
  432. );
  433. }
  434. Map<String, dynamic> toJson() {
  435. final map = super.toJson();
  436. if(featureCode != null)
  437. map['FeatureCode'] = featureCode;
  438. return map;
  439. }
  440. }
  441. class GetAssociatedAccountInfoResult {
  442. bool isSuccess;
  443. List<AssociatedFeatureInfoDTO >? accountInfoList;
  444. GetAssociatedAccountInfoResult({
  445. this.isSuccess = false,
  446. this.accountInfoList,
  447. });
  448. factory GetAssociatedAccountInfoResult.fromJson(Map<String, dynamic> map) {
  449. return GetAssociatedAccountInfoResult(
  450. isSuccess: map['IsSuccess'],
  451. accountInfoList: map['AccountInfoList'] != null ? (map['AccountInfoList'] as List).map((e)=>AssociatedFeatureInfoDTO.fromJson(e as Map<String,dynamic>)).toList() : null,
  452. );
  453. }
  454. Map<String, dynamic> toJson() {
  455. final map = Map<String, dynamic>();
  456. map['IsSuccess'] = isSuccess;
  457. if(accountInfoList != null)
  458. map['AccountInfoList'] = accountInfoList;
  459. return map;
  460. }
  461. }
  462. class GetAssociatedAccountInfoRequest extends TokenRequest{
  463. GetAssociatedAccountInfoRequest({
  464. String? token,
  465. }) : super(
  466. token: token,
  467. );
  468. factory GetAssociatedAccountInfoRequest.fromJson(Map<String, dynamic> map) {
  469. return GetAssociatedAccountInfoRequest(
  470. token: map['Token'],
  471. );
  472. }
  473. Map<String, dynamic> toJson() {
  474. final map = super.toJson();
  475. return map;
  476. }
  477. }
  478. class GetScanCodeResult {
  479. int validSeconds;
  480. String? scanCode;
  481. GetScanCodeResult({
  482. this.validSeconds = 0,
  483. this.scanCode,
  484. });
  485. factory GetScanCodeResult.fromJson(Map<String, dynamic> map) {
  486. return GetScanCodeResult(
  487. validSeconds: map['ValidSeconds'],
  488. scanCode: map['ScanCode'],
  489. );
  490. }
  491. Map<String, dynamic> toJson() {
  492. final map = Map<String, dynamic>();
  493. map['ValidSeconds'] = validSeconds;
  494. if(scanCode != null)
  495. map['ScanCode'] = scanCode;
  496. return map;
  497. }
  498. }
  499. enum ScanLoginSource {
  500. PC,
  501. Web,
  502. US,
  503. }
  504. class GetScanCodeRequest {
  505. ScanLoginSource scanLoginSource;
  506. Platform platform;
  507. String? installVersion;
  508. GetScanCodeRequest({
  509. this.scanLoginSource = ScanLoginSource.PC,
  510. this.platform = Platform.Windows,
  511. this.installVersion,
  512. });
  513. factory GetScanCodeRequest.fromJson(Map<String, dynamic> map) {
  514. return GetScanCodeRequest(
  515. scanLoginSource: ScanLoginSource.values.firstWhere((e) => e.index == map['ScanLoginSource']),
  516. platform: Platform.values.firstWhere((e) => e.index == map['Platform']),
  517. installVersion: map['InstallVersion'],
  518. );
  519. }
  520. Map<String, dynamic> toJson() {
  521. final map = Map<String, dynamic>();
  522. map['ScanLoginSource'] = scanLoginSource.index;
  523. map['Platform'] = platform.index;
  524. if(installVersion != null)
  525. map['InstallVersion'] = installVersion;
  526. return map;
  527. }
  528. }
  529. class ConfirmScanRequest extends TokenRequest{
  530. String? scanCode;
  531. ConfirmScanRequest({
  532. this.scanCode,
  533. String? token,
  534. }) : super(
  535. token: token,
  536. );
  537. factory ConfirmScanRequest.fromJson(Map<String, dynamic> map) {
  538. return ConfirmScanRequest(
  539. scanCode: map['ScanCode'],
  540. token: map['Token'],
  541. );
  542. }
  543. Map<String, dynamic> toJson() {
  544. final map = super.toJson();
  545. if(scanCode != null)
  546. map['ScanCode'] = scanCode;
  547. return map;
  548. }
  549. }
  550. enum CheckConfirmScanState {
  551. Wait,
  552. Success,
  553. Expire,
  554. }
  555. class CheckConfirmScanStateResult {
  556. CheckConfirmScanState checkConfirmScanState;
  557. LoginResult? loginResult;
  558. CheckConfirmScanStateResult({
  559. this.checkConfirmScanState = CheckConfirmScanState.Wait,
  560. this.loginResult,
  561. });
  562. factory CheckConfirmScanStateResult.fromJson(Map<String, dynamic> map) {
  563. return CheckConfirmScanStateResult(
  564. checkConfirmScanState: CheckConfirmScanState.values.firstWhere((e) => e.index == map['CheckConfirmScanState']),
  565. loginResult: map['LoginResult'] != null ? LoginResult.fromJson(map['LoginResult']) : null,
  566. );
  567. }
  568. Map<String, dynamic> toJson() {
  569. final map = Map<String, dynamic>();
  570. map['CheckConfirmScanState'] = checkConfirmScanState.index;
  571. if(loginResult != null)
  572. map['LoginResult'] = loginResult;
  573. return map;
  574. }
  575. }
  576. class CheckConfirmScanStateRequest {
  577. String? scanCode;
  578. CheckConfirmScanStateRequest({
  579. this.scanCode,
  580. });
  581. factory CheckConfirmScanStateRequest.fromJson(Map<String, dynamic> map) {
  582. return CheckConfirmScanStateRequest(
  583. scanCode: map['ScanCode'],
  584. );
  585. }
  586. Map<String, dynamic> toJson() {
  587. final map = Map<String, dynamic>();
  588. if(scanCode != null)
  589. map['ScanCode'] = scanCode;
  590. return map;
  591. }
  592. }