-
Notifications
You must be signed in to change notification settings - Fork 20
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 #234 from csfloat/feature/trade-cancel-pings
Implements Cancel Trade Pings
- Loading branch information
Showing
6 changed files
with
125 additions
and
19 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
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
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
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,31 @@ | ||
import {SimpleHandler} from './main'; | ||
import {RequestType} from './types'; | ||
import {environment} from '../../../environment'; | ||
import {Trade} from '../../types/float_market'; | ||
|
||
export interface PingCancelTradeRequest { | ||
trade_id: string; | ||
} | ||
|
||
export interface PingCancelTradeResponse { | ||
trade: Trade; | ||
} | ||
|
||
export const PingCancelTrade = new SimpleHandler<PingCancelTradeRequest, PingCancelTradeResponse>( | ||
RequestType.PING_CANCEL_TRADE, | ||
async (req) => { | ||
const resp = await fetch(`${environment.csfloat_base_api_url}/v1/trades/${req.trade_id}/cancel-ping`, { | ||
credentials: 'include', | ||
method: 'POST', | ||
}); | ||
|
||
if (resp.status !== 200) { | ||
throw new Error('invalid status'); | ||
} | ||
|
||
const trade = (await resp.json()) as Trade; | ||
return { | ||
trade, | ||
}; | ||
} | ||
); |
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 |
---|---|---|
|
@@ -15,4 +15,5 @@ export enum RequestType { | |
HAS_PERMISSIONS, | ||
PING_SETUP_EXTENSION, | ||
PING_EXTENSION_STATUS, | ||
PING_CANCEL_TRADE, | ||
} |
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