-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WoW] Add support for Character Encounters APIs
- Loading branch information
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@blizzard-api/wow': minor | ||
--- | ||
|
||
Add support for Character Encounters APIs |
45 changes: 45 additions & 0 deletions
45
packages/wow/src/character-encounters/character-encounters.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { characterDungeons, characterEncountersSummary, characterRaids } from './character-encounters'; | ||
|
||
describe('Character Encounters', () => { | ||
it('should return the correct ProtectedResource object for character encounters', () => { | ||
const realmSlug = 'realm'; | ||
const characterName = 'character'; | ||
const token = 'token'; | ||
|
||
const result = characterEncountersSummary(realmSlug, characterName, token); | ||
|
||
expect(result).toEqual({ | ||
namespace: 'profile', | ||
path: 'profile/wow/character/realm/character/encounters', | ||
token, | ||
}); | ||
}); | ||
it('should return the correct ProtectedResource object for character dungeons', () => { | ||
const realmSlug = 'realm'; | ||
const characterName = 'character'; | ||
const token = 'token'; | ||
|
||
const result = characterDungeons(realmSlug, characterName, token); | ||
|
||
expect(result).toEqual({ | ||
namespace: 'profile', | ||
path: 'profile/wow/character/realm/character/encounters/dungeons', | ||
token, | ||
}); | ||
}); | ||
|
||
it('should return the correct ProtectedResource object for character raids', () => { | ||
const realmSlug = 'realm'; | ||
const characterName = 'character'; | ||
const token = 'token'; | ||
|
||
const result = characterRaids(realmSlug, characterName, token); | ||
|
||
expect(result).toEqual({ | ||
namespace: 'profile', | ||
path: 'profile/wow/character/realm/character/encounters/raids', | ||
token, | ||
}); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
packages/wow/src/character-encounters/character-encounters.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { ProtectedResource } from '@blizzard-api/core'; | ||
import type { CharacterDungeonsResponse, CharacterEncountersSummaryResponse, CharacterRaidsResponse } from './types'; | ||
|
||
const bathPase = 'profile/wow/character'; | ||
|
||
export function characterEncountersSummary( | ||
realmSlug: string, | ||
characterName: string, | ||
token: string, | ||
): ProtectedResource<CharacterEncountersSummaryResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${bathPase}/${realmSlug}/${characterName.toLowerCase()}/encounters`, | ||
token, | ||
}; | ||
} | ||
|
||
export function characterDungeons( | ||
realmSlug: string, | ||
characterName: string, | ||
token: string, | ||
): ProtectedResource<CharacterDungeonsResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${bathPase}/${realmSlug}/${characterName.toLowerCase()}/encounters/dungeons`, | ||
token, | ||
}; | ||
} | ||
|
||
export function characterRaids( | ||
realmSlug: string, | ||
characterName: string, | ||
token: string, | ||
): ProtectedResource<CharacterRaidsResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${bathPase}/${realmSlug}/${characterName.toLowerCase()}/encounters/raids`, | ||
token, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import type { Href, NameIdKey } from '../base'; | ||
|
||
export interface CharacterEncountersSummaryResponse { | ||
_links: { self: Href }; | ||
character: Character; | ||
dungeons: Href; | ||
raids: Href; | ||
} | ||
|
||
interface Realm extends NameIdKey { | ||
slug: string; | ||
} | ||
|
||
interface Character extends NameIdKey { | ||
realm: Realm; | ||
} | ||
|
||
export interface CharacterDungeonsResponse { | ||
_links: { self: Href }; | ||
expansions: Array<Expansion<DungeonMode>>; | ||
} | ||
|
||
interface Expansion<T> { | ||
expansion: NameIdKey; | ||
instances: Array<Instance<T>>; | ||
} | ||
|
||
interface Instance<T> { | ||
instance: NameIdKey; | ||
modes: Array<T>; | ||
} | ||
|
||
interface DungeonMode { | ||
difficulty: DungeonDifficulties; | ||
progress: Progress; | ||
status: Status; | ||
} | ||
|
||
interface Status { | ||
name: 'Complete' | 'In Progress'; | ||
type: 'COMPLETE' | 'IN_PROGRESS'; | ||
} | ||
|
||
interface DungeonDifficulties { | ||
name: 'Heroic' | 'Mythic' | 'Mythic+ Dungeons' | 'Normal'; | ||
type: 'HEROIC' | 'MYTHIC' | 'MYTHIC_KEYSTONE' | 'NORMAL'; | ||
} | ||
|
||
interface Progress { | ||
completed_count: number; | ||
encounters: Array<Encounter>; | ||
total_count: number; | ||
} | ||
|
||
interface Encounter { | ||
completed_count: number; | ||
encounter: NameIdKey; | ||
last_kill_timestamp: number; | ||
} | ||
|
||
export interface CharacterRaidsResponse { | ||
_links: { self: Href }; | ||
character: Character; | ||
expansions: Array<Expansion<RaidMode>>; | ||
} | ||
|
||
interface RaidMode { | ||
difficulty: RaidDifficulties; | ||
progress: Progress; | ||
status: Status; | ||
} | ||
|
||
interface RaidDifficulties { | ||
name: | ||
| '10 Player (Heroic)' | ||
| '10 Player' | ||
| '25 Player (Heroic)' | ||
| '25 Player' | ||
| 'Heroic' | ||
| 'Mythic' | ||
| 'Normal' | ||
| 'Raid Finder'; | ||
type: | ||
| 'HEROIC' | ||
| 'LEGACY_10_MAN' | ||
| 'LEGACY_10_MAN_HEROIC' | ||
| 'LEGACY_25_MAN' | ||
| 'LEGACY_25_MAN_HEROIC' | ||
| 'LFR' | ||
| 'MYTHIC' | ||
| 'NORMAL'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters