示例#1
0
        public async Task <WalletDTO> CreateTestWallet(bool isHFT = false)
        {
            string url = ApiPaths.WALLETS_BASE_PATH;

            if (isHFT)
            {
                url += "/hft";
            }

            WalletCreateDTO newWallet = new WalletCreateDTO()
            {
                Name        = Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest,
                Description = Guid.NewGuid().ToString() + Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest
            };
            string createParam = JsonUtils.SerializeObject(newWallet);

            var response = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, createParam, Method.POST);

            if (response.Status != HttpStatusCode.OK)
            {
                return(null);
            }

            WalletDTO returnModel;

            if (isHFT)
            {
                returnModel = new WalletDTO();
                WalletCreateHFTDTO createdDTO = JsonUtils.DeserializeJson <WalletCreateHFTDTO>(response.ResponseJson);
                returnModel.Id          = createdDTO.WalletId;
                returnModel.ApiKey      = createdDTO.ApiKey;
                returnModel.Name        = newWallet.Name;
                returnModel.Description = newWallet.Description;
            }
            else
            {
                returnModel = JsonUtils.DeserializeJson <WalletDTO>(response.ResponseJson);
            }

            AddOneTimeCleanupAction(async() => await DeleteTestWallet(returnModel.Id));

            return(returnModel);
        }
示例#2
0
        public async Task <WalletDTO> CreateTestWallet()
        {
            string createWalletUrl = $"{BaseUrl.ApiV2BaseUrl}{walletPath}/hft";

            string          utcTimestamp = DateTime.UtcNow.ToString("s");
            WalletCreateDTO newWallet    = new WalletCreateDTO
            {
                Name        = $"{GlobalConstants.AutoTest}_Wallet_{utcTimestamp}",
                Description = $"{GlobalConstants.AutoTest}_Wallet_{utcTimestamp} - Description"
            };

            string createParam = JsonUtils.SerializeObject(newWallet);

            var response = await Consumer.ExecuteRequestCustomEndpoint(createWalletUrl, Helpers.EmptyDictionary, createParam, Method.POST);

            if (response.Status != HttpStatusCode.OK)
            {
                return(null);
            }

            WalletDTO returnModel = new WalletDTO();

            WalletCreateHFTDTO createdDTO = JsonUtils.DeserializeJson <WalletCreateHFTDTO>(response.ResponseJson);

            returnModel.Id          = createdDTO.WalletId;
            returnModel.ApiKey      = createdDTO.ApiKey;
            returnModel.Name        = newWallet.Name;
            returnModel.Description = newWallet.Description;

            // TODO: Make traded assets random

            // Add some funds to the wallet
            await AddAssetFundsToWallet(createdDTO.WalletId, "EUR", 100);
            await AddAssetFundsToWallet(createdDTO.WalletId, "USD", 100);
            await AddAssetFundsToWallet(createdDTO.WalletId, "BTC", 10);

            AddOneTimeCleanupAction(async() => await DeleteTestWallet(returnModel.Id));
            return(returnModel);
        }