notification.m.dart 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. enum MessageTypeEnum {
  2. placeHolder_0,
  3. Connection,
  4. Disconnect,
  5. Notify,
  6. KeepNotify,
  7. Ask,
  8. Ack,
  9. }
  10. enum NotificationTypeEnum {
  11. placeHolder_0,
  12. Message,
  13. Action,
  14. Update,
  15. NotifyRecordCodesMessage,
  16. FinishNotifyRecordsMessage,
  17. }
  18. class NotifyMessage {
  19. int length;
  20. MessageTypeEnum messageType;
  21. NotificationTypeEnum notificationType;
  22. String? message;
  23. NotifyMessage({
  24. this.length = 0,
  25. this.messageType = MessageTypeEnum.Connection,
  26. this.notificationType = NotificationTypeEnum.Message,
  27. this.message,
  28. });
  29. factory NotifyMessage.fromJson(Map<String, dynamic> map) {
  30. return NotifyMessage(
  31. length: map['Length'],
  32. messageType: MessageTypeEnum.values.firstWhere((e) => e.index == map['MessageType']),
  33. notificationType: NotificationTypeEnum.values.firstWhere((e) => e.index == map['NotificationType']),
  34. message: map['Message'],
  35. );
  36. }
  37. Map<String, dynamic> toJson() {
  38. final map = Map<String, dynamic>();
  39. map['Length'] = length;
  40. map['MessageType'] = messageType.index;
  41. map['NotificationType'] = notificationType.index;
  42. if(message != null)
  43. map['Message'] = message;
  44. return map;
  45. }
  46. }
  47. class SendNotificationRequest {
  48. String? clientId;
  49. NotifyMessage? message;
  50. SendNotificationRequest({
  51. this.clientId,
  52. this.message,
  53. });
  54. factory SendNotificationRequest.fromJson(Map<String, dynamic> map) {
  55. return SendNotificationRequest(
  56. clientId: map['ClientId'],
  57. message: map['Message'] != null ? NotifyMessage.fromJson(map['Message']) : null,
  58. );
  59. }
  60. Map<String, dynamic> toJson() {
  61. final map = Map<String, dynamic>();
  62. if(clientId != null)
  63. map['ClientId'] = clientId;
  64. if(message != null)
  65. map['Message'] = message;
  66. return map;
  67. }
  68. }
  69. class BroadcastNotificationRequest {
  70. List<String >? clientIds;
  71. NotifyMessage? message;
  72. String? msgQueueId;
  73. BroadcastNotificationRequest({
  74. this.clientIds,
  75. this.message,
  76. this.msgQueueId,
  77. });
  78. factory BroadcastNotificationRequest.fromJson(Map<String, dynamic> map) {
  79. return BroadcastNotificationRequest(
  80. clientIds: map['ClientIds'] != null ? map['ClientIds'].cast<String>().toList() : null,
  81. message: map['Message'] != null ? NotifyMessage.fromJson(map['Message']) : null,
  82. msgQueueId: map['MsgQueueId'],
  83. );
  84. }
  85. Map<String, dynamic> toJson() {
  86. final map = Map<String, dynamic>();
  87. if(clientIds != null)
  88. map['ClientIds'] = clientIds;
  89. if(message != null)
  90. map['Message'] = message;
  91. if(msgQueueId != null)
  92. map['MsgQueueId'] = msgQueueId;
  93. return map;
  94. }
  95. }
  96. class OpenNotifyQueueRequest {
  97. String? module;
  98. OpenNotifyQueueRequest({
  99. this.module,
  100. });
  101. factory OpenNotifyQueueRequest.fromJson(Map<String, dynamic> map) {
  102. return OpenNotifyQueueRequest(
  103. module: map['Module'],
  104. );
  105. }
  106. Map<String, dynamic> toJson() {
  107. final map = Map<String, dynamic>();
  108. if(module != null)
  109. map['Module'] = module;
  110. return map;
  111. }
  112. }
  113. class CloseNotifyQueueRequest {
  114. String? msgQueueId;
  115. CloseNotifyQueueRequest({
  116. this.msgQueueId,
  117. });
  118. factory CloseNotifyQueueRequest.fromJson(Map<String, dynamic> map) {
  119. return CloseNotifyQueueRequest(
  120. msgQueueId: map['MsgQueueId'],
  121. );
  122. }
  123. Map<String, dynamic> toJson() {
  124. final map = Map<String, dynamic>();
  125. if(msgQueueId != null)
  126. map['MsgQueueId'] = msgQueueId;
  127. return map;
  128. }
  129. }