-
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 Account Profile API responses
- Loading branch information
Showing
11 changed files
with
373 additions
and
12 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 Account Profile API responses. |
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
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,73 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { | ||
accountCollectionsIndex, | ||
accountHeirloomsCollectionSummary, | ||
accountMountsCollectionSummary, | ||
accountPetsCollectionSummary, | ||
accountProfileSummary, | ||
accountToysCollectionSummary, | ||
accountTransmogsCollectionSummary, | ||
protectedCharacterProfileSummary, | ||
} from './account-profile'; | ||
|
||
describe('Account Profile', () => { | ||
const token = 'your_token_here'; | ||
const realmId = 1; | ||
const characterId = 2; | ||
|
||
it('should return account profile summary', () => { | ||
const result = accountProfileSummary(token); | ||
expect(result.namespace).toBe('profile'); | ||
expect(result.path).toBe('/profile/user/wow'); | ||
expect(result.token).toBe(token); | ||
}); | ||
|
||
it('should return protected character profile summary', () => { | ||
const result = protectedCharacterProfileSummary(realmId, characterId, token); | ||
expect(result.namespace).toBe('profile'); | ||
expect(result.path).toBe('/profile/user/wow/protected-character/1-2'); | ||
expect(result.token).toBe(token); | ||
}); | ||
|
||
it('should return account collections index', () => { | ||
const result = accountCollectionsIndex(token); | ||
expect(result.namespace).toBe('profile'); | ||
expect(result.path).toBe('/profile/user/wow/collections'); | ||
expect(result.token).toBe(token); | ||
}); | ||
|
||
it('should return account heirlooms collection summary', () => { | ||
const result = accountHeirloomsCollectionSummary(token); | ||
expect(result.namespace).toBe('profile'); | ||
expect(result.path).toBe('/profile/user/wow/collections/heirlooms'); | ||
expect(result.token).toBe(token); | ||
}); | ||
|
||
it('should return account mounts collection summary', () => { | ||
const result = accountMountsCollectionSummary(token); | ||
expect(result.namespace).toBe('profile'); | ||
expect(result.path).toBe('/profile/user/wow/collections/mounts'); | ||
expect(result.token).toBe(token); | ||
}); | ||
|
||
it('should return account pets collection summary', () => { | ||
const result = accountPetsCollectionSummary(token); | ||
expect(result.namespace).toBe('profile'); | ||
expect(result.path).toBe('/profile/user/wow/collections/pets'); | ||
expect(result.token).toBe(token); | ||
}); | ||
|
||
it('should return account toys collection summary', () => { | ||
const result = accountToysCollectionSummary(token); | ||
expect(result.namespace).toBe('profile'); | ||
expect(result.path).toBe('/profile/user/wow/collections/toys'); | ||
expect(result.token).toBe(token); | ||
}); | ||
|
||
it('should return account transmogs collection summary', () => { | ||
const result = accountTransmogsCollectionSummary(token); | ||
expect(result.namespace).toBe('profile'); | ||
expect(result.path).toBe('/profile/user/wow/collections/transmogs'); | ||
expect(result.token).toBe(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,87 @@ | ||
import type { ProtectedResource } from '@blizzard-api/core'; | ||
import type { | ||
AccountCollectionsIndexResponse, | ||
AccountHeirloomsCollectionSummaryResponse, | ||
AccountMountsCollectionSummaryResponse, | ||
AccountPetsCollectionSummaryResponse, | ||
AccountProfileSummaryResponse, | ||
AccountToysCollectionSummaryResponse, | ||
AccountTransmogsCollectionSummaryResponse, | ||
ProtectedCharacterProfileSummaryResponse, | ||
} from './types'; | ||
|
||
const accountProfileBase = '/profile/user/wow'; | ||
|
||
export function accountProfileSummary(token: string): ProtectedResource<AccountProfileSummaryResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${accountProfileBase}`, | ||
token, | ||
}; | ||
} | ||
|
||
export function protectedCharacterProfileSummary( | ||
realmId: number, | ||
characterId: number, | ||
token: string, | ||
): ProtectedResource<ProtectedCharacterProfileSummaryResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${accountProfileBase}/protected-character/${realmId}-${characterId}`, | ||
token, | ||
}; | ||
} | ||
|
||
export function accountCollectionsIndex(token: string): ProtectedResource<AccountCollectionsIndexResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${accountProfileBase}/collections`, | ||
token, | ||
}; | ||
} | ||
|
||
export function accountHeirloomsCollectionSummary( | ||
token: string, | ||
): ProtectedResource<AccountHeirloomsCollectionSummaryResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${accountProfileBase}/collections/heirlooms`, | ||
token, | ||
}; | ||
} | ||
|
||
export function accountMountsCollectionSummary( | ||
token: string, | ||
): ProtectedResource<AccountMountsCollectionSummaryResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${accountProfileBase}/collections/mounts`, | ||
token, | ||
}; | ||
} | ||
|
||
export function accountPetsCollectionSummary(token: string): ProtectedResource<AccountPetsCollectionSummaryResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${accountProfileBase}/collections/pets`, | ||
token, | ||
}; | ||
} | ||
|
||
export function accountToysCollectionSummary(token: string): ProtectedResource<AccountToysCollectionSummaryResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${accountProfileBase}/collections/toys`, | ||
token, | ||
}; | ||
} | ||
|
||
export function accountTransmogsCollectionSummary( | ||
token: string, | ||
): ProtectedResource<AccountTransmogsCollectionSummaryResponse> { | ||
return { | ||
namespace: 'profile', | ||
path: `${accountProfileBase}/collections/transmogs`, | ||
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,158 @@ | ||
import type { Faction, Gender, KeyBase, NameId, NameIdKey } from '../base'; | ||
|
||
export interface AccountProfileSummaryResponse { | ||
_links: Links; | ||
collections: Href; | ||
id: number; | ||
wow_accounts?: Array<WowAccount>; | ||
} | ||
|
||
interface Links { | ||
profile: Href; | ||
self: Href; | ||
user: Href; | ||
} | ||
|
||
interface Href { | ||
href: string; | ||
} | ||
|
||
interface WowAccount { | ||
characters: Array<Character>; | ||
id: number; | ||
} | ||
|
||
interface Realm extends NameIdKey { | ||
slug: string; | ||
} | ||
|
||
interface Character { | ||
character: Href; | ||
faction: Faction; | ||
gender: Gender; | ||
id: number; | ||
level: number; | ||
name: string; | ||
playable_class: NameIdKey; | ||
playable_race: NameIdKey; | ||
protected_character: Href; | ||
realm: Realm; | ||
} | ||
|
||
export interface ProtectedCharacterProfileSummaryResponse { | ||
_links: Links; | ||
bind_position: Position; | ||
character: NameIdKey & Realm; | ||
id: number; | ||
money: number; | ||
name: string; | ||
position: Position; | ||
protected_stats: ProtectedStats; | ||
wow_account: number; | ||
} | ||
|
||
interface Position { | ||
facing: number; | ||
map: NameId; | ||
x: number; | ||
y: number; | ||
z: number; | ||
zone: NameId; | ||
} | ||
|
||
interface ProtectedStats { | ||
level_gold_gained: number; | ||
level_gold_lost: number; | ||
level_item_value_gained: number; | ||
level_number_deaths: number; | ||
total_gold_gained: number; | ||
total_gold_lost: number; | ||
total_item_value_gained: number; | ||
total_number_deaths: number; | ||
} | ||
|
||
export interface AccountCollectionsIndexResponse { | ||
_links: Links; | ||
heirlooms: Href; | ||
mounts: Href; | ||
pets: Href; | ||
toys: Href; | ||
transmogs: Href; | ||
} | ||
|
||
export interface AccountHeirloomsCollectionSummaryResponse { | ||
_links: Links; | ||
heirlooms: Array<Heirloom>; | ||
} | ||
|
||
interface Heirloom { | ||
heirloom: NameIdKey; | ||
upgrade: { level: number }; | ||
} | ||
|
||
export interface AccountMountsCollectionSummaryResponse { | ||
_links: Links; | ||
mounts: Array<Mount>; | ||
} | ||
|
||
interface Mount { | ||
is_favorite?: boolean; | ||
mount: NameIdKey; | ||
} | ||
|
||
export interface AccountPetsCollectionSummaryResponse { | ||
_links: Links; | ||
pets: Array<Pet>; | ||
unlocked_battle_pet_slots: number; | ||
} | ||
|
||
interface Pet { | ||
active_slot?: number; | ||
creature_display?: { id: number } & KeyBase; | ||
id: number; | ||
is_active?: boolean; | ||
is_favorite?: boolean; | ||
level: number; | ||
name?: string; | ||
quality: Quality; | ||
species: NameIdKey; | ||
stats: Stats; | ||
} | ||
|
||
interface Quality { | ||
name: 'Common' | 'Poor' | 'Rare' | 'Uncommon'; | ||
type: 'COMMON' | 'POOR' | 'RARE' | 'UNCOMMON'; | ||
} | ||
|
||
interface Stats { | ||
breed_id: number; | ||
health: number; | ||
power: number; | ||
speed: number; | ||
} | ||
|
||
export interface AccountToysCollectionSummaryResponse { | ||
_links: Links; | ||
toys: Array<Toy>; | ||
} | ||
|
||
interface Toy { | ||
is_favorite?: boolean; | ||
toy: NameIdKey; | ||
} | ||
|
||
export interface AccountTransmogsCollectionSummaryResponse { | ||
_links: Links; | ||
appearance_sets: Array<NameIdKey>; | ||
slots: Array<Slot>; | ||
} | ||
|
||
interface Slot { | ||
appearances: Array<{ id: number } & KeyBase>; | ||
slot: Slot; | ||
} | ||
|
||
interface Slot { | ||
name: string; | ||
type: string; | ||
} |
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
Oops, something went wrong.