コード例 #1
0
        public async Task <IActionResult> SetBaseAsset([FromBody] BaseAssetUpdateModel model)
        {
            var baseAsset = model.BaseAssetId ?? model.BaseAsssetId;

            if (string.IsNullOrWhiteSpace(baseAsset))
            {
                return(BadRequest());
            }

            var asset = await _assetsHelper.GetAssetAsync(baseAsset);

            if (asset == null || asset.IsDisabled)
            {
                return(NotFound());
            }

            var assetsAvailableToUser =
                await _assetsHelper.GetSetOfAssetsAvailableToClientAsync(_requestContext.ClientId, _requestContext.PartnerId,
                                                                         true);

            if (!asset.IsBase || !assetsAvailableToUser.Contains(baseAsset))
            {
                return(BadRequest());
            }

            await _clientAccountClient.ClientSettings.SetBaseAssetAsync(
                new BaseAssetRequest { BaseAssetId = baseAsset, ClientId = _requestContext.ClientId });

            return(Ok());
        }
コード例 #2
0
        public async Task <IActionResult> SetBaseAsset([FromBody] BaseAssetUpdateModel model)
        {
            try
            {
                var assetResponse = await _assetsService.AssetGetWithHttpMessagesAsync(model.BaseAsssetId);

                var asset = assetResponse?.Body as Asset;

                if (asset == null)
                {
                    return(NotFound());
                }

                if (!asset.IsBase)
                {
                    return(BadRequest(new { message = "Asset can't be set as base" }));
                }

                await _clientAccountSettingsClient.SetBaseAssetAsync(_requestContext.ClientId, model.BaseAsssetId);
            }
            catch (Exception e)
            {
                await _log.WriteFatalErrorAsync(nameof(AssetsController), nameof(SetBaseAsset), e);

                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            return(Ok());
        }
コード例 #3
0
 public void PostBaseAssetTest()
 {
     Step("Make POST /api/assets/baseAsset and validate response", () =>
     {
         var model = new BaseAssetUpdateModel
         {
             BaseAssetId  = "BTC",
             BaseAsssetId = "BTC"
         };
         var response = apiV2.Assets.PostAssetBaseAsset(model, token);
         Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
     });
 }
コード例 #4
0
 public IResponse PostAssetBaseAsset(BaseAssetUpdateModel baseAsset, string token)
 {
     return(Request.Post($"/assets/baseAsset").WithBearerToken(token).AddJsonBody(baseAsset).Build().Execute());
 }