| GET | /notifications | Lấy danh sách các Notification mới nhất |
|---|
import 'package:servicestack/servicestack.dart';
class PagingRequest implements IConvertible
{
int? page;
int? limit;
PagingRequest({this.page,this.limit});
PagingRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
page = json['page'];
limit = json['limit'];
return this;
}
Map<String, dynamic> toJson() => {
'page': page,
'limit': limit
};
getTypeName() => "PagingRequest";
TypeContext? context = _ctx;
}
class Notification implements IMongoModel, IConvertible
{
String? id;
int? accountId;
// @required()
// @StringLength(200)
String? title;
String? message;
String? payload;
DateTime? createdOn;
DateTime? readOn;
DateTime? pushOn;
DateTime? deletedOn;
Notification({this.id,this.accountId,this.title,this.message,this.payload,this.createdOn,this.readOn,this.pushOn,this.deletedOn});
Notification.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
accountId = json['accountId'];
title = json['title'];
message = json['message'];
payload = json['payload'];
createdOn = JsonConverters.fromJson(json['createdOn'],'DateTime',context!);
readOn = JsonConverters.fromJson(json['readOn'],'DateTime',context!);
pushOn = JsonConverters.fromJson(json['pushOn'],'DateTime',context!);
deletedOn = JsonConverters.fromJson(json['deletedOn'],'DateTime',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'accountId': accountId,
'title': title,
'message': message,
'payload': payload,
'createdOn': JsonConverters.toJson(createdOn,'DateTime',context!),
'readOn': JsonConverters.toJson(readOn,'DateTime',context!),
'pushOn': JsonConverters.toJson(pushOn,'DateTime',context!),
'deletedOn': JsonConverters.toJson(deletedOn,'DateTime',context!)
};
getTypeName() => "Notification";
TypeContext? context = _ctx;
}
class NotificationResponse implements IResponseRequest, IConvertible
{
int? code;
String? message;
List<Notification>? notifications;
int? unreadCount;
int? totalCount;
NotificationResponse({this.code,this.message,this.notifications,this.unreadCount,this.totalCount});
NotificationResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
code = json['code'];
message = json['message'];
notifications = JsonConverters.fromJson(json['notifications'],'List<Notification>',context!);
unreadCount = json['unreadCount'];
totalCount = json['totalCount'];
return this;
}
Map<String, dynamic> toJson() => {
'code': code,
'message': message,
'notifications': JsonConverters.toJson(notifications,'List<Notification>',context!),
'unreadCount': unreadCount,
'totalCount': totalCount
};
getTypeName() => "NotificationResponse";
TypeContext? context = _ctx;
}
enum NotificationFilter
{
Unread,
All,
}
/**
* Lấy danh sách các Notification mới nhất của người dùng hiện tại
*/
class GetNotificationFilter extends PagingRequest implements IGet, IConvertible
{
NotificationFilter? filter;
GetNotificationFilter({this.filter});
GetNotificationFilter.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
filter = JsonConverters.fromJson(json['filter'],'NotificationFilter',context!);
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'filter': JsonConverters.toJson(filter,'NotificationFilter',context!)
});
getTypeName() => "GetNotificationFilter";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'etc_api.vsmlab.vn', types: <String, TypeInfo> {
'PagingRequest': TypeInfo(TypeOf.Class, create:() => PagingRequest()),
'Notification': TypeInfo(TypeOf.Class, create:() => Notification()),
'NotificationResponse': TypeInfo(TypeOf.Class, create:() => NotificationResponse()),
'List<Notification>': TypeInfo(TypeOf.Class, create:() => <Notification>[]),
'NotificationFilter': TypeInfo(TypeOf.Enum, enumValues:NotificationFilter.values),
'GetNotificationFilter': TypeInfo(TypeOf.Class, create:() => GetNotificationFilter()),
});
Dart GetNotificationFilter DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /notifications HTTP/1.1 Host: etc-api.vsmlab.vn Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<NotificationResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/tvpl.api.ServiceModel">
<Code>0</Code>
<Message>String</Message>
<Notifications xmlns:d2p1="http://schemas.datacontract.org/2004/07/tvpl.data.Models">
<d2p1:Notification>
<d2p1:AccountId>0</d2p1:AccountId>
<d2p1:CreatedOn>0001-01-01T00:00:00</d2p1:CreatedOn>
<d2p1:DeletedOn>0001-01-01T00:00:00</d2p1:DeletedOn>
<d2p1:Id>String</d2p1:Id>
<d2p1:Message>String</d2p1:Message>
<d2p1:Payload>String</d2p1:Payload>
<d2p1:PushOn>0001-01-01T00:00:00</d2p1:PushOn>
<d2p1:ReadOn>0001-01-01T00:00:00</d2p1:ReadOn>
<d2p1:Title>String</d2p1:Title>
</d2p1:Notification>
</Notifications>
<TotalCount>0</TotalCount>
<UnreadCount>0</UnreadCount>
</NotificationResponse>