@@ -99,6 +99,55 @@ public void Dispose() {
9999 WebBrowser . Dispose ( ) ;
100100 }
101101
102+ [ PublicAPI ]
103+ public async Task < ( bool Success , bool RequiresMobileConfirmation ) > AcceptTradeOffer ( ulong tradeID ) {
104+ ArgumentOutOfRangeException . ThrowIfZero ( tradeID ) ;
105+
106+ Uri request = new ( SteamCommunityURL , $ "/tradeoffer/{ tradeID } /accept") ;
107+ Uri referer = new ( SteamCommunityURL , $ "/tradeoffer/{ tradeID } ") ;
108+
109+ // Extra entry for sessionID
110+ Dictionary < string , string > data = new ( 3 , StringComparer . Ordinal ) {
111+ { "serverid" , "1" } ,
112+ { "tradeofferid" , tradeID . ToString ( CultureInfo . InvariantCulture ) }
113+ } ;
114+
115+ ObjectResponse < TradeOfferAcceptResponse > ? response = null ;
116+
117+ for ( byte i = 0 ; ( i < WebBrowser . MaxTries ) && ( response == null ) ; i ++ ) {
118+ response = await UrlPostToJsonObjectWithSession < TradeOfferAcceptResponse > ( request , data : data , referer : referer , requestOptions : WebBrowser . ERequestOptions . ReturnServerErrors | WebBrowser . ERequestOptions . AllowInvalidBodyOnErrors ) . ConfigureAwait ( false ) ;
119+
120+ if ( response == null ) {
121+ return ( false , false ) ;
122+ }
123+
124+ if ( response . StatusCode . IsServerErrorCode ( ) ) {
125+ if ( string . IsNullOrEmpty ( response . Content ? . ErrorText ) ) {
126+ // This is a generic server error without a reason, try again
127+ response = null ;
128+
129+ continue ;
130+ }
131+
132+ // This is actually client error with a reason, so it doesn't make sense to retry
133+ Bot . ArchiLogger . LogGenericWarning ( Strings . FormatWarningFailedWithError ( response . Content . ErrorText ) ) ;
134+
135+ return ( false , false ) ;
136+ }
137+ }
138+
139+ return response ? . Content != null ? ( true , response . Content . RequiresMobileConfirmation ) : ( false , false ) ;
140+ }
141+
142+ [ PublicAPI ]
143+ public async Task < bool > DeclineTradeOffer ( ulong tradeID ) {
144+ ArgumentOutOfRangeException . ThrowIfZero ( tradeID ) ;
145+
146+ Uri request = new ( SteamCommunityURL , $ "/tradeoffer/{ tradeID } /decline") ;
147+
148+ return await UrlPostWithSession ( request ) . ConfigureAwait ( false ) ;
149+ }
150+
102151 [ PublicAPI ]
103152 public async Task < bool > CancelTradeOffer ( ulong tradeID ) {
104153 ArgumentOutOfRangeException . ThrowIfZero ( tradeID ) ;
@@ -1468,45 +1517,6 @@ internal async Task<bool> AcceptDigitalGiftCard(ulong giftCardID) {
14681517 return true ;
14691518 }
14701519
1471- internal async Task < ( bool Success , bool RequiresMobileConfirmation ) > AcceptTradeOffer ( ulong tradeID ) {
1472- ArgumentOutOfRangeException . ThrowIfZero ( tradeID ) ;
1473-
1474- Uri request = new ( SteamCommunityURL , $ "/tradeoffer/{ tradeID } /accept") ;
1475- Uri referer = new ( SteamCommunityURL , $ "/tradeoffer/{ tradeID } ") ;
1476-
1477- // Extra entry for sessionID
1478- Dictionary < string , string > data = new ( 3 , StringComparer . Ordinal ) {
1479- { "serverid" , "1" } ,
1480- { "tradeofferid" , tradeID . ToString ( CultureInfo . InvariantCulture ) }
1481- } ;
1482-
1483- ObjectResponse < TradeOfferAcceptResponse > ? response = null ;
1484-
1485- for ( byte i = 0 ; ( i < WebBrowser . MaxTries ) && ( response == null ) ; i ++ ) {
1486- response = await UrlPostToJsonObjectWithSession < TradeOfferAcceptResponse > ( request , data : data , referer : referer , requestOptions : WebBrowser . ERequestOptions . ReturnServerErrors | WebBrowser . ERequestOptions . AllowInvalidBodyOnErrors ) . ConfigureAwait ( false ) ;
1487-
1488- if ( response == null ) {
1489- return ( false , false ) ;
1490- }
1491-
1492- if ( response . StatusCode . IsServerErrorCode ( ) ) {
1493- if ( string . IsNullOrEmpty ( response . Content ? . ErrorText ) ) {
1494- // This is a generic server error without a reason, try again
1495- response = null ;
1496-
1497- continue ;
1498- }
1499-
1500- // This is actually client error with a reason, so it doesn't make sense to retry
1501- Bot . ArchiLogger . LogGenericWarning ( Strings . FormatWarningFailedWithError ( response . Content . ErrorText ) ) ;
1502-
1503- return ( false , false ) ;
1504- }
1505- }
1506-
1507- return response ? . Content != null ? ( true , response . Content . RequiresMobileConfirmation ) : ( false , false ) ;
1508- }
1509-
15101520 internal async Task < bool > AcknowledgeTradeRestrictions ( ) {
15111521 Uri request = new ( SteamCommunityURL , "/trade/new/acknowledge" ) ;
15121522
@@ -1621,14 +1631,6 @@ internal async Task<bool> ChangePrivacySettings(UserPrivacy userPrivacy) {
16211631 return true ;
16221632 }
16231633
1624- internal async Task < bool > DeclineTradeOffer ( ulong tradeID ) {
1625- ArgumentOutOfRangeException . ThrowIfZero ( tradeID ) ;
1626-
1627- Uri request = new ( SteamCommunityURL , $ "/tradeoffer/{ tradeID } /decline") ;
1628-
1629- return await UrlPostWithSession ( request ) . ConfigureAwait ( false ) ;
1630- }
1631-
16321634 internal async Task < HashSet < uint > ? > GetAppList ( ) {
16331635 const string endpoint = "GetAppList" ;
16341636 HttpMethod method = HttpMethod . Get ;
0 commit comments