Skip to content

Commit

Permalink
fetchUniversesIcons
Browse files Browse the repository at this point in the history
  • Loading branch information
PurpleCreativity committed Dec 14, 2024
1 parent bf0210c commit 89aa43e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/functions/legacy/thumbnails/v1/fetchUniversesIcons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type BloxFetch from "../../../../main.js";
import type { LegacyFetchOptions } from "../../../../types/internal/LegacyFetchHandler.js";
import {
UniverseIconImageFormat,
UniverseIconImageReutrnPolicy,
UniverseIconImageSize,
} from "../../../../types/legacy/Thumbnails.Enums.js";
import type { fetchedImage } from "../../../../types/legacy/Thumbnails.js";

export type fetchUniversesIconsResponse = { data: fetchedImage[] };

export type fetchUniversesIconsType = (
this: BloxFetch,

universeId: number,
returnPolicy?: UniverseIconImageReutrnPolicy,
size?: UniverseIconImageSize,
format?: UniverseIconImageFormat,
isCircular?: boolean,

fetchOptions?: Partial<LegacyFetchOptions>,
) => Promise<fetchedImage[]>;

export default async function (
this: BloxFetch,

universeId: number,
returnPolicy: UniverseIconImageReutrnPolicy = UniverseIconImageReutrnPolicy.PlaceHolder,
size: UniverseIconImageSize = UniverseIconImageSize["50x50"],
format: UniverseIconImageFormat = UniverseIconImageFormat.Png,
isCircular = false,

fetchOptions?: Partial<LegacyFetchOptions>,
): Promise<fetchedImage[]> {
return (
await this.LegacyFetchHandler.fetch<fetchUniversesIconsResponse>("GET", "ThumbnailsV1", "/v1/badges/icons", {
params: {
universeId: universeId,
returnPolicy: returnPolicy,

size: size,
format: format,
isCircular: isCircular,
},
body: {},
useCache: fetchOptions?.useCache ?? true,
})
).data;
}
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import fetchBadgeIcons, { type fetchBadgeIconsType } from "./functions/legacy/th
import fetchUniversepassIcons, {
type fetchUniversepassIconsType,
} from "./functions/legacy/thumbnails/v1/fetchUniversepassIcons.js";
import fetchUniversesIcons, {
type fetchUniversesIconsType,
} from "./functions/legacy/thumbnails/v1/fetchUniversesIcons.js";
import fetchUniversesThumbnails, {
type fetchUniversesThumbnailsType,
} from "./functions/legacy/thumbnails/v1/fetchUniversesThumbnails.js";
Expand Down Expand Up @@ -81,6 +84,8 @@ export default class BloxFetch {
readonly fetchUniversepassIcons: fetchUniversepassIconsType;

readonly fetchUniversesThumbnails: fetchUniversesThumbnailsType;

readonly fetchUniversesIcons: fetchUniversesIconsType;
/**
* Initializes a new instance of the BloxFetch class.
*/
Expand All @@ -103,5 +108,6 @@ export default class BloxFetch {
this.fetchBadgeIcons = fetchBadgeIcons;
this.fetchUniversepassIcons = fetchUniversepassIcons;
this.fetchUniversesThumbnails = fetchUniversesThumbnails;
this.fetchUniversesIcons = fetchUniversesIcons;
}
}
24 changes: 24 additions & 0 deletions src/types/legacy/Thumbnails.Enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ export enum GroupIconImageFormat {
Webp = "Webp",
}

// Universe Icon

export enum UniverseIconImageReutrnPolicy {
PlaceHolder = "PlaceHolder",
ForcePlaceHolder = "ForcePlaceHolder",
AutoGenerated = "AutoGenerated",
ForceAutoGenerated = "ForceAutoGenerated",
}

export enum UniverseIconImageSize {
"50x50" = "50x50",
"128x128" = "128x128",
"150x150" = "150x150",
"256x256" = "256x256",
"420x420" = "420x420",
"512x512" = "512x512",
}

export enum UniverseIconImageFormat {
Png = "Png",
Jpeg = "Jpeg",
Webp = "Webp",
}

// Universe Thumbnail

export enum UniverseThumbnailImageSize {
Expand Down

0 comments on commit 89aa43e

Please sign in to comment.