Skip to content

Commit

Permalink
last of the wow profile endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinta365 committed Sep 23, 2023
1 parent 840099d commit fd74dcb
Show file tree
Hide file tree
Showing 15 changed files with 841 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ Built for Deno 🦕

## WORK IN PROGRESS

Let me know if you want certain APIs to be prioritized.

### APIs implemented

| APIs | Status | Note |
| --------------------------------------------- | ------ | ---- |
| **World of Warcraft:** Game Data APIs || |
| **World of Warcraft:** Profile APIs | | |
| **World of Warcraft:** Profile APIs | | |
| | | |
| **World of Warcraft Classic:** Game Data APIs | | |
| | | |
Expand Down
5 changes: 4 additions & 1 deletion src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface TypeName {
}

export interface Character {
key: {
key?: {
href: string;
};
name: string;
Expand All @@ -81,4 +81,7 @@ export interface Character {
id: number;
slug: string;
};
level?: number;
playable_class?: KeyId;
playable_race?: KeyId;
}
25 changes: 25 additions & 0 deletions src/wow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,28 @@ export { characterEquipments } from "./profile/character_equipment.ts";
export { characterHunterPets } from "./profile/character_hunter_pets.ts";

export { characterMedia } from "./profile/character_media.ts";

export {
characterMythicKeystoneProfile,
characterMythicKeystoneSeasonDetails,
} from "./profile/character_mythic_keystone_profile.ts";

export { characterProfessions } from "./profile/character_professions.ts";

export { characterProfile, characterProfileStatus } from "./profile/character_profile.ts";

export { characterPvpBracketStatistics, characterPvpSummary } from "./profile/character_pvp.ts";

export { characterCompletedQuests, characterQuests } from "./profile/character_quests.ts";

export { characterReputations } from "./profile/character_reputations.ts";

export { characterSoulbinds } from "./profile/character_soulbinds.ts";

export { characterSpecializations } from "./profile/character_specializations.ts";

export { characterStatistics } from "./profile/character_statistics.ts";

export { characterTitles } from "./profile/character_titles.ts";

export { guild, guildAchievements, guildActivity, guildRoster } from "./profile/guild.ts";
1 change: 1 addition & 0 deletions src/wow/profile/character_media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface CharacterMedia extends LinkSelfHref {
character: Character;
assets: Asset[];
}

/**
* Returns a summary of the media assets available for a character (such as an avatar render).
*
Expand Down
82 changes: 82 additions & 0 deletions src/wow/profile/character_mythic_keystone_profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { Character, KeyId, KeyNameId, LinkSelfHref, request } from "../../shared/index.ts";

interface MythicRating {
color: {
r: number;
g: number;
b: number;
a: number;
};
rating: number;
}

interface CharacterMythicKeystoneProfile extends LinkSelfHref {
current_period: {
period: KeyId;
};
seasons: KeyId[];
character: Character;
current_mythic_rating: MythicRating;
}

interface CharacterMythicKeystoneSeasonDetails extends LinkSelfHref {
season: KeyId;
best_runs: {
completed_timestamp: number;
duration: number;
keystone_level: number;
keystone_affixes: KeyNameId[];
members: {
character: Character;
specialization: KeyNameId;
race: KeyNameId;
equipped_item_level: number;
}[];
dungeon: KeyNameId;
is_completed_within_time: boolean;
mythic_rating: MythicRating;
map_rating: MythicRating;
}[];
character: Character;
mythic_rating: MythicRating;
}

/**
* Returns the Mythic Keystone profile index for a character.
*
* @param realmSlug - The slug of the realm.
* @param characterName - The lowercase name of the character.
* @returns A promise that resolves to an object representing a Mythic Keystone profile.
*/
export async function characterMythicKeystoneProfile(
realmSlug: string,
characterName: string,
): Promise<CharacterMythicKeystoneProfile> {
return await request({
method: "GET",
url: `/profile/wow/character/${realmSlug}/${characterName}/mythic-keystone-profile`,
namespace: "profile",
});
}

/**
* Returns the Mythic Keystone season details for a character.
*
* Returns a 404 Not Found for characters that have not yet completed a Mythic Keystone dungeon for the specified season.
*
* @param realmSlug - The slug of the realm.
* @param characterName - The lowercase name of the character.
* @param seasonId - The lowercase name of the character.
* @returns A promise that resolves to an object representing a Mythic Keystone season details.
*/
export async function characterMythicKeystoneSeasonDetails(
realmSlug: string,
characterName: string,
seasonId: number,
): Promise<CharacterMythicKeystoneSeasonDetails> {
return await request({
method: "GET",
url: `/profile/wow/character/${realmSlug}/${characterName}/mythic-keystone-profile/season/${seasonId}`,
namespace: "profile",
});
}
39 changes: 39 additions & 0 deletions src/wow/profile/character_professions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Character, KeyNameId, LinkSelfHref, NameId, request } from "../../shared/index.ts";

interface Tier {
skill_points: number;
max_skill_points: number;
tier: NameId;
known_recipes: KeyNameId[];
}

interface Profession {
profession: KeyNameId;
skill_points?: number;
max_skill_points?: number;
tiers?: Tier[];
}

interface CharacterProfessions extends LinkSelfHref {
character: Character;
primaries: Profession[];
secondaries: Profession[];
}

