@trophyso/node
Version:
NodeJS SDK for the Trophy API
148 lines (147 loc) • 5.92 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);
/**
* Create 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>;
/**
* Identify a user.
* @throws {@link TrophyApi.BadRequestError}
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.identify("id", {
* email: "user@example.com",
* tz: "Europe/London"
* })
*/
identify(id: string, request: TrophyApi.UpdatedUser, requestOptions?: Users.RequestOptions): Promise<TrophyApi.User>;
/**
* Update a user.
* @throws {@link TrophyApi.BadRequestError}
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.NotFoundError}
* @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 a summary of metric events over time for a user.
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.NotFoundError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.metricEventSummary("userId", "words-written", {
* aggregation: TrophyApi.UsersMetricEventSummaryRequestAggregation.Daily,
* startDate: "2024-01-01",
* endDate: "2024-01-31"
* })
*/
metricEventSummary(id: string, key: string, request: TrophyApi.UsersMetricEventSummaryRequest, requestOptions?: Users.RequestOptions): Promise<TrophyApi.UsersMetricEventSummaryResponseItem[]>;
/**
* 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.CompletedAchievementResponse[]>;
/**
* 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>;
/**
* Get a user's points.
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.NotFoundError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.points("userId", {})
*/
points(id: string, request?: TrophyApi.UsersPointsRequest, requestOptions?: Users.RequestOptions): Promise<TrophyApi.GetUserPointsResponse>;
/**
* Get a summary of points awards over time for a user.
* @throws {@link TrophyApi.UnauthorizedError}
* @throws {@link TrophyApi.NotFoundError}
* @throws {@link TrophyApi.UnprocessableEntityError}
*
* @example
* await trophyApi.users.pointsEventSummary("userId", {
* aggregation: TrophyApi.UsersPointsEventSummaryRequestAggregation.Daily,
* startDate: "2024-01-01",
* endDate: "2024-01-31"
* })
*/
pointsEventSummary(id: string, request: TrophyApi.UsersPointsEventSummaryRequest, requestOptions?: Users.RequestOptions): Promise<TrophyApi.UsersPointsEventSummaryResponseItem[]>;
}