Setting up the API Client
Setting the up the API client is a simple process. The API client is a .NET Standard 2.0 library, so it can be used in any .NET Core or .NET Framework application.
Installation
When you start integration with the Pattinson Partner Agent API you will be provided with access to a NuGet feed that contains the API client. You will need to add this feed to your NuGet configuration in order to install the API client.
There are several ways to do this, but the way we recommend is using a nuget.config file in the root of your
solution. This will allow you to share the configuration across all projects in your solution. The contents of the file
should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="pattinson" value="[url-to-feed]" />
</packageSources>
<packageSourceCredentials>
<pattinson>
<add key="Username" value="[nuget-user-name]" />
<add key="ClearTextPassword" value="[nuget-user-password]" />
</pattinson>
</packageSourceCredentials>
</configuration>
Configuration
NET Core
With .NET Core we use the PAccess.PartnerAgents.ApiClient.DependencyInjection package to register the API client with
the dependency injection container.
using PAccess.PartnerAgents.ApiClient.DependencyInjection;
// ...
var services = new ServiceCollection();
services.AddPartnerAgentApiClient(settings =>
{
settings.ClientId = "[client-id]";
settings.ClientSecret = "[client-secret]";
settings.BaseUrl = "[endpoint-url]";
});
var serviceProvider = services.BuildServiceProvider();
var apiClient = serviceProvider.GetRequiredService<IPartnerAgentApiClient>();
// ...
From here, you can use the IPartnerAgentApiClient to
make calls to the API.
NET Framework
With .NET Framework we use the PAccess.PartnerAgents.ApiClient package more directly to create an instance of the API
client.
var factory = new PartnerAgentApiClientFactory();
var client = factory.CreateApiClient(settings =>
{
settings.ClientId = "[client-id]";
settings.ClientSecret = "[client-secret]";
settings.BaseUrl = "[endpoint-url]";
});
From here, you can use the IPartnerAgentApiClient to
make calls to the API.
You can register either the IPartnerAgentApiClient or
the IPartnerAgentApiClientFactory with
your dependency injection
container if you wish, based on your needs.
Proxy configuration
If you need to configure a proxy for the API client to use, you can do so by setting the Proxy property on the
PartnerAgentApiClientSettings object.
For example:
var factory = new PartnerAgentApiClientFactory();
var client = factory.CreateApiClient(settings =>
{
settings.ClientId = "[client-id]";
settings.ClientSecret = "[client-secret]";
settings.BaseUrl = "[endpoint-url]";
settings.Proxy = new WebProxy("[proxy-url]", true)
{
Credentials = new NetworkCredential("[proxy-user-name]", "[proxy-password]")
};
});
You can also disable proxy certificate validation by setting the DisableProxyCertificateValidation property on the
PartnerAgentApiClientSettings object to true.