textiot
Version:
A framework for building web and native (IoT) Dapps on the IPFS network
54 lines (53 loc) • 1.98 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = require("../core/api");
/**
* Notifications is an API module for managing notifications
*
* Notifications are generated by thread and account activity.
*
* @extends API
*/
class Notifications extends api_1.API {
/**
* Retrieves all notifications generated by thread and account activity
* @returns An array of Notification objects
*/
list() {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.sendGet('notifications');
return response.json();
});
}
/**
* Marks a notifiction as read by ID
*
* @param id ID of the target notification
* @returns Whether the operation was successful
*/
read(id) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.sendPost(`notifications/${id}/read`);
return response.status === 200;
});
}
/**
* Marks all notifictions as read
* @returns Whether the operation was successful
*/
readAll() {
return __awaiter(this, void 0, void 0, function* () {
return this.read('all');
});
}
}
exports.default = Notifications;
;