SteamWebAPI.SteamMicroTransaction.CreateCartAsync C# (CSharp) Méthode

CreateCartAsync() public méthode

public CreateCartAsync ( long steamId ) : Task
steamId long
Résultat Task
        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);
            }
        }

Usage Example

 public async Task<Cart> CreateCartAsync(long steamId)
 {
     SteamMicroTransaction steamMicroTransaction = new SteamMicroTransaction(this.developerKey);
     return await steamMicroTransaction.CreateCartAsync(steamId);
 }