public async Task<Cart> CreateCartAsync(long steamId) { List<WebRequestParameter> requestParameters = new List<WebRequestParameter>(); WebRequestParameter steamIdParameter = new WebRequestParameter("steamid", steamId.ToString()); requestParameters.Add(steamIdParameter); // send the request and wait for the response JObject data = await PerformSteamRequestAsync("ISteamMicroTxn", "CreateCart", 1, requestParameters); bool success = TypeHelper.CreateBoolean(data["result"]["success"]); if (!success) throw new Exception(E_HTTP_RESPONSE_RESULT_FAILED); try { Cart cart = new Cart() { ID = TypeHelper.CreateLong(data["result"]["cartgid"]), IsValid = true, OwnerSteamID = steamId }; return cart; } catch { throw new Exception(E_JSON_DESERIALIZATION_FAILED); } }
public async Task<Cart> IsValidCartAsync(long steamId, long cartId) { List<WebRequestParameter> requestParameters = new List<WebRequestParameter>(); WebRequestParameter steamIdParameter = new WebRequestParameter("steamid", steamId.ToString()); requestParameters.Add(steamIdParameter); WebRequestParameter cartIdParameter = new WebRequestParameter("gid", cartId.ToString()); requestParameters.Add(cartIdParameter); // send the request and wait for the response JObject data = await PerformSteamRequestAsync("ISteamMicroTxn", "IsValidCart", 1, requestParameters); try { Cart cart = new Cart(); bool isFound = TypeHelper.CreateBoolean(data["result"]["found"]); cart.ID = cartId; cart.IsValid = isFound; if (isFound) cart.OwnerSteamID = TypeHelper.CreateLong(data["result"]["steamidowner"]); return cart; } catch { throw new Exception(E_JSON_DESERIALIZATION_FAILED); } }