From 38c2b51f2b12dfb1c1b172a43bdbe0d958c09dd1 Mon Sep 17 00:00:00 2001 From: Archi Date: Thu, 17 Feb 2022 10:59:49 +0100 Subject: [PATCH] Make GetTradeToken() public API --- .../Steam/Integration/ArchiHandler.cs | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs index 50cdfa5c0..d7ccb6db0 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs @@ -130,6 +130,37 @@ public sealed class ArchiHandler : ClientMsgHandler { return body.games.ToDictionary(static game => (uint) game.appid, static game => game.name); } + [PublicAPI] + public async Task GetTradeToken() { + if (Client == null) { + throw new InvalidOperationException(nameof(Client)); + } + + if (!Client.IsConnected) { + return null; + } + + CEcon_GetTradeOfferAccessToken_Request request = new(); + + SteamUnifiedMessages.ServiceMethodResponse response; + + try { + response = await UnifiedEconService.SendMessage(x => x.GetTradeOfferAccessToken(request)).ToLongRunningTask().ConfigureAwait(false); + } catch (Exception e) { + ArchiLogger.LogGenericWarningException(e); + + return null; + } + + if (response.Result != EResult.OK) { + return null; + } + + CEcon_GetTradeOfferAccessToken_Response body = response.GetDeserializedResponse(); + + return body.trade_offer_access_token; + } + public override void HandleMsg(IPacketMsg packetMsg) { ArgumentNullException.ThrowIfNull(packetMsg); @@ -401,36 +432,6 @@ public sealed class ArchiHandler : ClientMsgHandler { return body.privacy_settings; } - internal async Task GetTradeToken() { - if (Client == null) { - throw new InvalidOperationException(nameof(Client)); - } - - if (!Client.IsConnected) { - return null; - } - - CEcon_GetTradeOfferAccessToken_Request request = new(); - - SteamUnifiedMessages.ServiceMethodResponse response; - - try { - response = await UnifiedEconService.SendMessage(x => x.GetTradeOfferAccessToken(request)).ToLongRunningTask().ConfigureAwait(false); - } catch (Exception e) { - ArchiLogger.LogGenericWarningException(e); - - return null; - } - - if (response.Result != EResult.OK) { - return null; - } - - CEcon_GetTradeOfferAccessToken_Response body = response.GetDeserializedResponse(); - - return body.trade_offer_access_token; - } - internal async Task GetTwoFactorDeviceIdentifier(ulong steamID) { if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) { throw new ArgumentOutOfRangeException(nameof(steamID));