Skip to content

Commit

Permalink
[WoW] Add support for Character Appearance APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pewtro committed Aug 10, 2024
1 parent 1d182dd commit d191168
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-days-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blizzard-api/wow': minor
---

Add support for Character Appearance APIs
20 changes: 20 additions & 0 deletions packages/wow/src/character-appearance/character-appearance.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
14 changes: 14 additions & 0 deletions packages/wow/src/character-appearance/character-appearance.ts
Original file line number Diff line number Diff line change
@@ -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<CharacterAppearanceResponse> {
return {
namespace: 'profile',
path: `/profile/wow/character/${realmSlug}/${characterName.toLowerCase()}/appearance`,
token,
};
}
55 changes: 55 additions & 0 deletions packages/wow/src/character-appearance/types.ts
Original file line number Diff line number Diff line change
@@ -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<Customization>;
faction: Faction;
gender: Gender;
guild_crest: GuildCrest;
items: Array<Item>;
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;
}
6 changes: 6 additions & 0 deletions packages/wow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -184,6 +185,8 @@ export const wow = {
//Character Achievements
characterAchievementsSummary,
characterAchievementStatistics,
//Character Appearance
characterAppearanceSummary,
//Connected Realm
connectedRealm,
connectedRealmIndex,
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit d191168

Please sign in to comment.