// Generated from the LeavePulse contract. Do not edit. import { Resource, extractId } from "../runtime/resource"; import { fetchCachedOrThrow } from "../runtime/etag-store"; import type { components } from "../types"; import type * as models from "../models"; import type { ClientContext } from "../client"; import type { Snowflake } from "../runtime/snowflake"; type Data = components["schemas"]["PublicProfile"]; export class User extends Resource { constructor( data: Data, private readonly ctx: ClientContext, ) { super(data); } /** Re-fetch this User and hydrate in place. */ async refresh(): Promise { const data = await fetchCachedOrThrow( this.ctx.transport, this.ctx.etagStore, { method: "GET", path: `/v1/users/${this.id}/public-profile` }, ); let hydrated = data as Record; const id = extractId(hydrated); return this.ctx.cache.upsertAlias( "User", this.id, id, hydrated, () => this, ) as this; } /** Load this User's data (alias of refresh). */ fetch(): Promise { return this.refresh(); } /** Whether the current user may report (RFC ยง4). */ get canReport(): boolean { return this.hasCapability("report", "user.report"); } /** user.heatmap */ async heatmap(params?: { days?: number; }): Promise { return fetchCachedOrThrow( this.ctx.transport, this.ctx.etagStore, { method: "GET", path: `/v1/users/${this.id}/profile/activity`, query: { days: params?.days }, }, ); } /** user.gameplay */ async gameplay(): Promise { return fetchCachedOrThrow( this.ctx.transport, this.ctx.etagStore, { method: "GET", path: `/v1/users/${this.id}/profile/gameplay` }, ); } /** user.ownership */ async ownership(): Promise { return fetchCachedOrThrow( this.ctx.transport, this.ctx.etagStore, { method: "GET", path: `/v1/users/${this.id}/profile/ownership` }, ); } /** user.report */ async report( userId: Snowflake, body: models.ReportUserRequest, ): Promise { return this.ctx.transport.request({ method: "POST", path: `/v1/community/users/${userId}/report`, body, }); } }