UNPKG

textiot

Version:

A framework for building web and native (IoT) Dapps on the IPFS network

75 lines (74 loc) 2.65 kB
"use strict"; 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"); /** * Comments is an API module for managing thread/block comments * * Comments are added as blocks in a thread, which target another block, usually a file(s). * * @extends API */ class Comments extends api_1.API { /** * Adds a comment to a block * * @param block Target block ID. Usually a file(s) block. * @param body Comment body * @returns The generated comment block */ add(block, body) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendPost(`blocks/${block}/comments`, [body]); return response.json(); }); } /** * Retrieves a comment by ID * * @param id ID of the target comment * @returns The target comment block */ get(id) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendGet(`blocks/${id}/comment`); return response.json(); }); } /** * Retrieves a list of comments on a target block * * @param block ID of the target block * @returns An array of comment blocks */ list(block) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendGet(`blocks/${block}/comments`); return response.json(); }); } /** * Ignores a block comment by its ID * * This adds an 'ignore' thread block targeted at the comment. * Ignored blocks are by default not returned when listing. * * @param id ID of the comment * @returns The ignored block */ ignore(id) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendDelete(`blocks/${id}`); return response.json(); }); } } exports.default = Comments;