@@ -72,56 +72,56 @@ export interface FetchSteamPoweredInventoryResponse {
7272 total_inventory_count : number ;
7373}
7474
75- export const FetchSteamPoweredInventory = new SimpleHandler < FetchSteamPoweredInventoryRequest , FetchSteamPoweredInventoryResponse > (
76- RequestType . FETCH_STEAM_POWERED_INVENTORY ,
77- async ( req ) => {
78- const accessToken = await getAccessToken ( req . steam_id ) ;
79-
80- const params = new URLSearchParams ( {
81- access_token : accessToken . token ,
82- steamid : req . steam_id ,
83- appid : req . app_id . toString ( ) ,
84- contextid : req . context_id . toString ( ) ,
85- } ) ;
86-
87- if ( req . start_assetid ) {
88- params . set ( 'start_assetid' , req . start_assetid ) ;
89- }
90-
91- if ( req . count ) {
92- params . set ( 'count' , req . count . toString ( ) ) ;
93- }
75+ export const FetchSteamPoweredInventory = new SimpleHandler <
76+ FetchSteamPoweredInventoryRequest ,
77+ FetchSteamPoweredInventoryResponse
78+ > ( RequestType . FETCH_STEAM_POWERED_INVENTORY , async ( req ) => {
79+ const accessToken = await getAccessToken ( req . steam_id ) ;
80+
81+ const params = new URLSearchParams ( {
82+ access_token : accessToken . token ,
83+ steamid : req . steam_id ,
84+ appid : req . app_id . toString ( ) ,
85+ contextid : req . context_id . toString ( ) ,
86+ } ) ;
87+
88+ if ( req . start_assetid ) {
89+ params . set ( 'start_assetid' , req . start_assetid ) ;
90+ }
9491
95- if ( req . get_descriptions !== undefined ) {
96- params . set ( 'get_descriptions ' , req . get_descriptions . toString ( ) ) ;
97- }
92+ if ( req . count ) {
93+ params . set ( 'count ' , req . count . toString ( ) ) ;
94+ }
9895
99- if ( req . for_trade_offer_verification !== undefined ) {
100- params . set ( 'for_trade_offer_verification ' , req . for_trade_offer_verification . toString ( ) ) ;
101- }
96+ if ( req . get_descriptions !== undefined ) {
97+ params . set ( 'get_descriptions ' , req . get_descriptions . toString ( ) ) ;
98+ }
10299
103- if ( req . language ) {
104- params . set ( 'language ' , req . language ) ;
105- }
100+ if ( req . for_trade_offer_verification !== undefined ) {
101+ params . set ( 'for_trade_offer_verification ' , req . for_trade_offer_verification . toString ( ) ) ;
102+ }
106103
107- if ( req . get_asset_properties !== undefined ) {
108- params . set ( 'get_asset_properties ' , req . get_asset_properties . toString ( ) ) ;
109- }
104+ if ( req . language ) {
105+ params . set ( 'language ' , req . language ) ;
106+ }
110107
111- const resp = await fetch (
112- `https://api.steampowered.com/IEconService/GetInventoryItemsWithDescriptions/v1/? ${ params . toString ( ) } `
113- ) ;
108+ if ( req . get_asset_properties !== undefined ) {
109+ params . set ( 'get_asset_properties' , req . get_asset_properties . toString ( ) ) ;
110+ }
114111
115- if ( ! resp . ok ) {
116- throw new Error ( `Invalid response code: ${ resp . status } ` ) ;
117- }
112+ const resp = await fetch (
113+ `https://api.steampowered.com/IEconService/GetInventoryItemsWithDescriptions/v1/? ${ params . toString ( ) } `
114+ ) ;
118115
119- const data = await resp . json ( ) ;
116+ if ( ! resp . ok ) {
117+ throw new Error ( `Invalid response code: ${ resp . status } ` ) ;
118+ }
120119
121- if ( ! data . response ) {
122- throw new Error ( 'Invalid response from Steam API' ) ;
123- }
120+ const data = await resp . json ( ) ;
124121
125- return data . response as FetchSteamPoweredInventoryResponse ;
122+ if ( ! data . response ) {
123+ throw new Error ( 'Invalid response from Steam API' ) ;
126124 }
127- ) ;
125+
126+ return data . response as FetchSteamPoweredInventoryResponse ;
127+ } ) ;
0 commit comments