diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 7e5d3ff6..8abe7c4b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -13,10 +13,11 @@ jobs: name: Build and analyze runs-on: windows-latest steps: - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - name: Set up JDK + uses: actions/setup-java@v4 with: - java-version: 1.11 + distribution: 'zulu' + java-version: 17 - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis diff --git a/TransactionProcessor.Client/ITransactionProcessorClient.cs b/TransactionProcessor.Client/ITransactionProcessorClient.cs index e7b2c80f..a8311d27 100644 --- a/TransactionProcessor.Client/ITransactionProcessorClient.cs +++ b/TransactionProcessor.Client/ITransactionProcessorClient.cs @@ -57,6 +57,16 @@ Task RedeemVoucher(String accessToken, RedeemVoucherRequest redeemVoucherRequest, CancellationToken cancellationToken); + Task CreateFloatForContractProduct(String accessToken, + Guid estateId, + CreateFloatForContractProductRequest createFloatForContractProductRequest, + CancellationToken cancellationToken); + + Task RecordFloatCreditPurchase(String accessToken, + Guid estateId, + RecordFloatCreditPurchaseRequest recordFloatCreditPurchaseRequest, + CancellationToken cancellationToken); + #endregion } } \ No newline at end of file diff --git a/TransactionProcessor.Client/TransactionProcessorClient.cs b/TransactionProcessor.Client/TransactionProcessorClient.cs index 5e141500..67e20ad8 100644 --- a/TransactionProcessor.Client/TransactionProcessorClient.cs +++ b/TransactionProcessor.Client/TransactionProcessorClient.cs @@ -363,6 +363,69 @@ public async Task RedeemVoucher(String accessToken, return response; } + public async Task CreateFloatForContractProduct(String accessToken, Guid estateId, CreateFloatForContractProductRequest createFloatForContractProductRequest, CancellationToken cancellationToken){ + CreateFloatForContractProductResponse response = null; + + String requestUri = $"{this.BaseAddress}/api/estates/{estateId}/floats"; + + try + { + String requestSerialised = JsonConvert.SerializeObject(createFloatForContractProductRequest); + + StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + String content = await this.HandleResponse(httpResponse, cancellationToken); + + // call was successful so now deserialise the body to the response object + response = JsonConvert.DeserializeObject(content); + } + catch (Exception ex) + { + // An exception has occurred, add some additional information to the message + Exception exception = new Exception("Error creating contract product float.", ex); + + throw exception; + } + + return response; + } + + public async Task RecordFloatCreditPurchase(String accessToken, Guid estateId, RecordFloatCreditPurchaseRequest recordFloatCreditPurchaseRequest, CancellationToken cancellationToken){ + String requestUri = $"{this.BaseAddress}/api/estates/{estateId}/floats"; + + try + { + String requestSerialised = JsonConvert.SerializeObject(recordFloatCreditPurchaseRequest); + + StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PutAsync(requestUri, httpContent, cancellationToken); + + // Process the response + await this.HandleResponse(httpResponse, cancellationToken); + + } + catch (Exception ex) + { + // An exception has occurred, add some additional information to the message + Exception exception = new Exception("Error crediting contract product float.", ex); + + throw exception; + } + } + #endregion } } \ No newline at end of file