-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Pricer.ts
109 lines (89 loc) · 2.66 KB
/
Pricer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import Currencies from 'tf2-currencies';
export interface PricerOptions {
pricerUrl?: string;
pricerApiToken?: string;
}
export type GetPricerFn = (options: PricerOptions) => Pricer;
/**
* Basic pricer interface
*
* Those wishing to plug in something other than PricesTf should provide at least
* the following interface plus a "pricer" module with the following method to get the constructor:
* static getPricer(options: PricerOptions): Pricer
*/
export default interface Pricer {
getOptions(): PricerOptions;
requestCheck(sku: string, source: string): Promise<RequestCheckResponse>;
getPrice(sku: string, source: string): Promise<GetItemPriceResponse>;
getSales(sku: string, source: string): Promise<GetItemSalesResponse>;
getPricelist(source: string): Promise<GetPricelistResponse>;
getSchema(): Promise<GetSchemaResponse>;
}
export type RequestCheckFn = (sku: string, source: string) => Promise<RequestCheckResponse>;
export type GetPriceFn = (sku: string, source: string) => Promise<GetItemPriceResponse>;
export type GetSalesFn = (sku: string, source: string) => Promise<GetItemSalesResponse>;
export type GetPrice = (sku: string, source: string) => Promise<GetItemPriceResponse>;
export type GetPricelist = (source: string) => Promise<GetPricelistResponse>;
export type GetSchema = () => Promise<GetSchemaResponse>;
export interface PricesResponse {
success: boolean;
message?: string;
}
export interface GetSchemaResponse extends PricesResponse {
version: string;
time: number;
raw: any;
}
export interface GetOverviewResponse extends PricesResponse {
items: ItemOverview[];
}
export interface ItemOverview {
name: string;
sku: string;
}
export interface GetPricelistResponse extends PricesResponse {
currency?: any;
items?: Item[];
}
export interface Item {
sku: string;
name: string;
source: string;
time: number;
buy: Currencies | null;
sell: Currencies | null;
}
export interface Links {
ptf: string;
mptf: string;
scm: string;
bptf: string;
}
export interface GetItemPriceResponse extends PricesResponse {
sku?: string;
name?: string;
currency?: string;
source?: string;
time?: number;
buy?: Currencies;
sell?: Currencies;
message?: string;
}
export interface GetItemSalesResponse extends PricesResponse {
sku: string;
name: string;
sales: Sale[];
}
export interface Sale {
id: string;
steamid: string;
automatic: boolean;
attributes: any;
intent: number;
currencies: Currencies;
time: number;
}
export interface RequestCheckResponse extends PricesResponse {
sku: string;
name: string;
}