Skip to content

Commit

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

Add types for `/v2/skins`
56 changes: 56 additions & 0 deletions packages/types/data/skin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import type { Gender, Race } from './character';

/**
* Skin as returned from `/v2/skins`
* @see https://wiki.guildwars2.com/wiki/API:2/skins
*/
export interface Skin {
/** The id of the skin */
id: number;

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

/** Description of the skin */
description?: string;

/** The icon of the skin */
icon?: string;

/** The rarity of the skin */
rarity: 'Basic' | 'Masterwork' | 'Legendary' | 'Rare' | 'Exotic' | 'Ascended';

/** Flags of this skin */
flags: SkinFlag[];

/** Restrictions of the skin */
restrictions: string[];

/** Skin type */
type: 'Armor' | 'Back' | 'Gathering' | 'Weapon';

/** Skin details */
details?: {
/** Damage type */
damage_type?: 'Physical' | 'Choking' | 'Fire' | 'Lightning' | 'Ice';

/** Dye slots */
dye_slots?: {
default: DyeSlot[];
overrides: Record<`${Race}${Gender}`, DyeSlot[]>;
};

/** The subtype of this skin */
type: 'Leggings' | 'Coat' | 'Boots' | 'Gloves' | 'Shoulders' | 'Helm' | 'HelmAquatic' | 'Foraging' | 'Logging' | 'Mining' | 'LargeBundle' | 'Rifle' | 'SmallBundle' | 'Toy' | 'ToyTwoHanded' | 'Axe' | 'Staff' | 'Hammer' | 'Pistol' | 'Longbow' | 'Dagger' | 'Sword' | 'Shortbow' | 'Focus' | 'Torch' | 'Spear' | 'Mace' | 'Speargun' | 'Greatsword' | 'Scepter' | 'Warhorn' | 'Shield' | 'Trident' | 'Lure' | 'Bait' | 'Fishing';

/** The weight class of this armor skin */
weight_class?: 'Heavy' | 'Light' | 'Medium' | 'Clothing';
};
};

interface DyeSlot {
color_id: number;
material: 'leather' | 'cloth' | 'metal';
}

export type SkinFlag = 'ShowInWardrobe' | 'NoCost' | 'HideIfLocked' | 'OverrideRarity';
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 { Skin } from './data/skin';
import type { Title } from './data/title';
import type { Tokeninfo } from './data/tokeninfo';
import type { WizardsVault, WizardsVaultListing, WizardsVaultObjective } from './data/wizardsvault';
Expand Down Expand Up @@ -419,6 +420,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/skins', number> ? BulkExpandedResponseType<'/v2/skins', Url, number, Skin> :
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> :
Expand Down

0 comments on commit 2badee8

Please sign in to comment.