Ejemplo n.º 1
0
        public void POSTDepositsSwiftAssetIdEmailTest()
        {
            Step("Make POST /api/Deposits/swift/{assetId}/email and validate response", () =>
            {
                var model = new SwiftDepositEmailModel
                {
                    Amount = 1
                };

                var response = apiV2.Deposits.PostSwiftAssetIdEmail(model, "BTC", token);
                Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            });
        }
Ejemplo n.º 2
0
        public void PostDepositsSwiftAssetIdEmailainvalidTokenTest()
        {
            Step("Make POST /api/Deposits/swift/{assetId}/email and validate response", () =>
            {
                var model = new SwiftDepositEmailModel
                {
                    Amount = 1
                };

                var response = apiV2.Deposits.PostSwiftAssetIdEmail(model, "BTC", Guid.NewGuid().ToString());
                Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            });
        }
Ejemplo n.º 3
0
        public void PostDepositsSwiftAssetIdEmailEmptyObjectTest()
        {
            var assetId = "";

            Step("Make GET /assets request. Take id of first asset in response", () =>
            {
                var assets = apiV2.Assets.GetAssets();
                Assert.That(assets.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                assetId = assets.GetResponseObject().Assets[0].Id;
            });

            Step($"Make POST /api/Deposits/swift/{assetId}/email and validate response", () =>
            {
                var model = new SwiftDepositEmailModel
                {
                };

                var response = apiV2.Deposits.PostSwiftAssetIdEmail(model, assetId, token);
                Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            });
        }
Ejemplo n.º 4
0
 public IResponse PostSwiftAssetIdEmail(SwiftDepositEmailModel model, string assetId, string token)
 {
     return(Request.Post($"/Deposits/swift/{assetId}/email").AddJsonBody(model).WithBearerToken(token).Build().Execute());
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> PostRequestSwiftRequisites([FromRoute] string assetId, [FromBody] SwiftDepositEmailModel model)
        {
            var asset = await _assetsHelper.GetAssetAsync(assetId);

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

            if (asset == null)
            {
                throw LykkeApiErrorException.NotFound(LykkeApiErrorCodes.Service.AssetNotFound);
            }

            if (!asset.SwiftDepositEnabled || !assetsAvailableToClient.Contains(assetId))
            {
                throw LykkeApiErrorException.BadRequest(LykkeApiErrorCodes.Service.AssetUnavailable);
            }

            if (model.Amount <= 0 || model.Amount != decimal.Round(model.Amount, asset.Accuracy))
            {
                throw LykkeApiErrorException.BadRequest(LykkeApiErrorCodes.Service.InvalidInput);
            }

            var isKycNeeded = await _kycStatusService.IsKycNeededAsync(_requestContext.ClientId);

            if (isKycNeeded)
            {
                throw LykkeApiErrorException.BadRequest(LykkeApiErrorCodes.Service.KycRequired);
            }

            var checkResult = await _limitationsServiceClient.CheckAsync(
                _requestContext.ClientId,
                assetId,
                decimal.ToDouble(model.Amount),
                CurrencyOperationType.SwiftTransfer);

            if (!checkResult.IsValid)
            {
                throw LykkeApiErrorException.BadRequest(LykkeApiErrorCodes.Service.DepositLimitReached);
            }

            var personalData = await _personalDataService.GetAsync(_requestContext.ClientId);

            _swiftCredentialsClient.EmailRequestAsync(
                _requestContext.ClientId,
                personalData.SpotRegulator,
                assetId,
                model.Amount);

            return(Ok());
        }