Skip to content

Latest commit

 

History

History
98 lines (72 loc) · 2.38 KB

README.md

File metadata and controls

98 lines (72 loc) · 2.38 KB

Courier .NET Library

fern shield NuGet Version

The official Courier C# library, supporting .NET Standard, .NET Core, and .NET Framework.

Installation

Using the .NET Core command-line interface (CLI) tools:

dotnet add package Courier.Client

Using the NuGet Command Line Interface (CLI):

nuget install Courier.Client

Documentation

API reference documentation is available here.

Usage

Below are code snippets of how you can use the C# SDK.

using Courier.Client;

Courier courier = new Courier("YOUR_API_KEY")
Agent agent = courier.SendAsync(
    new SendMessageRequest {
        ...
    }
);

Exception Handling

When the API returns a non-zero status code, (4xx or 5xx response), a subclass of CourierException will be thrown:

using Courier.Client;

try {
  courier.SendAsync(...);
} catch (CourierException e) {
  System.Console.WriteLine(e.Message)
  System.Console.WriteLine(e.StatusCode)
}

Advanced

Retries

429 Rate Limit, and >=500 Internal errors will all be retried twice with exponential backoff. You can override this behavior globally or per-request.

var courier = new Courier("...", new ClientOptions {
    MaxRetries = 1 // Only retry once
});

Timeouts

The SDK defaults to a 60s timeout. You can override this behaviour globally or per-request.

var courier = new Courier("...", new ClientOptions {
    TimeoutInSeconds = 20 // Lower timeout
});

HTTP Client

You can override the HttpClient by passing in ClientOptions.

var courier = new Courier("YOUR_API_KEY", new ClientOptions {
    HttpClient = ... // Override the Http Client
    BaseURL = ... // Override the Base URL
})

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to Courier it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!