Skip to content

Commit bcb46d5

Browse files
committed
chore: Allow optional includeUsage (default: true)
1 parent 2d99708 commit bcb46d5

File tree

1 file changed

+6
-5
lines changed
  • packages/service-utils/src/core

1 file changed

+6
-5
lines changed

packages/service-utils/src/core/api.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type CoreServiceConfig = {
2020
serviceApiKey: string;
2121
serviceAction?: string;
2222
useWalletAuth?: boolean;
23+
includeUsage?: boolean;
2324
};
2425

2526
type Usage = {
@@ -85,8 +86,8 @@ export async function fetchKeyMetadataFromApi(
8586
clientId: string,
8687
config: CoreServiceConfig,
8788
): Promise<ApiResponse> {
88-
const { apiUrl, serviceScope, serviceApiKey } = config;
89-
const url = `${apiUrl}/v1/keys/use?clientId=${clientId}&scope=${serviceScope}&includeUsage=true`;
89+
const { apiUrl, serviceScope, serviceApiKey, includeUsage = true } = config;
90+
const url = `${apiUrl}/v1/keys/use?clientId=${clientId}&scope=${serviceScope}&includeUsage=${includeUsage}`;
9091
const response = await fetch(url, {
9192
method: "GET",
9293
headers: {
@@ -111,10 +112,10 @@ export async function fetchAccountFromApi(
111112
config: CoreServiceConfig,
112113
useWalletAuth: boolean,
113114
): Promise<ApiAccountResponse> {
114-
const { apiUrl, serviceApiKey } = config;
115+
const { apiUrl, serviceApiKey, includeUsage = true } = config;
115116
const url = useWalletAuth
116-
? `${apiUrl}/v1/wallet/me?includeUsage=true`
117-
: `${apiUrl}/v1/account/me?includeUsage=true`;
117+
? `${apiUrl}/v1/wallet/me?includeUsage=${includeUsage}`
118+
: `${apiUrl}/v1/account/me?includeUsage=${includeUsage}`;
118119
const response = await fetch(url, {
119120
method: "GET",
120121
headers: {

0 commit comments

Comments
 (0)