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()); }
public async Task <IActionResult> UserInfo() { try { var personalDataTask = _personalDataService.GetAsync(_requestContext.ClientId); var isKycNeededTask = _kycStatusService.IsKycNeededAsync(_requestContext.ClientId); await Task.WhenAll(personalDataTask, isKycNeededTask); IPersonalData personalData = personalDataTask.Result; bool isKycNeeded = isKycNeededTask.Result; return(Ok(new UserInfoResponseModel { Email = personalData?.Email, FirstName = personalData?.FirstName, LastName = personalData?.LastName, KycStatus = (isKycNeeded ? KycStatus.NeedToFillData : KycStatus.Ok).ToApiModel() })); } catch (Exception e) { _log.Error(e, $"clientId = {_requestContext.ClientId}"); return(StatusCode((int)HttpStatusCode.InternalServerError)); } }
public async Task <Asset> CheckDepositPreconditionsAsync(string clientId, string assetId = default) { Asset asset = default; if (!string.IsNullOrWhiteSpace(assetId)) { asset = await _assetsService.GetAssetByIdAsync(assetId); if (asset == null || asset.IsDisabled || !asset.BlockchainDepositEnabled) { throw HftApiException.Create(HftApiErrorCode.ItemNotFound, "Asset not found"); } var assetsAvailableToClient = await _assetsService.GetAllAssetsAsync(clientId); if (assetsAvailableToClient.SingleOrDefault(x => x.AssetId == assetId) == null || asset.BlockchainIntegrationType != BlockchainIntegrationType.Sirius) { throw HftApiException.Create(HftApiErrorCode.ActionForbidden, "Asset unavailable"); } } else { var allAssets = await _assetsService.GetAllAssetsAsync(); if (allAssets.All(x => x.BlockchainIntegrationType != BlockchainIntegrationType.Sirius)) { throw HftApiException.Create(HftApiErrorCode.ActionForbidden, "Asset unavailable"); } } var pendingDialogs = await _clientDialogsClient.ClientDialogs.GetDialogsAsync(clientId); if (pendingDialogs.Any(dialog => dialog.ConditionType == DialogConditionType.Predeposit)) { throw HftApiException.Create(HftApiErrorCode.ActionForbidden, "Pending dialogs"); } var isKycNeeded = await _kycStatusService.IsKycNeededAsync(clientId); if (isKycNeeded) { throw HftApiException.Create(HftApiErrorCode.ActionForbidden, "KYC required"); } return(asset); }
private async Task <bool> IsKycNotNeeded(string value, CancellationToken cancellationToken) { var isKycNeeded = await _kycStatusService.IsKycNeededAsync(_clientId); return(!isKycNeeded); }