예제 #1
0
        public async Task RegenerateApiKey()
        {
            string url      = ApiPaths.HFT_BASE_PATH + "/" + this.TestWalletRegenerateKey.Id + "/regenerateKey";
            var    response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.PUT);

            Assert.True(response.Status == HttpStatusCode.OK);

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

            Assert.True(this.TestWalletRegenerateKey.ApiKey != parsedResponse.ApiKey);

            string checkUrl      = ApiPaths.WALLETS_BASE_PATH + "/" + this.TestWalletRegenerateKey.Id;
            var    checkResponse = await this.Consumer.ExecuteRequest(checkUrl, Helpers.EmptyDictionary, null, Method.GET);

            Assert.True(checkResponse.Status == HttpStatusCode.OK);
            WalletDTO checkParsedResponse = JsonUtils.DeserializeJson <WalletDTO>(checkResponse.ResponseJson);

            Assert.True(checkParsedResponse.ApiKey == parsedResponse.ApiKey);
        }
예제 #2
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);
        }
예제 #3
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);
        }