Skip to content

Commit

Permalink
[WoW] Add support for Character Titles APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pewtro committed Aug 11, 2024
1 parent e102c3e commit e6261b7
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-poems-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blizzard-api/wow': minor
---

Add support for Character Titles APIs
20 changes: 20 additions & 0 deletions packages/wow/src/character-titles/character-titles.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
14 changes: 14 additions & 0 deletions packages/wow/src/character-titles/character-titles.ts
Original file line number Diff line number Diff line change
@@ -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<CharacterTitlesSummaryResponse> {
return {
namespace: 'profile',
path: `/profile/wow/character/${realmSlug}/${characterName}/titles`,
token,
};
}
15 changes: 15 additions & 0 deletions packages/wow/src/character-titles/types.ts
Original file line number Diff line number Diff line change
@@ -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<NameIdKey>;
}

interface Realm extends NameIdKey {
slug: string;
}

interface Character extends NameIdKey {
realm: Realm;
}
6 changes: 6 additions & 0 deletions packages/wow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -253,6 +254,8 @@ export const wow = {
characterSpecializationsSummary,
//Character Statistics
characterStatisticsSummary,
//Character Titles
characterTitlesSummary,
//Connected Realm
connectedRealm,
connectedRealmIndex,
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit e6261b7

Please sign in to comment.