-
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.
Merge pull request #82 from GW2Treasures/feature/commerce-delivery
Add types for `/v2/commerce/delivery` and `/v2/commerce/exchange`
- Loading branch information
Showing
5 changed files
with
123 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@gw2api/types": patch | ||
--- | ||
|
||
Add types for `/v2/commerce/delivery` |
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,5 @@ | ||
--- | ||
"@gw2api/types": patch | ||
--- | ||
|
||
Add types for `/v2/commerce/exchange` |
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,5 @@ | ||
--- | ||
"@gw2api/types": patch | ||
--- | ||
|
||
Improve commerce types |
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 |
---|---|---|
@@ -1,33 +1,118 @@ | ||
type PriceDetail = { | ||
/** | ||
* Delivery as returned from /v2/commerce/delivery | ||
* @see https://wiki.guildwars2.com/wiki/API:2/commerce/delivery | ||
*/ | ||
export interface Delivery { | ||
/** The amount of coins ready for pickup */ | ||
coins: number, | ||
|
||
/** Items waiting for pickup */ | ||
items: Delivery.Item[] | ||
} | ||
|
||
export namespace Delivery { | ||
export interface Item { | ||
/** The id of the item, resolvable against /v2/items */ | ||
id: number, | ||
|
||
/** The amount of items */ | ||
count: number | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Listing as returned from /v2/commerce/exchange/{coins,gems} | ||
* @see https://wiki.guildwars2.com/wiki/API:2/commerce/exchange | ||
*/ | ||
export interface Exchange { | ||
/** The amount of coins per single gem */ | ||
coins_per_gem: number, | ||
|
||
/** The amount exchanged for the specified quantity */ | ||
quantity: number, | ||
unit_price: number, | ||
} | ||
|
||
type ListingDetail = PriceDetail & { | ||
listings: number, | ||
|
||
/** | ||
* Listing as returned from /v2/commerce/listings | ||
* @see https://wiki.guildwars2.com/wiki/API:2/commerce/listings | ||
*/ | ||
export interface Listing { | ||
/** The id of the item, resolvable against /v2/items */ | ||
id: number, | ||
|
||
/** Current buy listings */ | ||
buys: Listing.Detail[], | ||
|
||
/** Current sell listings */ | ||
sells: Listing.Detail[], | ||
} | ||
|
||
export namespace Listing { | ||
export interface Detail extends Price.Detail { | ||
/** Amount of listings */ | ||
listings: number, | ||
} | ||
} | ||
|
||
export type Price = { | ||
|
||
/** | ||
* Price as returned from /v2/commerce/prices | ||
* @see https://wiki.guildwars2.com/wiki/API:2/commerce/prices | ||
*/ | ||
export interface Price { | ||
/** The id of the item, resolvable against /v2/items */ | ||
id: number, | ||
|
||
/** Flag if the item is available for Free to Play accounts */ | ||
whitelisted: boolean, | ||
buys: PriceDetail, | ||
sells: PriceDetail, | ||
|
||
/** Buy price details */ | ||
buys: Price.Detail, | ||
|
||
/** Sell price details */ | ||
sells: Price.Detail, | ||
} | ||
|
||
export type Listing = { | ||
id: number, | ||
buys: ListingDetail[], | ||
sells: ListingDetail[], | ||
export namespace Price { | ||
export interface Detail { | ||
/** Amount of items listed at this price */ | ||
quantity: number, | ||
|
||
/** Price per item */ | ||
unit_price: number, | ||
} | ||
} | ||
|
||
export type TransactionCurrent = { | ||
|
||
/** | ||
* Transactions as returned from /v2/commerce/transactions/current | ||
* @see https://wiki.guildwars2.com/wiki/API:2/commerce/transactions | ||
*/ | ||
export interface TransactionCurrent { | ||
/** Transaction id */ | ||
id: number, | ||
|
||
/** The id of the item, resolvable against /v2/items */ | ||
item_id: number, | ||
|
||
/** The price of the transaction */ | ||
price: number, | ||
|
||
/** The amount of items in this transaction */ | ||
quantity: number, | ||
|
||
/** The transaction creation date as ISO-8601 timestamp */ | ||
created: string | ||
} | ||
|
||
export type TransactionHistoric = TransactionCurrent & { | ||
|
||
/** | ||
* Transactions as returned from /v2/commerce/transactions/history | ||
* @see https://wiki.guildwars2.com/wiki/API:2/commerce/transactions | ||
*/ | ||
export interface TransactionHistoric extends TransactionCurrent { | ||
/** The date of purchase as ISO-8601 timestamp */ | ||
purchased: string | ||
} |
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