From 28b96768b6b44d9bfb3618314d4c1322523414bf Mon Sep 17 00:00:00 2001 From: Putro <29204244+Pewtro@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:21:53 +0200 Subject: [PATCH] [WoW] Add support for Character Profile APIs --- .changeset/plenty-trainers-push.md | 5 ++ .../character-profile.test.ts | 34 +++++++++++ .../character-profile/character-profile.ts | 26 +++++++++ packages/wow/src/character-profile/types.ts | 58 +++++++++++++++++++ packages/wow/src/index.ts | 7 +++ 5 files changed, 130 insertions(+) create mode 100644 .changeset/plenty-trainers-push.md create mode 100644 packages/wow/src/character-profile/character-profile.test.ts create mode 100644 packages/wow/src/character-profile/character-profile.ts create mode 100644 packages/wow/src/character-profile/types.ts diff --git a/.changeset/plenty-trainers-push.md b/.changeset/plenty-trainers-push.md new file mode 100644 index 0000000..3d46dd1 --- /dev/null +++ b/.changeset/plenty-trainers-push.md @@ -0,0 +1,5 @@ +--- +'@blizzard-api/wow': minor +--- + +Add support for Character Profile APIs diff --git a/packages/wow/src/character-profile/character-profile.test.ts b/packages/wow/src/character-profile/character-profile.test.ts new file mode 100644 index 0000000..4568b8f --- /dev/null +++ b/packages/wow/src/character-profile/character-profile.test.ts @@ -0,0 +1,34 @@ +import { describe, expect, it } from 'vitest'; +import { characterProfileStatus, characterProfileSummary } from './character-profile'; + +describe('characterProfileSummary', () => { + it('should return the correct protected resource object', () => { + const realmSlug = 'example-realm'; + const characterName = 'example-character'; + const token = 'example-token'; + + const result = characterProfileSummary(realmSlug, characterName, token); + + expect(result).toEqual({ + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName.toLowerCase()}`, + token, + }); + }); +}); + +describe('characterProfileStatus', () => { + it('should return the correct protected resource object', () => { + const realmSlug = 'example-realm'; + const characterName = 'example-character'; + const token = 'example-token'; + + const result = characterProfileStatus(realmSlug, characterName, token); + + expect(result).toEqual({ + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName.toLowerCase()}/status`, + token, + }); + }); +}); diff --git a/packages/wow/src/character-profile/character-profile.ts b/packages/wow/src/character-profile/character-profile.ts new file mode 100644 index 0000000..9bc8d1c --- /dev/null +++ b/packages/wow/src/character-profile/character-profile.ts @@ -0,0 +1,26 @@ +import type { ProtectedResource } from '@blizzard-api/core'; +import type { CharacterProfileStatusResponse, CharacterProfileSummaryResponse } from './types'; + +export function characterProfileSummary( + realmSlug: string, + characterName: string, + token: string, +): ProtectedResource { + return { + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName.toLowerCase()}`, + token, + }; +} + +export function characterProfileStatus( + realmSlug: string, + characterName: string, + token: string, +): ProtectedResource { + return { + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName.toLowerCase()}/status`, + token, + }; +} diff --git a/packages/wow/src/character-profile/types.ts b/packages/wow/src/character-profile/types.ts new file mode 100644 index 0000000..3b8c371 --- /dev/null +++ b/packages/wow/src/character-profile/types.ts @@ -0,0 +1,58 @@ +import type { Faction, Href, NameIdKey, ResponseBase } from '../base'; + +export interface CharacterProfileSummaryResponse extends ResponseBase { + achievement_points: number; + achievements: Href; + achievements_statistics: Href; + active_spec: NameIdKey; + active_title: { display_string: string } & NameIdKey; + appearance: Href; + average_item_level: number; + character_class: NameIdKey; + collections: Href; + covenant_progress: CovenantProgress; + encounters: Href; + equipment: Href; + equipped_item_level: number; + experience: number; + faction: Faction; + gender: Faction; + guild: Guild; + hunter_pets: Href; + id: number; + last_login_timestamp: number; + level: number; + media: Href; + mythic_keystone_profile: Href; + name: string; + name_search: string; + professions: Href; + pvp_summary: Href; + quests: Href; + race: NameIdKey; + realm: Realm; + reputations: Href; + specializations: Href; + statistics: Href; + titles: Href; +} + +interface CovenantProgress { + chosen_covenant: NameIdKey; + renown_level: number; + soulbinds: Href; +} + +interface Realm extends NameIdKey { + slug: string; +} + +interface Guild extends NameIdKey { + faction: Faction; + realm: Realm; +} + +export interface CharacterProfileStatusResponse extends ResponseBase { + id: number; + is_valid: boolean; +} diff --git a/packages/wow/src/index.ts b/packages/wow/src/index.ts index 94eaef7..c43366d 100644 --- a/packages/wow/src/index.ts +++ b/packages/wow/src/index.ts @@ -48,6 +48,7 @@ import { characterMythicKeystoneSeasonDetails, } from './character-mythic-keystone-profile/character-mythic-keystone-profile'; import { characterProfessionsSummary } from './character-professions/character-professions'; +import { characterProfileStatus, characterProfileSummary } from './character-profile/character-profile'; import { connectedRealm, connectedRealmIndex, connectedRealmSearch } from './connected-realm/connected-realm'; import { conduit, @@ -230,6 +231,9 @@ export const wow = { characterMythicKeystoneSeasonDetails, //Character Professions characterProfessionsSummary, + //Character Profile + characterProfileStatus, + characterProfileSummary, //Connected Realm connectedRealm, connectedRealmIndex, @@ -432,6 +436,9 @@ export * from './character-mythic-keystone-profile/types'; //Character Professions export * from './character-professions/character-professions'; export * from './character-professions/types'; +//Character Profile +export * from './character-profile/character-profile'; +export * from './character-profile/types'; //Connected Realm export * from './connected-realm/connected-realm'; export * from './connected-realm/types';