/**
* Returns a summary of professions for a character.
*
* @param realmSlug - The slug of the realm.
* @param characterName - The lowercase name of the character.
* @returns A promise that resolves to an object representing a summary of professions for a character.
*/
export async function characterProfessions(
realmSlug: string,
characterName: string,
): Promise<CharacterProfessions> {
return await request({
method: "GET",
url: `/profile/wow/character/${realmSlug}/${characterName}/professions`,
namespace: "profile",
});
}
104 changes: 104 additions & 0 deletions src/wow/profile/character_profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { KeyNameId, LinkSelfHref, LocalizedString, request, TypeName } from "../../shared/index.ts";

interface Href {
href: string;
}

interface Realm extends KeyNameId {
slug: string;
}

interface CharacterProfile extends LinkSelfHref {
id: number;
name: LocalizedString;
gender: TypeName;
faction: TypeName;
race: KeyNameId;
character_class: KeyNameId;
active_spec: KeyNameId;
realm: Realm;
guild: {
key: Href;
name: LocalizedString;
id: number;
realm: Realm;
faction: TypeName;
};
level: number;
experience: number;
achievement_points: number;
achievements: Href;
titles: Href;
pvp_summary: Href;
encounters: Href;
media: Href;
last_login_timestamp: number;
average_item_level: number;
equipped_item_level: number;
specializations: Href;
statistics: Href;
mythic_keystone_profile: Href;
equipment: Href;
appearance: Href;
collections: Href;
reputations: Href;
quests: Href;
achievements_statistics: Href;
professions: Href;
covenant_progress: {
chosen_covenant: KeyNameId;
renown_level: number;
soulbinds: Href;
};
}

interface CharacterProfileStatus extends LinkSelfHref {
id: number;
is_valid: boolean;
}
/**
* Returns a profile summary for a character.
*
* @param realmSlug - The slug of the realm.
* @param characterName - The lowercase name of the character.
* @returns A promise that resolves to an object representing a profile summary.
*/
export async function characterProfile(
realmSlug: string,
characterName: string,
): Promise<CharacterProfile> {
return await request({
method: "GET",
url: `/profile/wow/character/${realmSlug}/${characterName}`,
namespace: "profile",
});
}

/**
* Returns the status and a unique ID for a character. A client should delete information about a character from their application if any of the following conditions occur:
*
* an HTTP 404 Not Found error is returned
* the is_valid value is false
* the returned character ID doesn't match the previously recorded value for the character
*
* The following example illustrates how to use this endpoint:
*
* A client requests and stores information about a character, including its unique character ID and the timestamp of the request.
* After 30 days, the client makes a request to the status endpoint to verify if the character information is still valid.
* If character cannot be found, is not valid, or the characters IDs do not match, the client removes the information from their application.
* If the character is valid and the character IDs match, the client retains the data for another 30 days.
*
* @param realmSlug - The slug of the realm.
* @param characterName - The lowercase name of the character.
* @returns A promise that resolves to an object representing a profile summary status.
*/
export async function characterProfileStatus(
realmSlug: string,
characterName: string,
): Promise<CharacterProfileStatus> {
return await request({
method: "GET",
url: `/profile/wow/character/${realmSlug}/${characterName}/status`,
namespace: "profile",
});
}
75 changes: 75 additions & 0 deletions src/wow/profile/character_pvp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Character, KeyId, LinkSelfHref, LocalizedString, request, TypeName } from "../../shared/index.ts";

interface MatchStatistic {
played: number;
won: number;
lost: number;
}

interface CharacterPvpBracketStatistics extends LinkSelfHref {
character: Character;
faction: TypeName;
bracket: {
id: number;
type: string;
};
rating: number;
season: KeyId;
tier: KeyId;
season_match_statistics: MatchStatistic;
weekly_match_statistics: MatchStatistic;
}

interface CharacterPvpSummary extends LinkSelfHref {
brackets: {
href: string;
}[];
honor_level: number;
pvp_map_statistics: {
world_map: {
name: LocalizedString;
id: number;
};
match_statistics: MatchStatistic;
}[];
honorable_kills: number;
character: Character;
}

/**
* Returns the PvP bracket statistics for a character.
*
* @param realmSlug - The slug of the realm.
* @param characterName - The lowercase name of the character.
* @param pvpBracket - The PvP bracket type.
* @returns A promise that resolves to an object representing the PvP bracket statistics for a character.
*/
export async function characterPvpBracketStatistics(
realmSlug: string,
characterName: string,
pvpBracket: string,
): Promise<CharacterPvpBracketStatistics> {
return await request({
method: "GET",
url: `/profile/wow/character/${realmSlug}/${characterName}/pvp-bracket/${pvpBracket}`,
namespace: "profile",
});
}

/**
* Returns a PvP summary for a character.
*
* @param realmSlug - The slug of the realm.
* @param characterName - The lowercase name of the character.
* @returns A promise that resolves to an object representing the PvP summary for a character.
*/
export async function characterPvpSummary(
realmSlug: string,
characterName: string,
): Promise<CharacterPvpSummary> {
return await request({
method: "GET",
url: `/profile/wow/character/${realmSlug}/${characterName}/pvp-summary`,
namespace: "profile",
});
}
Loading

0 comments on commit fd74dcb

Please sign in to comment.