Skip to content

pexcard/pex-sdk-dotnet

Repository files navigation

PEX SDK for .NET

About

The PEX SDK for .NET provides access to the PEX platform via the REST API. For more information on the API or to obtain your credentials, please sign up on the PEX Developer Center.

Included Packages

Package Description
PexCard.Api.Client.Core Contains interfaces, models, and extension methods use to describe and work with the PEX API
PexCard.Api.Client Contains interface implementations and error handling for working with the PEX API

Prerequisites

Versioning

All packages following the semantic versioning 2.0 convention.

Installation

  • dotnet CLI
    • dotnet add package PexCard.Api.Client
    • dotnet add package PexCard.Api.Client.Core

Configuration

ASP.NET Core

  1. Reference the following packages:
  2. Configure the IoC container:
Using configure options
public void ConfigureServices(IServiceCollection services)
{
    services.AddPexAuthClient(options =>
    {
        options.BaseUri = new Uri("https://oauth.pexcard.com");
        options.Timeout = TimeSpan.FromSeconds(30);
        options.LogLevelSuccess = LogLevel.Debug;
        options.LogLevelFailure = LogLevel.Warning;
        options.Retries = new PexRetryPolicyOptions
        {
            RetryLogLevel = LogLevel.Warning,
            TooManyRequests = new BackoffRetryPolicy(TimeSpan.FromSeconds(5), 7),
            Timeouts = new BackoffRetryPolicy(TimeSpan.FromSeconds(1), 2),
            ServerErrors = new BackoffRetryPolicy(TimeSpan.FromMilliseconds(100), 1)
        };
    });
    services.AddPexApiClient(options =>
    {
        options.BaseUri = new Uri("https://coreapi.pexcard.com");
        options.Timeout = TimeSpan.FromMinutes(3);
        options.LogLevelSuccess = LogLevel.Debug;
        options.LogLevelFailure = LogLevel.Warning;
        options.Retries = new PexRetryPolicyOptions
        {
            RetryLogLevel = LogLevel.Warning,
            TooManyRequests = new BackoffRetryPolicy(TimeSpan.FromSeconds(5), 7),
            Timeouts = new BackoffRetryPolicy(TimeSpan.FromSeconds(1), 2),
            ServerErrors = new BackoffRetryPolicy(TimeSpan.FromMilliseconds(100), 1)
        };
    });
}
Using configuration section
{
 "Pex": {
     "Auth": {
         "BaseUri": "https://oauth.pexcard.com",
         "Timeout": "00:00:30",
         "LogLevelSuccess": "Debug",
         "LogLevelFailure": "Warning",
         "Retries": {
             "RetryLogLevel": "Warning",
             "TooManyRequests": {
                 "Delay": "00:00:05",
                 "Retries": 7
             },
             "Timeouts": {
                 "Delay": "00:00:01",
                 "Retries": 2
             },
             "ServerErrors": {
                 "Delay": "00:00:00.100",
                 "Retries": 1
             }
         }
     },
     "Api": {
         "BaseUri": "https://coreapi.pexcard.com",
         "Timeout": "00:03:00",
         "LogLevelSuccess": "Debug",
         "LogLevelFailure": "Warning",
         "Retries": {
             "RetryLogLevel": "Warning",
             "TooManyRequests": {
                 "Delay": "00:00:05",
                 "Retries": 7
             },
             "Timeouts": {
                 "Delay": "00:00:01",
                 "Retries": 2
             },
             "ServerErrors": {
                 "Delay": "00:00:00.100",
                 "Retries": 1
             }
         }
     }
 }
}
public void ConfigureServices(IServiceCollection services)
{
     services.AddPexAuthClient(Configuration.GetSection("Pex:Auth"));
     services.AddPexApiClient(Configuration.GetSection("Pex:Api"));
}
  1. Inject an instance of IPexAuthClient or IPexApiClient into the class in which you want to use it.

Examples

Support

Problems

Please create an issue tagged with bug including the following information:

  • Repro Steps
  • Expected Result
  • Actual Result
  • Package Version
  • Operating System

Questions

Please create an issue tagged with question.

Enhancement Requests

Please create an issue tagged with enhancement.