mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-02-02 19:12:07 +00:00
Make GetTradeToken() public API
This commit is contained in:
@@ -130,6 +130,37 @@ public sealed class ArchiHandler : ClientMsgHandler {
|
|||||||
return body.games.ToDictionary(static game => (uint) game.appid, static game => game.name);
|
return body.games.ToDictionary(static game => (uint) game.appid, static game => game.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public async Task<string?> 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<CEcon_GetTradeOfferAccessToken_Response>();
|
||||||
|
|
||||||
|
return body.trade_offer_access_token;
|
||||||
|
}
|
||||||
|
|
||||||
public override void HandleMsg(IPacketMsg packetMsg) {
|
public override void HandleMsg(IPacketMsg packetMsg) {
|
||||||
ArgumentNullException.ThrowIfNull(packetMsg);
|
ArgumentNullException.ThrowIfNull(packetMsg);
|
||||||
|
|
||||||
@@ -401,36 +432,6 @@ public sealed class ArchiHandler : ClientMsgHandler {
|
|||||||
return body.privacy_settings;
|
return body.privacy_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<string?> 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<CEcon_GetTradeOfferAccessToken_Response>();
|
|
||||||
|
|
||||||
return body.trade_offer_access_token;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task<string?> GetTwoFactorDeviceIdentifier(ulong steamID) {
|
internal async Task<string?> GetTwoFactorDeviceIdentifier(ulong steamID) {
|
||||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
||||||
throw new ArgumentOutOfRangeException(nameof(steamID));
|
throw new ArgumentOutOfRangeException(nameof(steamID));
|
||||||
|
|||||||
Reference in New Issue
Block a user