Skip to content

Commit 5f41693

Browse files
committed
feat(monetization): add get entitlement endpoint
1 parent 3a1b3cc commit 5f41693

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/core/src/api/monetization.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import {
1414
type Snowflake,
1515
} from 'discord-api-types/v10';
1616

17+
// TODO: discord-api-types
18+
type RESTGetAPIEntitlementResult = RESTGetAPIEntitlementsResult[number];
19+
1720
export class MonetizationAPI {
1821
public constructor(private readonly rest: REST) {}
1922

@@ -84,6 +87,24 @@ export class MonetizationAPI {
8487
}) as Promise<RESTGetAPIEntitlementsResult>;
8588
}
8689

90+
/**
91+
* Fetches an entitlement for an application.
92+
*
93+
* @see {@link https://discord.com/developers/docs/resources/entitlement#get-entitlement}
94+
* @param applicationId - The application id to fetch the entitlement for
95+
* @param entitlementId - The entitlement id to fetch
96+
* @param options - The options for fetching the entitlement
97+
*/
98+
public async getEntitlement(
99+
applicationId: Snowflake,
100+
entitlementId: Snowflake,
101+
{ signal }: Pick<RequestData, 'signal'> = {},
102+
) {
103+
return this.rest.get(Routes.entitlement(applicationId, entitlementId), {
104+
signal,
105+
}) as Promise<RESTGetAPIEntitlementResult>;
106+
}
107+
87108
/**
88109
* Creates a test entitlement for an application's SKU.
89110
*

0 commit comments

Comments
 (0)