UNPKG

@donation-alerts/api

Version:
60 lines 2.83 kB
import { type RateLimiterRequestOptions } from '@d-fischer/rate-limiter'; import { type UserIdResolvable } from '@donation-alerts/common'; import { DonationAlertsUser } from './donation-alerts-user'; import { BaseApi } from '../base-api'; /** * Donation Alerts Users API. * * @remarks * Provides methods to interact with Donation Alerts users, including retrieving user profiles * and socket connection tokens. */ export declare class DonationAlertsUsersApi extends BaseApi { /** * Fetches the authenticated user's information based on the provided user ID. * * @remarks * Requires `oauth-user-show` scope. * * @param user The ID of the user whose profile needs to be fetched. * @param rateLimiterOptions Optional rate limiter configuration to control API requests. * * @returns A {@link DonationAlertsUser} instance containing the user's profile information. * * @throws {@link HttpError} if the response status code falls outside the 200–299 range. * @throws {@link UnregisteredUserError} if the specified user is not registered in the authentication provider. * @throws {@link MissingScopeError} if the provided access token is missing the required `oauth-user-show` scope. * * @example * ```ts * const user = await apiClient.users.getUser(userId); * console.log(`User ID: ${user.id}, Name: ${user.name}`); * ``` */ getUser(user: UserIdResolvable, rateLimiterOptions?: RateLimiterRequestOptions): Promise<DonationAlertsUser>; /** * Fetches a Centrifugo connection token required for establishing real-time socket connections for the * specified user. * * @remarks * This method internally uses {@link getUser} method to fetch the profile of the user, then extracts * the `socketConnectionToken` property. * * @param user The ID of the user for whom the token is being fetched. * @param rateLimiterOptions Optional rate limiter configuration to control API requests. * * @returns A string containing the user's socket connection token. * * @throws {@link HttpError} if the response status code falls outside the 200–299 range. * @throws {@link UnregisteredUserError} if the specified user is not registered in the authentication provider. * @throws {@link MissingScopeError} if the provided access token is missing the required `oauth-user-show` scope. * * @example * ```ts * const token = await apiClient.users.getSocketConnectionToken(authenticatedUserId); * console.log(`Socket connection token: ${token}`); * ``` */ getSocketConnectionToken(user: UserIdResolvable, rateLimiterOptions?: RateLimiterRequestOptions): Promise<string>; } //# sourceMappingURL=donation-alerts-users-api.d.ts.map