UNPKG

getsocial-react-native-sdk

Version:
86 lines (76 loc) 1.94 kB
// @flow import UserId from './../UserId.js'; import CommunitiesIds from './CommunitiesIds.js'; /** * FollowersQuery object. */ export default class FollowersQuery { ids: CommunitiesIds; searchTerm: string = ''; // eslint-disable-next-line require-jsdoc constructor(ids: CommunitiesIds) { this.ids = ids; } /** * Get followers of topic with ID. * * @param {string} id Topic ID. * @return {FollowersQuery} new query. */ static ofTopic(id: string): FollowersQuery { return new FollowersQuery(CommunitiesIds.topic(id)); } /** * Get followers of group with ID. * * @param {string} id Group ID. * @return {FollowersQuery} new query. */ static ofGroup(id: string): FollowersQuery { return new FollowersQuery(CommunitiesIds.group(id)); } /** * Get followers of user with ID. * * @param {UserId} id User ID. * @return {FollowersQuery} new query. */ static ofUser(id: UserId): FollowersQuery { return new FollowersQuery(CommunitiesIds.user(id)); } /** * Get followers of label with ID. * * @param {string} id Label ID. * @return {FollowersQuery} new query. */ static ofLabel(id: string): FollowersQuery { return new FollowersQuery(CommunitiesIds.label(id)); } /** * Get followers of tag with ID. * * @param {string} id Label ID. * @return {FollowersQuery} new query. */ static ofTag(id: string): FollowersQuery { return new FollowersQuery(CommunitiesIds.tag(id)); } /** * Filter followers by username or displayName. * * @param {string} searchTerm Beginning of name. * @return {FollowersQuery} same query. */ withName(searchTerm: string): FollowersQuery { this.searchTerm = searchTerm; return this; } /** * Generates JSON string. * @return {string} object as json. */ toJSON() { return {ids: this.ids, searchTerm: this.searchTerm}; } }