public void InreasePrimaryMarketInvestmentOk() { var investmentRequest = new IncreasePrimaryMarketInvestment() { Amount = 200 }; _zonkyApi.IncreasePrimaryMarketInvestmentAsync(1, investmentRequest, _tokenProvider.GetToken(), CancellationToken.None).GetAwaiter().GetResult(); }
/// <summary> /// Increase primary market investment /// </summary> /// <param name="investmentId">Investment Id</param> /// <param name="increaseInvestment">Primary market increase investment</param> /// <param name="authorizationToken"></param> /// <param name="ct"></param> /// <returns></returns> public async Task IncreasePrimaryMarketInvestmentAsync(int investmentId, IncreasePrimaryMarketInvestment increaseInvestment, AuthorizationToken authorizationToken, CancellationToken ct = default) { CheckAuthorizationToken(authorizationToken); using (var request = PrepareAuthorizedRequest($"/marketplace/investment/{investmentId}", new HttpMethod("PATCH"), authorizationToken).AddJsonContent(increaseInvestment, Settings)) using (var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead, ct).ConfigureAwait(false)) { await _resolverFactory.Create(Settings, true) .ConfigureStatusResponce(HttpStatusCode.OK, (message) => { }) .ConfigureStatusResponce(HttpStatusCode.BadRequest, (message) => throw new PrimaryMarketInvestmentException(investmentId, increaseInvestment, message)) .ConfigureDefaultResponce((message) => throw new ServerErrorException(message)) .ExtractDataAsync(response); } }
/// <summary> /// Primary market increase investment failed /// The input is invalid. /// Possible error codes are: /// CAPTCHA_REQUIRED - Captcha verification is required /// insufficientBalance - The user cannot invest because of a low wallet balance /// cancelled - The loan has been canceled /// withdrawn - The loan has been withdrawn by the borrower /// reservedInvestmentOnly - The user cannot invest without a reservation. The whole remaining investment is reserved for other users. /// overInvestment - The amount for investment is too high /// multipleInvestment - The user has already invested to this loan. Try increasing the investment instead /// alreadyCovered - The whole loan amount has been already covered /// </summary> /// <param name="investmentId"></param> /// <param name="increaseInvestment"></param> /// <param name="message"></param> public PrimaryMarketInvestmentException(int investmentId, IncreasePrimaryMarketInvestment increaseInvestment, HttpResponseMessage message) : base($"Increase primary market participation id {investmentId} - {increaseInvestment.ToString()} failed \r\n Server return \r\n {message.ToString()} \r\n with content { message.Content.ReadAsStringAsync().GetAwaiter().GetResult()}") { }
/// <summary> /// Increase primary market investment /// </summary> /// <param name="investmentId">Investment Id</param> /// <param name="increaseInvestment">Primary market increase investment</param> /// <param name="ct"></param> /// <returns></returns> public async Task IncreasePrimaryMarketInvestmentAsync(int investmentId, IncreasePrimaryMarketInvestment increaseInvestment, CancellationToken ct = default) { CheckTradingPrerequisites(); await HandleAuthorizedRequestAsync(() => ZonkyApi.IncreasePrimaryMarketInvestmentAsync(investmentId, increaseInvestment, AuthorizationToken, ct), ct).ConfigureAwait(false); }