Skip to content

Commit 968e7a1

Browse files
skin route
1 parent 1efab4a commit 968e7a1

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mcutils-js-api",
3-
"version": "2.0.42",
3+
"version": "2.0.43",
44
"module": "dist/index.js",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { StatisticsResponse } from "./types/response/statistics-response";
1212
import { Skin } from "./types/player/skin/skin";
1313
import { Page } from "./types/pagination/pagination";
1414
import { PlayerSearchEntry } from "./types/player/player-search-entry";
15-
import { SkinsResponsePage } from "./types/response/skins-response";
15+
import { SkinsResponsePage } from "./types/response/skin/skins-response";
16+
import { SkinDTO } from "./types/response/skin/skin-dto";
1617

1718
type RequestOptions = RequestInit & { responseType?: "json" | "arrayBuffer" };
1819

@@ -333,6 +334,17 @@ export class McUtilsAPI {
333334
const { data, error } = await this.request<PlayerSearchEntry[]>(`/players${this.buildParams({ query: query })}`);
334335
return error ? { error } : { entries: data };
335336
}
337+
338+
/**
339+
* Fetch the details of a specific skin.
340+
*
341+
* @param id the ID of the skin (UUID)
342+
* @returns the skin details or the error (if one occurred)
343+
*/
344+
async fetchSkin(id: string): Promise<{ skin?: SkinDTO; error?: ErrorResponse }> {
345+
const { data, error } = await this.request<SkinDTO>(`/skins/${id}`);
346+
return error ? { error } : { skin: data };
347+
}
336348
}
337349

338350
export default McUtilsAPI;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export type SkinDTO = {
2+
id: string;
3+
imageUrl: string;
4+
accountsUsed: number;
5+
firstSeenUsing: string;
6+
accountsSeenUsing: string[];
7+
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Page } from "../pagination/pagination";
1+
import { Page } from "../../pagination/pagination";
22

33
export type SkinsResponse = {
44
id: string;

0 commit comments

Comments
 (0)