From d1911680487591927b64a474aace4dcd538c0ef2 Mon Sep 17 00:00:00 2001 From: Putro <29204244+Pewtro@users.noreply.github.com> Date: Sat, 10 Aug 2024 23:39:52 +0200 Subject: [PATCH] [WoW] Add support for Character Appearance APIs --- .changeset/rare-days-tan.md | 5 ++ .../character-appearance.test.ts | 20 +++++++ .../character-appearance.ts | 14 +++++ .../wow/src/character-appearance/types.ts | 55 +++++++++++++++++++ packages/wow/src/index.ts | 6 ++ 5 files changed, 100 insertions(+) create mode 100644 .changeset/rare-days-tan.md create mode 100644 packages/wow/src/character-appearance/character-appearance.test.ts create mode 100644 packages/wow/src/character-appearance/character-appearance.ts create mode 100644 packages/wow/src/character-appearance/types.ts diff --git a/.changeset/rare-days-tan.md b/.changeset/rare-days-tan.md new file mode 100644 index 0000000..fd68705 --- /dev/null +++ b/.changeset/rare-days-tan.md @@ -0,0 +1,5 @@ +--- +'@blizzard-api/wow': minor +--- + +Add support for Character Appearance APIs diff --git a/packages/wow/src/character-appearance/character-appearance.test.ts b/packages/wow/src/character-appearance/character-appearance.test.ts new file mode 100644 index 0000000..2d1da7e --- /dev/null +++ b/packages/wow/src/character-appearance/character-appearance.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest'; +import { characterAppearanceSummary } from './character-appearance'; + +describe('characterAppearanceSummary', () => { + it('should return the correct ProtectedResource object', () => { + const realmSlug = 'test-realm'; + const characterName = 'test-character'; + const token = 'test-token'; + + const expectedResource = { + namespace: 'profile', + path: '/profile/wow/character/test-realm/test-character/appearance', + token: 'test-token', + }; + + const result = characterAppearanceSummary(realmSlug, characterName, token); + + expect(result).toEqual(expectedResource); + }); +}); diff --git a/packages/wow/src/character-appearance/character-appearance.ts b/packages/wow/src/character-appearance/character-appearance.ts new file mode 100644 index 0000000..2249bfa --- /dev/null +++ b/packages/wow/src/character-appearance/character-appearance.ts @@ -0,0 +1,14 @@ +import type { ProtectedResource } from '@blizzard-api/core'; +import type { CharacterAppearanceResponse } from './types'; + +export function characterAppearanceSummary( + realmSlug: string, + characterName: string, + token: string, +): ProtectedResource { + return { + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName.toLowerCase()}/appearance`, + token, + }; +} diff --git a/packages/wow/src/character-appearance/types.ts b/packages/wow/src/character-appearance/types.ts new file mode 100644 index 0000000..dbe65d9 --- /dev/null +++ b/packages/wow/src/character-appearance/types.ts @@ -0,0 +1,55 @@ +import type { Color, Faction, Gender, Href, KeyBase, NameId, NameIdKey } from '../base'; + +export interface CharacterAppearanceResponse { + _links: { self: Href }; + active_spec: NameIdKey; + character: Character; + customizations: Array; + faction: Faction; + gender: Gender; + guild_crest: GuildCrest; + items: Array; + playable_class: NameIdKey; + playable_race: NameIdKey; +} + +interface Character extends NameIdKey { + realm: { slug: string } & NameIdKey; +} + +interface Customization { + choice: Choice; + option: NameId; +} + +interface Choice { + display_order: number; + id: number; + name?: string; +} + +interface GuildCrest { + background: { color: RGBWithId }; + border: BorderEmblem; + emblem: BorderEmblem; +} + +interface RGBWithId { + id: number; + rgba: Color; +} + +interface BorderEmblem { + color: RGBWithId; + id: number; + media: { id: number } & KeyBase; +} + +interface Item { + enchant: number; + id: number; + internal_slot_id: number; + item_appearance_modifier_id: number; + slot: { name: string; type: string }; + subclass: number; +} diff --git a/packages/wow/src/index.ts b/packages/wow/src/index.ts index 3aa1211..3fed818 100644 --- a/packages/wow/src/index.ts +++ b/packages/wow/src/index.ts @@ -26,6 +26,7 @@ import { characterAchievementsSummary, characterAchievementStatistics, } from './character-achievements/character-achievements'; +import { characterAppearanceSummary } from './character-appearance/character-appearance'; import { connectedRealm, connectedRealmIndex, connectedRealmSearch } from './connected-realm/connected-realm'; import { conduit, @@ -184,6 +185,8 @@ export const wow = { //Character Achievements characterAchievementsSummary, characterAchievementStatistics, + //Character Appearance + characterAppearanceSummary, //Connected Realm connectedRealm, connectedRealmIndex, @@ -362,6 +365,9 @@ export * from './azerite-essence/types'; //Character Achievements export * from './character-achievements/character-achievements'; export * from './character-achievements/types'; +//Character Appearance +export * from './character-appearance/character-appearance'; +export * from './character-appearance/types'; //Connected Realm export * from './connected-realm/connected-realm'; export * from './connected-realm/types';