1.0.2 • Published 4 years ago
noticebord-client v1.0.2
client-typescript
The official Typescript client library for the Noticebord API.
Installation
To install, run the following command:
NPM:
npm install noticebord-clientYarn:
yarn add noticebord-clientCDN:
The package is also availavable from JsDelivr and Unpkg.
Usage
NoticebordClient
This is the entry point to the SDK.
const client = new NoticebordClient();
// Providing a valid access token will allow you tyo perform action on behalf of users
const client = new NoticebordClient(token);
// You can also provide a custom base URL to connect to an instance of the web platform hosted elsewhere
const client = new NoticebordClient(token, baseUrl);Tokens
A token is needed to access restricted endpoints and perform actions on behalf of users.
// Use your request object to get a token from the server
const token = await NoticebordClient.getToken({
email: "",
password: "",
deviceName: "",
});
// You can optionally provide a custom base url
const token = await NoticebordClient.getToken({
email: "",
password: "",
deviceName: "",
}, baseUrl);Notices
This service allows you to perform operations related to notices.
// An instance of the notice service can be obtained from the Noticebord client.
const service = client.notices
// Creating a notice
const notice = await service.createNotice({
title: "",
body: "",
topics: [],
anonymous: false,
public: true,
});
// Fetching notices
const notices = await service.fetchNotices();
// This endpoint is cursor-paginated, and you can optionally include a cursor to fetch results from a specific page.
const notices = await service.fetchNotices(cursor);
// Fetching a single notice
const notices = await service.fetchNotice(noticeId);
// Updating notices
const notice = await service.updateNotice({
title: "",
body: "",
topics: [],
anonymous: false,
public: true,
});
// Deleting notices
await service.deleteNotice(noticeId);Team Notices
This service allows you to perform operations related to team notices.
// An instance of the team notice service can be obtained from the Noticebord client.
const service = client.teamNotices
// Creating a team notice
const teamNotice = await service.createTeamNotice(teamId, {
title: "",
body: "",
});
// Fetching team notices
const teamNotices = await service.fetchTeamNotices(teamId);
// This endpoint is cursor-paginated, and you can include a cursor, to fetch results from a specific page.
const teamNotices = await service.fetchTeamNotices(teamId, cursor);
// Fetching a single team notice
const teamNotice = await service.fetchTeamNotice(teamId, teamNoticeId);
// Updating team notices
const teamNotice = await service.updateTeamNotice(teamId, {
title: "",
body: "",
});
// Deleting team notices
await service.deleteTeamNotice(teamId, teamNoticeId);Topics
This service allows you to perform operations related to topics.
// An instance of the topic service can be obtained from the Noticebord client.
const service = client.topics
// Fetching topics
const topics = await service.fetchTopics();
// Fetching a single topic
const topic = await service.fetchTopic(topicId);
// Fetching topic notices
const topicNotices = await service.fetchTopicNotices(topicId);
// This endpoint is cursor-paginated, and you can include a cursor, to fetch results from a specific page.
const topicNotices = await service.fetchTopicNotices(topicId, cursor);Teams
This service allows you to perform operations related to teams.
// An instance of the team service can be obtained from the Noticebord client.
const service = client.teams
// Fetching teams
const teams = await service.fetchTeams();
// Fetching a single team
const team = await service.fetchTeam(teamId);Users
This service allows you to perform operations related to users.
// An instance of the user service can be obtained from the Noticebord client.
const service = client.users
// Fetching users
const users = await service.fetchUsers();
// Fetching a single user
const user = await service.fetchUser(userId);
// Fetching the current user
const currentUser = await service.fetchCurrentUser();
// Fetching user notices
const userNotices = await service.fetchUsersNotices(UserId);
// Fetching user notes (private notices)
const userNotes = await service.fetchUserNotes(userId);Building From Source
0. Prerequisites
- Git
1. Clone the repo from GitHub
git clone https://github.com/noticebord/client-typescript2. Build the project
NPM
npm run buildYarn
yarn build3. Running Tests
NPM
npm run testYarn
yarn testContributing
This project is governed by the Noticebord contribution guidelines.