From e6261b759a899cb909e72018450c37ea6c2ac520 Mon Sep 17 00:00:00 2001 From: Putro <29204244+Pewtro@users.noreply.github.com> Date: Sun, 11 Aug 2024 02:06:35 +0200 Subject: [PATCH] [WoW] Add support for Character Titles APIs --- .changeset/hot-poems-applaud.md | 5 +++++ .../character-titles/character-titles.test.ts | 20 +++++++++++++++++++ .../src/character-titles/character-titles.ts | 14 +++++++++++++ packages/wow/src/character-titles/types.ts | 15 ++++++++++++++ packages/wow/src/index.ts | 6 ++++++ 5 files changed, 60 insertions(+) create mode 100644 .changeset/hot-poems-applaud.md create mode 100644 packages/wow/src/character-titles/character-titles.test.ts create mode 100644 packages/wow/src/character-titles/character-titles.ts create mode 100644 packages/wow/src/character-titles/types.ts diff --git a/.changeset/hot-poems-applaud.md b/.changeset/hot-poems-applaud.md new file mode 100644 index 0000000..0396f50 --- /dev/null +++ b/.changeset/hot-poems-applaud.md @@ -0,0 +1,5 @@ +--- +'@blizzard-api/wow': minor +--- + +Add support for Character Titles APIs diff --git a/packages/wow/src/character-titles/character-titles.test.ts b/packages/wow/src/character-titles/character-titles.test.ts new file mode 100644 index 0000000..5fe44be --- /dev/null +++ b/packages/wow/src/character-titles/character-titles.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest'; +import { characterTitlesSummary } from './character-titles'; + +describe('characterTitlesSummary', () => { + 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/${realmSlug}/${characterName}/titles`, + token, + }; + + const result = characterTitlesSummary(realmSlug, characterName, token); + + expect(result).toEqual(expectedResource); + }); +}); diff --git a/packages/wow/src/character-titles/character-titles.ts b/packages/wow/src/character-titles/character-titles.ts new file mode 100644 index 0000000..66ccd9c --- /dev/null +++ b/packages/wow/src/character-titles/character-titles.ts @@ -0,0 +1,14 @@ +import type { ProtectedResource } from '@blizzard-api/core'; +import type { CharacterTitlesSummaryResponse } from './types'; + +export function characterTitlesSummary( + realmSlug: string, + characterName: string, + token: string, +): ProtectedResource { + return { + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName}/titles`, + token, + }; +} diff --git a/packages/wow/src/character-titles/types.ts b/packages/wow/src/character-titles/types.ts new file mode 100644 index 0000000..2e68224 --- /dev/null +++ b/packages/wow/src/character-titles/types.ts @@ -0,0 +1,15 @@ +import type { NameIdKey, ResponseBase } from '../base'; + +export interface CharacterTitlesSummaryResponse extends ResponseBase { + active_title: { display_string: string } & NameIdKey; + character: Character; + titles: Array; +} + +interface Realm extends NameIdKey { + slug: string; +} + +interface Character extends NameIdKey { + realm: Realm; +} diff --git a/packages/wow/src/index.ts b/packages/wow/src/index.ts index 13f3cd9..45be1b7 100644 --- a/packages/wow/src/index.ts +++ b/packages/wow/src/index.ts @@ -55,6 +55,7 @@ import { characterReputationsSummary } from './character-reputations/character-r import { characterSoulbinds } from './character-soulbinds/character-soulbinds'; import { characterSpecializationsSummary } from './character-specializations/character-specializations'; import { characterStatisticsSummary } from './character-statistics/character-statistics'; +import { characterTitlesSummary } from './character-titles/character-titles'; import { connectedRealm, connectedRealmIndex, connectedRealmSearch } from './connected-realm/connected-realm'; import { conduit, @@ -253,6 +254,8 @@ export const wow = { characterSpecializationsSummary, //Character Statistics characterStatisticsSummary, + //Character Titles + characterTitlesSummary, //Connected Realm connectedRealm, connectedRealmIndex, @@ -476,6 +479,9 @@ export * from './character-specializations/types'; //Character Statistics export * from './character-statistics/character-statistics'; export * from './character-statistics/types'; +//Character Titles +export * from './character-titles/character-titles'; +export * from './character-titles/types'; //Connected Realm export * from './connected-realm/connected-realm'; export * from './connected-realm/types';