@trophyso/node
Version:
NodeJS SDK for the Trophy API
96 lines (95 loc) • 3.56 kB
TypeScript
/**
* This file was auto-generated by Fern from our API Definition.
*/
import * as environments from "../../../../environments";
import * as core from "../../../../core";
import * as TrophyApi from "../../..";
export declare namespace Users {
interface Options {
environment?: core.Supplier<environments.TrophyApiEnvironment | string>;
apiKey: core.Supplier<string>;
}
interface RequestOptions {
timeoutInSeconds?: number;
maxRetries?: number;
}
}
export declare class Users {
protected readonly _options: Users.Options;
constructor(_options: Users.Options);
/**
* Identify a new user.
* @throws {@link TrophyApi.BadRequestError}
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.create({
* id: "user-id"
* })
*/
create(request: TrophyApi.UpsertedUser, requestOptions?: Users.RequestOptions): Promise<TrophyApi.User>;
/**
* Get a single user.
* @throws {@link TrophyApi.BadRequestError}
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.get("userId")
*/
get(id: string, requestOptions?: Users.RequestOptions): Promise<TrophyApi.User>;
/**
* Update a user.
* @throws {@link TrophyApi.BadRequestError}
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.update("id", {
* email: "user@example.com",
* tz: "Europe/London"
* })
*/
update(id: string, request: TrophyApi.UpdatedUser, requestOptions?: Users.RequestOptions): Promise<TrophyApi.User>;
/**
* Get a single user's progress against all active metrics.
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.NotFoundError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.allMetrics("userId")
*/
allMetrics(id: string, requestOptions?: Users.RequestOptions): Promise<TrophyApi.MetricResponse[]>;
/**
* Get a user's progress against a single active metric.
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.NotFoundError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.singleMetric("userId", "key")
*/
singleMetric(id: string, key: string, requestOptions?: Users.RequestOptions): Promise<TrophyApi.MetricResponse>;
/**
* Get all of a user's completed achievements.
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.NotFoundError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.allAchievements("userId")
*/
allAchievements(id: string, requestOptions?: Users.RequestOptions): Promise<TrophyApi.AchievementResponse[]>;
/**
* Get a user's streak data.
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.NotFoundError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.streak("userId", {})
*/
streak(id: string, request?: TrophyApi.UsersStreakRequest, requestOptions?: Users.RequestOptions): Promise<TrophyApi.StreakResponse>;
}