From 68c07e7a5ab8acf5ba7785eed594497e05467061 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sat, 13 Feb 2021 14:35:58 -0600 Subject: create member, profile, and profiles cleaners --- src/cleaners/skyblock/profiles.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/cleaners/skyblock/profiles.ts (limited to 'src/cleaners/skyblock/profiles.ts') diff --git a/src/cleaners/skyblock/profiles.ts b/src/cleaners/skyblock/profiles.ts new file mode 100644 index 0000000..c942a14 --- /dev/null +++ b/src/cleaners/skyblock/profiles.ts @@ -0,0 +1,24 @@ +import { HypixelPlayerStatsSkyBlockProfiles } from "../../hypixelApi" +import { CleanBasicProfile, CleanProfile, cleanSkyblockProfileResponseLighter } from "./profile" + +export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBlockProfiles): CleanBasicProfile[] { + let profiles: CleanBasicProfile[] = [] + for (const profile of Object.values(rawProfiles)) { + profiles.push({ + uuid: profile.profile_id, + name: profile.cute_name + }) + } + console.log('cleanPlayerSkyblockProfiles', profiles) + return profiles +} + +/** Convert an array of raw profiles into clean profiles */ +export async function cleanSkyblockProfilesResponse(data: any[]): Promise { + const cleanedProfiles: CleanProfile[] = [] + for (const profile of data) { + let cleanedProfile = await cleanSkyblockProfileResponseLighter(profile) + cleanedProfiles.push(cleanedProfile) + } + return cleanedProfiles +} -- cgit