import { RawAnalyticsGranularity, RawAnalyticsMetric } from '../../enums/raw/Analytics'; import { Analytics } from '../../models/data/Analytics'; import { BookmarkFolder } from '../../models/data/BookmarkFolder'; import { CursoredData } from '../../models/data/CursoredData'; import { List } from '../../models/data/List'; import { Notification } from '../../models/data/Notification'; import { Tweet } from '../../models/data/Tweet'; import { User } from '../../models/data/User'; import { UserAbout } from '../../models/data/UserAbout'; import { RettiwtConfig } from '../../models/RettiwtConfig'; import { IProfileUpdateOptions } from '../../types/args/ProfileArgs'; import { FetcherService } from './FetcherService'; /** * Handles interacting with resources related to user account * * @public */ export declare class UserService extends FetcherService { /** * @param config - The config object for configuring the Rettiwt instance. * * @internal */ constructor(config: RettiwtConfig); /** * Gets the size in bytes of a base64 string. * * @param base64Data - The base64 data show size is required. * * @returns The size in bytes of the data. */ private _base64ByteSize; /** * Normalizes base64 data into just the raw base64 string. * * @param payload - The data to normalize. * * @returns The raw base64 part of the data. */ private _normalizeBase64; private _validateBase64Payload; /** * Get the about profile of a user. * * @param userName - The username/screenname of the target user. * * @returns The about profile of the user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the about profile of the User with username 'user1' or '@user1' * rettiwt.user.about('user1') // or @user1 * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ about(userName: string): Promise; /** * Get the list affiliates of a user. * * @param id - The ID of the target user. If no id is provided, the logged-in user's id is used. * @param count - The number of affiliates to fetch, must be \<= 100. * @param cursor - The cursor to the batch of affiliates to fetch. * * @returns The list of users affiliated to the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 100 affiliates of the User with id '1234567890' * rettiwt.user.affiliates('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ affiliates(id?: string, count?: number, cursor?: string): Promise>; /** * Get the analytics overview of the logged in user. * * @param fromTime - The start time of the analytics period. Defaults to 7 days ago. * @param toTime - The end time of the analytics period. Defaults to now. * @param granularity - The granularity of the analytics data. Defaults to daily. * @param metrics - The metrics to include in the analytics data. Defaults to all available metrics available. * @param showVerifiedFollowers - Whether to include verified follower count and relationship counts in the response. Defaults to true. * * @returns The raw analytics data of the user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the analytics overview of the logged in user * rettiwt.user.analytics().then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ analytics(fromTime?: Date, toTime?: Date, granularity?: RawAnalyticsGranularity, metrics?: RawAnalyticsMetric[], showVerifiedFollowers?: boolean): Promise; /** * Get the list of tweets in a specific bookmark folder of the logged in user. * * @param folderId - The ID of the bookmark folder. * @param count - The number of tweets to fetch, must be \<= 100. * @param cursor - The cursor to the batch of tweets to fetch. * * @returns The list of tweets in the bookmark folder. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 100 tweets from bookmark folder with ID '2001752149647049173' * rettiwt.user.bookmarkFolderTweets('2001752149647049173') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ bookmarkFolderTweets(folderId: string, count?: number, cursor?: string): Promise>; /** * Get the list of bookmark folders of the logged in user. * * @param cursor - The cursor to the batch of bookmark folders to fetch. * * @returns The list of bookmark folders. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching all bookmark folders of the logged in user * rettiwt.user.bookmarkFolders() * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ bookmarkFolders(cursor?: string): Promise>; /** * Get the list of bookmarks of the logged in user. * * @param count - The number of bookmakrs to fetch, must be \<= 100. * @param cursor - The cursor to the batch of bookmarks to fetch. * * @returns The list of tweets bookmarked by the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the most recent 100 liked Tweets of the logged in User * rettiwt.user.bookmarks() * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ bookmarks(count?: number, cursor?: string): Promise>; /** * Changes the password of the authenticated user. * * @param currentPassword - The current account password. * @param newPassword - The new password to set. * @returns Whether the password was changed successfully. * * @remarks * After a successful password change, this method attempts to rotate the current * `apiKey` using cookies returned by Twitter. If rotation is not possible, you * must re-authenticate and obtain a new `apiKey` to continue making authenticated * requests. */ changePassword(currentPassword: string, newPassword: string): Promise; /** * Changes the username (screen_name) of the authenticated user. * * @param newUsername - The new username (with or without `@`). * @returns Whether the username was changed successfully. */ changeUsername(newUsername: string): Promise; /** * Get the details of the logged in user. * * @returns The details of the user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the details of the User * rettiwt.user.details() * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ details(): Promise; /** * Get the details of a user. * * @param id - The ID/username of the target user. * * @returns The details of the user. * * @example * * #### Fetching the details of a single user using username * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the details of the User with username 'user1' or '@user1' * rettiwt.user.details('user1') // or @user1 * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` * * @example * * #### Fetching the details of a single user using ID * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the details of the User with id '1234567890' * rettiwt.user.details('1234567890') * .then(res => { * console.log(res); # 'res' is a single tweet * }) * .catch(err => { * console.log(err); * }); * ``` */ details(id: string): Promise; /** * Get the details of multiple users in bulk. * * @param id - The list of IDs of the target users. * * @returns The details of the users. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the details of the users with IDs '123', '456', '789' * rettiwt.user.details(['123', '456', '789']) * .then(res => { * console.log(res); # 'res' is an array of users * }) * .catch(err => { * console.log(err); * }); * ``` */ details(id: string[]): Promise; /** * Follow a user. * * @param id - The ID the user to be followed. * * @returns Whether following was successful or not. * * @throws Code 108 if given user id is invalid. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Following the User with id '1234567890' * rettiwt.user.follow('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ follow(id: string): Promise; /** * Get the followed feed of the logged in user. * * @param cursor - The cursor to the batch of feed items to fetch. * * @returns - The followed feed of the logged-in user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 35 followed feed items of the logged-in user * rettiwt.user.followed() * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` * * @remarks Always returns 35 feed items, with no way to customize the count. */ followed(cursor?: string): Promise>; /** * Get the list followers of a user. * * @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used. * @param count - The number of followers to fetch, must be \<= 100. * @param cursor - The cursor to the batch of followers to fetch. * * @returns The list of users following the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 100 followers of the User with id '1234567890' * rettiwt.user.followers('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ followers(id?: string, count?: number, cursor?: string): Promise>; /** * Get the list of users who are followed by a user. * * @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used. * @param count - The number of following to fetch, must be \<= 100. * @param cursor - The cursor to the batch of following to fetch. * * @returns The list of users followed by the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 100 following of the User with id '1234567890' * rettiwt.user.following('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ following(id?: string, count?: number, cursor?: string): Promise>; /** * Get the highlighted tweets of a user. * * @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used. * @param count - The number of followers to fetch, must be \<= 100. * @param cursor - The cursor to the batch of followers to fetch. * * @returns The list of highlighted tweets of the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the top 100 highlights of the User with id '1234567890' * rettiwt.user.highlights('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ highlights(id?: string, count?: number, cursor?: string): Promise>; /** * Get the list of tweets liked by the logged in user. * * @param count - The number of likes to fetch, must be \<= 100. * @param cursor - The cursor to the batch of likes to fetch. * * @returns The list of tweets liked by the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the most recent 100 liked Tweets of the logged in User * rettiwt.user.likes() * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ likes(count?: number, cursor?: string): Promise>; /** * Get the list of of the the logged in user. Includes both followed and owned. * * @param count - The number of lists to fetch, must be \<= 100. * @param cursor - The cursor to the batch of likes to fetch. * * @returns The list of tweets liked by the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 100 Lists of the logged in User * rettiwt.user.lists() * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ lists(count?: number, cursor?: string): Promise>; /** * Get the media timeline of a user. * * @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used. * @param count - The number of media to fetch, must be \<= 100. * @param cursor - The cursor to the batch of media to fetch * * @returns The media timeline of the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 100 timeline media tweets of the User with id '1234567890' * rettiwt.user.timeline('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ media(id?: string, count?: number, cursor?: string): Promise>; /** * Stream notifications of the logged in user in pseudo real-time. * * @param pollingInterval - The interval in milliseconds to poll for new tweets. Default interval is 60000 ms. * * @returns An async generator that yields new notifications as they are received. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Creating a function that streams all new notifications * async function streamNotifications() { * try { * // Awaiting for the notifications returned by the AsyncGenerator returned by the method * for await (const notification of rettiwt.user.notifications(5000)) { * console.log(notification.message); * } * } * catch (err) { * console.log(err); * } * } * * // Calling the function * streamNotifications(); * ``` */ notifications(pollingInterval?: number): AsyncGenerator; /** * Get the recommended feed of the logged in user. * * @param cursor - The cursor to the batch of feed items to fetch. * * @returns - The recommended feed of the logged-in user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 35 recommended feed items of the logged-in user * rettiwt.user.recommended() * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` * * @remarks Always returns 35 feed items, with no way to customize the count. */ recommended(cursor?: string): Promise>; /** * Get the reply timeline of a user. * * @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used. * @param count - The number of replies to fetch, must be \<= 20. * @param cursor - The cursor to the batch of replies to fetch. * * @returns The reply timeline of the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 100 timeline replies of the User with id '1234567890' * rettiwt.user.replies('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` * * @remarks * * If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet. */ replies(id?: string, count?: number, cursor?: string): Promise>; /** * Search for a username. * * @param userName - The username to search for. * @param count - The number of results to fetch, must be \<= 20. * @param cursor - The cursor to the batch of results to fetch. * * @returns The list of users that match the given username. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the top 5 matching users for the username 'user1' * rettiwt.user.search('user1') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ search(userName: string, count?: number, cursor?: string): Promise>; /** * Get the list of subscriptions of a user. * * @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used. * @param count - The number of subscriptions to fetch, must be \<= 100. * @param cursor - The cursor to the batch of subscriptions to fetch. * * @returns The list of subscriptions by the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 100 subscriptions of the User with id '1234567890' * rettiwt.user.subscriptions('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ subscriptions(id?: string, count?: number, cursor?: string): Promise>; /** * Get the tweet timeline of a user. * * @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used. * @param count - The number of timeline items to fetch, must be \<= 20. * @param cursor - The cursor to the batch of timeline items to fetch. * * @returns The timeline of the target user. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Fetching the first 20 timeline tweets of the User with id '1234567890' * rettiwt.user.timeline('1234567890') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` * * @remarks * * - If the target user has a pinned tweet, the returned timeline has one item extra and this is always the pinned tweet. * - If timeline is fetched without authenticating, then the most popular tweets of the target user are returned instead. */ timeline(id?: string, count?: number, cursor?: string): Promise>; /** * Unfollow a user. * * @param id - The ID the user to be unfollowed. * * @returns Whether unfollowing was successful or not. * * @example * * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Unfollowing the User with id '12345678' * rettiwt.user.unfollow('12345678') * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ unfollow(id: string): Promise; /** * Update the logged in user's profile. * * @param options - The profile update options. * * @returns Whether the profile update was successful or not. * * @example * * #### Updating only the display name * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Updating the display name of the logged in user * rettiwt.user.updateProfile({ name: 'New Display Name' }) * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` * * @example * * #### Updating multiple profile fields * ```ts * import { Rettiwt } from 'rettiwt-api'; * * // Creating a new Rettiwt instance using the given 'API_KEY' * const rettiwt = new Rettiwt({ apiKey: API_KEY }); * * // Updating multiple profile fields * rettiwt.user.updateProfile({ * name: 'New Display Name', * location: 'Istanbul', * description: 'Hello world!', * url: 'https://example.com' * }) * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }); * ``` */ updateProfile(options: IProfileUpdateOptions): Promise; /** * Updates the profile banner of the authenticated user. * * @param bannerBase64 - The base64-encoded banner image data. * @returns Whether the profile banner was updated successfully. */ updateProfileBanner(bannerBase64: string): Promise; /** * Updates the profile image of the authenticated user. * * @param imageBase64 - The base64-encoded image data. * @returns Whether the profile image was updated successfully. */ updateProfileImage(imageBase64: string): Promise; }