Skip to content

Commit

Permalink
Convert AuthenticateUserTicket to strong typing (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hona committed Jan 4, 2021
1 parent 47c6ce3 commit 5ea5c99
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/Steam.Models/SteamUserAuth/SteamAuthError.cs
@@ -0,0 +1,8 @@
namespace Steam.Models.SteamUserAuth
{
public class SteamAuthError
{
public string ErrorCode { get; set; }
public string ErrorDesc { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/Steam.Models/SteamUserAuth/SteamAuthResponseParams.cs
@@ -0,0 +1,11 @@
namespace Steam.Models.SteamUserAuth
{
public class SteamAuthResponseParams
{
public string Result { get; set; }
public string SteamId { get; set; }
public string OwnerSteamId { get; set; }
public bool VacBanned { get; set; }
public bool PublisherBanned { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/Steam.Models/SteamUserAuth/SteamUserAuthResponse.cs
@@ -0,0 +1,9 @@
namespace Steam.Models.SteamUserAuth
{
public class SteamUserAuthResponse
{
public SteamAuthResponseParams Params { get; set; }
public SteamAuthError Error { get; set; }
public bool Success => Error == null && Params != null;
}
}
7 changes: 7 additions & 0 deletions src/Steam.Models/SteamUserAuth/SteamUserAuthResponseModel.cs
@@ -0,0 +1,7 @@
namespace Steam.Models.SteamUserAuth
{
public class SteamUserAuthResponseModel
{
public SteamUserAuthResponse Response { get; set; }
}
}
3 changes: 2 additions & 1 deletion src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs
@@ -1,5 +1,6 @@
using SteamWebAPI2.Utilities;
using System.Threading.Tasks;
using Steam.Models.SteamUserAuth;

namespace SteamWebAPI2.Interfaces
{
Expand All @@ -11,6 +12,6 @@ public interface ISteamUserAuth
/// <param name="appId">App ID of the game to authenticate against</param>
/// <param name="ticket">Ticket from GetAuthSessionTicket</param>
/// <returns>Results of authentication request</returns>
Task<ISteamWebResponse<dynamic>> AuthenticateUserTicket(uint appId, string ticket);
Task<ISteamWebResponse<SteamUserAuthResponseModel>> AuthenticateUserTicket(uint appId, string ticket);
}
}
5 changes: 3 additions & 2 deletions src/SteamWebAPI2/Interfaces/SteamUserAuth.cs
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Steam.Models.SteamUserAuth;

namespace SteamWebAPI2.Interfaces
{
Expand Down Expand Up @@ -30,12 +31,12 @@ public SteamUserAuth(IMapper mapper, ISteamWebRequest steamWebRequest, ISteamWeb
/// <param name="appId">App ID of the game to authenticate against</param>
/// <param name="ticket">Ticket from GetAuthSessionTicket</param>
/// <returns>Results of authentication request</returns>
public async Task<ISteamWebResponse<dynamic>> AuthenticateUserTicket(uint appId, string ticket)
public async Task<ISteamWebResponse<SteamUserAuthResponseModel>> AuthenticateUserTicket(uint appId, string ticket)
{
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
parameters.AddIfHasValue(appId, "appid");
parameters.AddIfHasValue(ticket, "ticket");
var playingSharedGameResult = await steamWebInterface.GetAsync<dynamic>("AuthenticateUserTicket", 1, parameters);
var playingSharedGameResult = await steamWebInterface.GetAsync<SteamUserAuthResponseModel>("AuthenticateUserTicket", 1, parameters);
return playingSharedGameResult;
}
}
Expand Down

0 comments on commit 5ea5c99

Please sign in to comment.