From 455d7662dffc17802c2db3714986da9826351792 Mon Sep 17 00:00:00 2001 From: Putro <29204244+Pewtro@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:01:11 +0200 Subject: [PATCH] [WoW] Add support for Character Mythic Keystone Profile APIs --- .changeset/light-snakes-try.md | 5 ++ .../character-mythic-keystone-profile.test.ts | 36 +++++++++++++ .../character-mythic-keystone-profile.ts | 30 +++++++++++ .../types.ts | 51 +++++++++++++++++++ packages/wow/src/index.ts | 10 ++++ 5 files changed, 132 insertions(+) create mode 100644 .changeset/light-snakes-try.md create mode 100644 packages/wow/src/character-mythic-keystone-profile/character-mythic-keystone-profile.test.ts create mode 100644 packages/wow/src/character-mythic-keystone-profile/character-mythic-keystone-profile.ts create mode 100644 packages/wow/src/character-mythic-keystone-profile/types.ts diff --git a/.changeset/light-snakes-try.md b/.changeset/light-snakes-try.md new file mode 100644 index 0000000..dd72fd3 --- /dev/null +++ b/.changeset/light-snakes-try.md @@ -0,0 +1,5 @@ +--- +'@blizzard-api/wow': minor +--- + +Add support for Character Mythic Keystone Profile APIs diff --git a/packages/wow/src/character-mythic-keystone-profile/character-mythic-keystone-profile.test.ts b/packages/wow/src/character-mythic-keystone-profile/character-mythic-keystone-profile.test.ts new file mode 100644 index 0000000..3a56b31 --- /dev/null +++ b/packages/wow/src/character-mythic-keystone-profile/character-mythic-keystone-profile.test.ts @@ -0,0 +1,36 @@ +import { describe, expect, it } from 'vitest'; +import { + characterMythicKeystoneProfileIndex, + characterMythicKeystoneSeasonDetails, +} from './character-mythic-keystone-profile'; + +describe('Character Mythic Keystone Profile', () => { + it('should return the correct ProtectedResource object for characterMythicKeystoneProfileIndex', () => { + const realmSlug = 'realm'; + const characterName = 'character'; + const token = 'token'; + + const result = characterMythicKeystoneProfileIndex(realmSlug, characterName, token); + + expect(result).toEqual({ + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName}/mythic-keystone-profile`, + token, + }); + }); + + it('should return the correct ProtectedResource object for characterMythicKeystoneSeasonDetails', () => { + const realmSlug = 'realm'; + const characterName = 'character'; + const seasonId = 123; + const token = 'token'; + + const result = characterMythicKeystoneSeasonDetails(realmSlug, characterName, seasonId, token); + + expect(result).toEqual({ + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName}/mythic-keystone-profile/season/${seasonId}`, + token, + }); + }); +}); diff --git a/packages/wow/src/character-mythic-keystone-profile/character-mythic-keystone-profile.ts b/packages/wow/src/character-mythic-keystone-profile/character-mythic-keystone-profile.ts new file mode 100644 index 0000000..478770b --- /dev/null +++ b/packages/wow/src/character-mythic-keystone-profile/character-mythic-keystone-profile.ts @@ -0,0 +1,30 @@ +import type { ProtectedResource } from '@blizzard-api/core'; +import type { + CharacterMythicKeystoneProfileIndexResponse, + CharacterMythicKeystoneSeasonDetailsResponse, +} from './types'; + +export function characterMythicKeystoneProfileIndex( + realmSlug: string, + characterName: string, + token: string, +): ProtectedResource { + return { + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName}/mythic-keystone-profile`, + token, + }; +} + +export function characterMythicKeystoneSeasonDetails( + realmSlug: string, + characterName: string, + seasonId: number, + token: string, +): ProtectedResource { + return { + namespace: 'profile', + path: `/profile/wow/character/${realmSlug}/${characterName}/mythic-keystone-profile/season/${seasonId}`, + token, + }; +} diff --git a/packages/wow/src/character-mythic-keystone-profile/types.ts b/packages/wow/src/character-mythic-keystone-profile/types.ts new file mode 100644 index 0000000..779cfd5 --- /dev/null +++ b/packages/wow/src/character-mythic-keystone-profile/types.ts @@ -0,0 +1,51 @@ +import type { Color, Href, KeyBase, NameId, NameIdKey } from '../base'; + +export interface CharacterMythicKeystoneProfileIndexResponse { + _links: { self: Href }; + character: Character; + current_period: CurrentPeriod; + seasons: Array<{ id: number } & KeyBase>; +} + +interface Realm extends NameIdKey { + slug: string; +} + +interface Character extends NameIdKey { + realm: Realm; +} + +interface CurrentPeriod { + period: { id: number } & KeyBase; +} + +export interface CharacterMythicKeystoneSeasonDetailsResponse { + _links: { self: Href }; + best_runs: Array; + character: NameIdKey; + mythic_rating: MythicRating; + season: { id: number } & KeyBase; +} + +interface BestRun { + completed_timestamp: number; + dungeon: NameIdKey; + duration: number; + is_completed_within_time: boolean; + keystone_affixes: Array; + keystone_level: number; + members: Array; + mythic_rating: MythicRating; +} + +interface Member { + character: { realm: Realm } & NameId; + equipped_item_level: number; + race: NameIdKey; + specialization: NameIdKey; +} + +interface MythicRating { + color: Color; + rating: number; +} diff --git a/packages/wow/src/index.ts b/packages/wow/src/index.ts index bcd95ac..61806d5 100644 --- a/packages/wow/src/index.ts +++ b/packages/wow/src/index.ts @@ -43,6 +43,10 @@ import { import { characterEquipmentSummary } from './character-equipment/character-equipment'; import { characterHunterPetsSummary } from './character-hunter-pets/character-hunter-pets'; import { characterMediaSummary } from './character-media/character-media'; +import { + characterMythicKeystoneProfileIndex, + characterMythicKeystoneSeasonDetails, +} from './character-mythic-keystone-profile/character-mythic-keystone-profile'; import { connectedRealm, connectedRealmIndex, connectedRealmSearch } from './connected-realm/connected-realm'; import { conduit, @@ -220,6 +224,9 @@ export const wow = { characterHunterPetsSummary, //Character Media characterMediaSummary, + //Character Mythic Keystone Profile + characterMythicKeystoneProfileIndex, + characterMythicKeystoneSeasonDetails, //Connected Realm connectedRealm, connectedRealmIndex, @@ -416,6 +423,9 @@ export * from './character-hunter-pets/types'; //Character Media export * from './character-media/character-media'; export * from './character-media/types'; +//Character Mythic Keystone Profile +export * from './character-mythic-keystone-profile/character-mythic-keystone-profile'; +export * from './character-mythic-keystone-profile/types'; //Connected Realm export * from './connected-realm/connected-realm'; export * from './connected-realm/types';