Skip to content

Commit

Permalink
Add types for /v2/titles
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Jul 26, 2024
1 parent 8e7ac8f commit 3ecdca5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-apples-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gw2api/types": patch
---

Add types for `/v2/titles`
23 changes: 23 additions & 0 deletions packages/types/data/title.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Title as returned from `/v2/titles`
* @see https://wiki.guildwars2.com/wiki/API:2/titles
*/
export interface Title {
/** The id of the title */
id: number;

/** The name of the title */
name: string;

/**
* The achievement id that grants this title
* @deprecated Use `achievements` instead
*/
achievement?: number;

/** List of achievement ids granting this title */
achievements?: number[];

/** Achievement Points required to unlock this title. */
ap_required?: number;
}
2 changes: 2 additions & 0 deletions packages/types/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { Item } from './data/item';
import type { MaterialCategory } from './data/material';
import type { Quaggan } from './data/quaggan';
import type { Recipe } from './data/recipe';
import type { Title } from './data/title';
import type { Tokeninfo } from './data/tokeninfo';
import type { WizardsVault, WizardsVaultListing, WizardsVaultObjective } from './data/wizardsvault';
import type { SchemaVersion } from './schema';
Expand Down Expand Up @@ -418,6 +419,7 @@ export type EndpointType<Url extends KnownEndpoint | (string & {}), Schema exten
Url extends BulkExpandedEndpointUrl<'/v2/materials', number> ? BulkExpandedResponseType<'/v2/materials', Url, number, MaterialCategory> :
Url extends BulkExpandedEndpointUrl<'/v2/quaggans', string> ? BulkExpandedResponseType<'/v2/quaggans', Url, string, Quaggan> :
Url extends BulkExpandedEndpointUrl<'/v2/recipes', number> ? BulkExpandedResponseType<'/v2/recipes', Url, number, Recipe<Schema>> :
Url extends BulkExpandedEndpointUrl<'/v2/titles', number> ? BulkExpandedResponseType<'/v2/titles', Url, number, Title> :
Url extends BulkExpandedEndpointUrl<'/v2/commerce/listings', number> ? BulkExpandedResponseType<'/v2/commerce/listings', Url, number, Listing> :
Url extends BulkExpandedEndpointUrl<'/v2/commerce/prices', number> ? BulkExpandedResponseType<'/v2/commerce/prices', Url, number, Price> :
Url extends PaginatedEndpointUrl<'/v2/commerce/transactions/current/buys'> ? TransactionCurrent[] :
Expand Down

0 comments on commit 3ecdca5

Please sign in to comment.