Skip to content

Commit

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

Add support for Character Equipment APIs
20 changes: 20 additions & 0 deletions packages/wow/src/character-equipment/character-equipment.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest';
import { characterEquipmentSummary } from './character-equipment';

describe('characterEquipmentSummary', () => {
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/equipment',
token: 'test-token',
};

const result = characterEquipmentSummary(realmSlug, characterName, token);

expect(result).toEqual(expectedResource);
});
});
14 changes: 14 additions & 0 deletions packages/wow/src/character-equipment/character-equipment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { ProtectedResource } from '@blizzard-api/core';
import type { CharacterEquipmentSummaryResponse } from './types';

export function characterEquipmentSummary(
realmSlug: string,
characterName: string,
token: string,
): ProtectedResource<CharacterEquipmentSummaryResponse> {
return {
namespace: 'profile',
path: `/profile/wow/character/${realmSlug}/${characterName.toLowerCase()}/equipment`,
token,
};
}
166 changes: 166 additions & 0 deletions packages/wow/src/character-equipment/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import type { Color, Href, KeyBase, NameIdKey } from '../base';

export interface CharacterEquipmentSummaryResponse {
_links: { self: Href };
character: Character;
equipped_item_sets: Array<Set>;
equipped_items: Array<EquippedItem>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}

interface Set {
display_string: string;
effects: Array<Effect>;
item_set: NameIdKey;
items: Array<ItemElement>;
}

interface Effect {
display_string: string;
is_active: boolean;
required_count: number;
}

interface ItemElement extends NameIdKey {
is_equipped?: boolean;
}

interface EquippedItem {
armor?: Armor;
binding: NameType;
bonus_list?: Array<number>;
context: number;
description?: string;
durability?: DisplayStringValue;
enchantments?: Array<Enchantment>;
inventory_type: NameType;
is_subclass_hidden?: boolean;
item: { id: number } & KeyBase;
item_class: NameIdKey;
item_subclass: NameIdKey;
level: DisplayStringValue;
limit_category?: string;
media: { id: number } & KeyBase;
modified_appearance_id?: number;
modified_crafting_stat?: Array<ModifiedCraftingStat>;
name: string;
name_description: NameDescription;
quality: NameType;
quantity: number;
requirements?: Requirements;
sell_price?: SellPrice;
set?: Set;
slot: NameType;
sockets?: Array<Socket>;
spells?: Array<Spell>;
stats?: Array<Stat>;
transmog?: Transmog;
unique_equipped?: string;
weapon?: Weapon;
}

interface Armor {
display: NameDescription;
value: number;
}

interface NameDescription {
color: Color;
display_string: string;
}

interface NameType {
name: string;
type: string;
}

interface DisplayStringValue {
display_string: string;
value: number;
}

interface Enchantment {
display_string: string;
enchantment_id: number;
enchantment_slot: EnchantmentSlot;
source_item?: NameIdKey;
}

interface EnchantmentSlot {
id: number;
type: string;
}

interface ModifiedCraftingStat {
id: number;
name: string;
type: string;
}

interface Requirements {
level: DisplayStringValue;
playable_classes?: PlayableClasses;
}

interface PlayableClasses {
display_string: string;
links: Array<NameIdKey>;
}

interface SellPrice {
display_strings: DisplayStrings;
value: number;
}

interface DisplayStrings {
copper: string;
gold: string;
header: string;
silver: string;
}

interface Socket {
display_string: string;
item: NameIdKey;
media: { id: number } & KeyBase;
socket_type: NameType;
}

interface Spell {
description: string;
spell: NameIdKey;
}

interface Stat {
display: NameDescription;
is_equip_bonus?: boolean;
is_negated?: boolean;
type: NameType;
value: number;
}

interface Transmog {
display_string: string;
item: NameIdKey;
item_modified_appearance_id: number;
}

interface Weapon {
attack_speed: DisplayStringValue;
damage: Damage;
dps: DisplayStringValue;
}

interface Damage {
damage_class: NameType;
display_string: string;
max_value: number;
min_value: number;
}
6 changes: 6 additions & 0 deletions packages/wow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
characterEncountersSummary,
characterRaids,
} from './character-encounters/character-encounters';
import { characterEquipmentSummary } from './character-equipment/character-equipment';
import { connectedRealm, connectedRealmIndex, connectedRealmSearch } from './connected-realm/connected-realm';
import {
conduit,
Expand Down Expand Up @@ -211,6 +212,8 @@ export const wow = {
characterDungeons,
characterEncountersSummary,
characterRaids,
//Character Equipment
characterEquipmentSummary,
//Connected Realm
connectedRealm,
connectedRealmIndex,
Expand Down Expand Up @@ -398,6 +401,9 @@ export * from './character-collections/types';
//Character Encounters
export * from './character-encounters/character-encounters';
export * from './character-encounters/types';
//Character Equipment
export * from './character-equipment/character-equipment';
export * from './character-equipment/types';
//Connected Realm
export * from './connected-realm/connected-realm';
export * from './connected-realm/types';
Expand Down

0 comments on commit 9a9714e

Please sign in to comment.