.Net

Installation

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

1dotnet add package Mercoa.Client

Using the NuGet Command Line Interface (CLI):

1nuget install Mercoa.Client

Instantiation

Instantiate the SDK using the MercoaClient class. Note that all of the SDK methods are awaitable!

1using Mercoa;
2
3Mercoa mercoa = new Mercoa(
4 "YOUR_API_KEY"
5)

HTTP Client

You can override the HttpClient by passing in ClientOptions.

1mercoa = new Mercoa("YOUR_API_KEY", new ClientOptions{
2 HttpClient = ... // Override the Http Client
3 BaseURL = ... // Override the Base URL
4})

Exception Handling

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

1using Mercoa;
2
3try {
4 mercoa.Entity.Get(...);
5} catch (MercoaEerror e) {
6 System.Console.WriteLine(e.Message)
7 System.Console.WriteLine(e.StatusCode)
8}

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.

1var mercoa = new Mercoa("...", new ClientOptions{
2 MaxRetries = 1 // Only retry once
3});

Timeouts

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

1var mercoa = new Mercoa("...", new ClientOptions{
2 TimeoutInSeconds = 20 // Lower timeout
3});