Skip to content

Commit

Permalink
add PreSendConfigure option
Browse files Browse the repository at this point in the history
  • Loading branch information
cuteribs committed Aug 29, 2023
1 parent f1926d8 commit 2662cf6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/ApiTester/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Veracode.ApiClients.Applications.Api;
using Veracode.ApiClients.ApplicationsApi;
using Veracode.ApiClients.Helper;
using Veracode.ApiClients.IdentityApi;
using Veracode.ApiClients.SCAAgent.Api;
using Veracode.ApiClients.SCAAgent.Api.Patches;
using Veracode.ApiClients.SCAAgentApi;
using Veracode.ApiClients.SCAAgentApi.Patches;
using Veracode.ApiClients.SummaryReportApi;

namespace ApiTester;
Expand Down Expand Up @@ -86,13 +86,13 @@ static void GetApplications()
static void GetSummaryReport(string appGuid)
{
ServiceCollection services = new();
services.AddApiClient<ISummaryReportApi, SummaryReportApi>(o =>
services.AddApiClient<ISummaryReportApiClient, SummaryReportApiClient>(o =>
{
Configuration.Bind("VeracodeClientOptions", o);
o.BaseUri = new("https://api.veracode.com");
});
var serviceProvider = services.BuildServiceProvider();
var client = serviceProvider.GetRequiredService<ISummaryReportApi>();
var client = serviceProvider.GetRequiredService<ISummaryReportApiClient>();

var response = client.GetSummaryReport(appGuid);
var result = response;
Expand Down
2 changes: 2 additions & 0 deletions src/Veracode.ApiClients.Helper/ApiClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ protected override Task<HttpResponseMessage> SendAsync(
CancellationToken cancellationToken
)
{
_options.PreSendConfigure?.Invoke(request);

var uri = request.RequestUri!;
var authorization = GenerateAuthorization(
_options.ApiId,
Expand Down
6 changes: 5 additions & 1 deletion src/Veracode.ApiClients.Helper/ApiClientOptions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
using System.Net.Http;

namespace Veracode.ApiClients.Helper;

#nullable disable
public class ApiClientOptions
{
#nullable disable
public string ApiId { get; set; }
public string ApiKey { get; set; }
public Uri BaseUri { get; set; }
#nullable restore

public Action<HttpRequestMessage>? PreSendConfigure { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 2662cf6

Please sign in to comment.