-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
486 additions
and
13 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
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
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,132 @@ | ||
/** | ||
* This module provides interfaces and API function definitions for fetching World of Warcraft achievement data using the Blizzard API. | ||
* | ||
* @author Pinta <https://github.com/Pinta365> | ||
*/ | ||
|
||
import { KeyId, KeyNameId, LinkSelfHref, LocalizedString, request } from "../shared/index.ts"; | ||
|
||
interface AchievementCategories extends LinkSelfHref { | ||
categories: KeyNameId[]; | ||
} | ||
|
||
interface AggregatesByFaction { | ||
alliance: { | ||
quantity: number; | ||
points: number; | ||
}; | ||
horde: { | ||
quantity: number; | ||
points: number; | ||
}; | ||
} | ||
|
||
interface AchievementCategory extends LinkSelfHref { | ||
id: number; | ||
name: LocalizedString; | ||
achievements: KeyNameId[]; | ||
parent_category: KeyNameId; | ||
is_guild_category: boolean; | ||
aggregates_by_faction: AggregatesByFaction; | ||
display_order: number; | ||
} | ||
|
||
interface Achievements extends LinkSelfHref { | ||
achievements: KeyNameId[]; | ||
} | ||
|
||
interface Achievement extends LinkSelfHref { | ||
id: number; | ||
category: KeyNameId; | ||
name: LocalizedString; | ||
description: LocalizedString; | ||
points: number; | ||
is_account_wide: boolean; | ||
criteria: { | ||
id: number; | ||
description: LocalizedString; | ||
amount: number; | ||
}; | ||
next_achievement: KeyNameId; | ||
media: KeyId; | ||
display_order: number; | ||
} | ||
|
||
interface Asset { | ||
key: string; | ||
value: string; | ||
file_data_id: number; | ||
} | ||
|
||
interface AchievementMedia extends LinkSelfHref { | ||
assets: Asset[]; | ||
id: number; | ||
} | ||
|
||
/** | ||
* Fetches and returns an index of achievement categories. | ||
* | ||
* @returns A promise that resolves to an object representing the index of achievement categories. | ||
*/ | ||
export async function achievementCategories(): Promise<AchievementCategories> { | ||
return await request({ | ||
method: "GET", | ||
url: "/data/wow/achievement-category/index", | ||
namespace: "static", | ||
}); | ||
} | ||
|
||
/** | ||
* Fetches and returns details of a specific achievement category identified by its ID. | ||
* | ||
* @param achievementCategoryId - The unique identifier of the achievement category to retrieve. | ||
* @returns A promise that resolves to an object representing the achievement category details. | ||
*/ | ||
export async function achievementCategory(achievementCategoryId: number): Promise<AchievementCategory> { | ||
return await request({ | ||
method: "GET", | ||
url: `/data/wow/achievement-category/${achievementCategoryId}`, | ||
namespace: "static", | ||
}); | ||
} | ||
|
||
/** | ||
* Fetches and returns an index of achievements. | ||
* | ||
* @returns A promise that resolves to an object representing the index of achievements. | ||
*/ | ||
export async function achievements(): Promise<Achievements> { | ||
return await request({ | ||
method: "GET", | ||
url: "/data/wow/achievement/index", | ||
namespace: "static", | ||
}); | ||
} | ||
|
||
/** | ||
* Fetches and returns details of a specific achievement identified by its ID. | ||
* | ||
* @param achievementId - The unique identifier of the achievement to retrieve. | ||
* @returns A promise that resolves to an object representing the achievement details. | ||
*/ | ||
export async function achievement(achievementId: number): Promise<Achievement> { | ||
return await request({ | ||
method: "GET", | ||
url: `/data/wow/achievement/${achievementId}`, | ||
namespace: "static", | ||
}); | ||
} | ||
|
||
/** | ||
* Fetches and returns media details for a specific achievement identified by its ID. | ||
* | ||
* @param achievementId - The unique identifier of the achievement to retrieve media details for. | ||
* @returns A promise that resolves to an object representing the achievement media details. | ||
*/ | ||
export async function achievementMedia(achievementId: number): Promise<AchievementMedia> { | ||
return await request({ | ||
method: "GET", | ||
url: `/data/wow/media/achievement/${achievementId}`, | ||
namespace: "static", | ||
}); | ||
} |
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,83 @@ | ||
import { LinkSelfHref, request } from "../shared/index.ts"; | ||
|
||
interface AuctionItem { | ||
id: number; | ||
modifiers?: [{ | ||
type: number; | ||
value: number; | ||
}]; | ||
pet_breed_id?: number; | ||
pet_level?: number; | ||
pet_quality_id?: number; | ||
pet_species_id?: number; | ||
bonus_lists?: number[]; | ||
context?: number; | ||
} | ||
|
||
interface AuctionListing { | ||
id: number; | ||
item: AuctionItem; | ||
bid?: number; | ||
buyout?: number; | ||
quantity: number; | ||
time_left: "SHORT" | "MEDIUM" | "LONG" | "VERY_LONG"; | ||
} | ||
|
||
interface Auctions extends LinkSelfHref { | ||
connected_realm: { | ||
href: string; | ||
}; | ||
auctions: AuctionListing[]; | ||
commodities: { | ||
href: string; | ||
}; | ||
} | ||
|
||
interface commodity { | ||
"id": number; | ||
"item": { | ||
"id": number; | ||
}; | ||
"quantity": number; | ||
"unit_price": number; | ||
"time_left": "SHORT" | "MEDIUM" | "LONG" | "VERY_LONG"; | ||
} | ||
|
||
interface Commodities extends LinkSelfHref { | ||
auctions: commodity[]; | ||
} | ||
|
||
/** | ||
* Returns all active auctions for a connected realm. | ||
* | ||
* Auction house data updates at a set interval. The value was initially set at 1 hour; however, it might change over time without notice. | ||
* | ||
* NOTE: Depending on the number of active auctions on the specified connected realm, the response from this endpoint may be rather large. | ||
* | ||
* @param connectedRealmId - The id of the connected realm to return auctions from. | ||
* @returns A promise that resolves to an object representing the auctions being listed. | ||
*/ | ||
export async function auctions(connectedRealmId: number): Promise<Auctions> { | ||
return await request({ | ||
method: "GET", | ||
url: `/data/wow/connected-realm/${connectedRealmId}/auctions`, | ||
namespace: "dynamic", | ||
}); | ||
} | ||
|
||
/** | ||
* Returns all active auctions for commodity items for the entire game region. | ||
* | ||
* Auction house data updates at a set interval. The value was initially set at 1 hour; however, it might change over time without notice. | ||
* | ||
* NOTE: Depending on the number of active auctions on the specified region, the response from this endpoint may be rather large. | ||
* | ||
* @returns A promise that resolves to an object representing the commodities being listed. | ||
*/ | ||
export async function commodities(): Promise<Commodities> { | ||
return await request({ | ||
method: "GET", | ||
url: "/data/wow/auctions/commodities", | ||
namespace: "dynamic", | ||
}); | ||
} |
Oops, something went wrong.