tvpl.api

<back to all web services

GetNotificationFilter

Lấy danh sách các Notification mới nhất của người dùng hiện tại

Requires Authentication
The following routes are available for this service:
GET/notificationsLấ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 .csv suffix or ?format=csv

HTTP + CSV

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: text/csv
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"code":0,"message":"String","notifications":[{"id":"String","accountId":0,"title":"String","message":"String","payload":"String","createdOn":"0001-01-01T00:00:00.0000000+07:06","readOn":"0001-01-01T00:00:00.0000000+07:06","pushOn":"0001-01-01T00:00:00.0000000+07:06","deletedOn":"0001-01-01T00:00:00.0000000+07:06"}],"unreadCount":0,"totalCount":0}