UNPKG

noticebord-client

Version:

The official Typescript client library for the Noticebord API.

78 lines (77 loc) 2.62 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 }); exports.UserService = void 0; const service_1 = require("./service"); class UserService extends service_1.Service { constructor(token, baseUrl) { super(token, baseUrl); } /** * Fetch a list of all users. * * @returns An array of all users. */ fetchUsers() { return __awaiter(this, void 0, void 0, function* () { const response = yield this.api.get("/users"); return response.data; }); } /** * Fetch a single user. * * @param user The user ID * @returns The user */ fetchUser(user) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.api.get(`/users/${user}`); return response.data; }); } /** * Fetch the current user. * * @returns The user */ fetchCurrentUser() { return __awaiter(this, void 0, void 0, function* () { const response = yield this.api.get(`/user`); return response.data; }); } /** * Fetch a list of all notices belonging to a user. * * @param team The user ID * @returns A list of notices belonging to the user. */ fetchUserNotices(user) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.api.get(`/users/${user}/notices`); return response.data; }); } /** * Fetch a list of all notes belonging to a user. * * @param team The user ID * @returns A list of notes belonging to the user. */ fetchUserNotes(user) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.api.get(`/users/${user}/notes`); return response.data; }); } } exports.UserService = UserService;