Skip to content

Commit ac3cd42

Browse files
committed
chore: add more types to setstore responses
1 parent 213c96c commit ac3cd42

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

example/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ const setStorePluginApi = MCSetsAPI.from(setStorePluginApiKey, 'setstore')
2626
*/
2727

2828
// // Use base API to fetch health status (no auth required)
29-
// await baseApi.getHealth().then(console.log)
29+
await baseApi.getHealth().then(console.log)
3030

3131
// Use the personal API to fetch the profile of the user that supplied the API token
32-
await personalApi.getSales().then(console.log)
32+
await personalApi.getProfile().then(console.log)
3333

3434
// // Use the enterprise API to fetch products (requires enterprise API key, see ENV for key examples)
35-
// await enterpriseApi.getProducts().then(console.log)
35+
await enterpriseApi.getProducts().then(console.log)
3636

3737
// // Use the set store plugin API to fetch pending delivery commands (requires set store plugin API key, see ENV for key examples)
38-
// await setStorePluginApi.sendServerHeartbeat().then(console.log)
38+
await setStorePluginApi.fetchPendingDeliveryCommands().then(console.log)

index.d.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ declare module 'mcsets-js-sdk-client' {
2121
getApiTokens(): Promise<DataResponse<ApiToken[]>>
2222
revokeApiToken(tokenId: string): Promise<DataResponse<undefined>>
2323

24-
getCreditsBalance(): Promise<>
25-
getStatistics(): Promise<>
24+
getCreditsBalance(): Promise<DataResponse<CreditsBalance>>
25+
getStatistics(): Promise<DataResponse<AccountStatistics>>
2626

2727
getProducts(): Promise<>
2828
getProduct(productId: string): Promise<>
@@ -36,7 +36,7 @@ declare module 'mcsets-js-sdk-client' {
3636
export class SetStoreAPI extends MCSetsAPI {
3737
registerGameServerConnection(): Promise<>
3838

39-
fetchPendingDeliveryCommands(): Promise<>
39+
fetchPendingDeliveryCommands(): Promise<CommandDelivery>
4040
deliverCommand(): Promise<>
4141

4242
setOnlinePlayers(): Promise<>
@@ -212,6 +212,16 @@ declare module 'mcsets-js-sdk-client' {
212212
* SetStore types
213213
*/
214214

215+
export interface CommandDelivery {
216+
success: boolean,
217+
deliveries: Delivery[],
218+
count: number
219+
}
220+
221+
export interface Delivery {
222+
// TODO: Get proper data structure of command deliveries
223+
}
224+
215225
/**
216226
* Enterprise types
217227
*/

src/setstore/api.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ module.exports = class SetStoreAPI extends MCSetsAPI {
77
return await this.rest.post('/connect')
88
}
99

10+
/**
11+
* Gets the pending delivery commands that still need to be executed
12+
* for the specified set store after purchases.
13+
* @returns {Promise<import('mcsets-js-sdk-client').CommandDelivery>}
14+
*/
1015
async fetchPendingDeliveryCommands () {
1116
return await this.rest.get('/queue')
1217
}

0 commit comments

Comments
 (0)