Skip to content

unified-to/unified-csharp-sdk

Repository files navigation

Installation

dotnet add package UnifiedTo

SDK Example Usage

Example

using UnifiedTo;
using UnifiedTo.Models.Components;

var sdk = new UnifiedToSDK(security: new Security() {
    Jwt = "<YOUR_API_KEY_HERE>",
});

var res = await sdk.Accounting.CreateAccountingAccountAsync(
    accountingAccount: new AccountingAccount() {},
    connectionId: "<id>"
);

// handle response

Available Resources and Operations

Available methods

Server Selection

Select Server by Index

You can override the default server globally by passing a server index to the serverIndex: int optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

# Server Description
0 https://api.unified.to North American data region
1 https://api-eu.unified.to European data region
2 https://api-au.unified.to Australian data region

Example

using UnifiedTo;
using UnifiedTo.Models.Components;

var sdk = new UnifiedToSDK(
    serverIndex: 2,
    security: new Security() {
        Jwt = "<YOUR_API_KEY_HERE>",
    }
);

var res = await sdk.Accounting.CreateAccountingAccountAsync(
    accountingAccount: new AccountingAccount() {},
    connectionId: "<id>"
);

// handle response

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:

using UnifiedTo;
using UnifiedTo.Models.Components;

var sdk = new UnifiedToSDK(
    serverUrl: "https://api-au.unified.to",
    security: new Security() {
        Jwt = "<YOUR_API_KEY_HERE>",
    }
);

var res = await sdk.Accounting.CreateAccountingAccountAsync(
    accountingAccount: new AccountingAccount() {},
    connectionId: "<id>"
);

// handle response

Summary

Unified.to API: One API to Rule Them All

Table of Contents

SDK Installation

NuGet

To add the NuGet package to a .NET project:

dotnet add package UnifiedTo

Locally

To add a reference to a local instance of the SDK in a .NET project:

dotnet add reference UnifiedTo/UnifiedTo.csproj

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
Jwt apiKey API key

You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:

using UnifiedTo;
using UnifiedTo.Models.Components;

var sdk = new UnifiedToSDK(security: new Security() {
    Jwt = "<YOUR_API_KEY_HERE>",
});

var res = await sdk.Accounting.CreateAccountingAccountAsync(
    accountingAccount: new AccountingAccount() {},
    connectionId: "<id>"
);

// handle response

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.

By default, an API error will raise a UnifiedTo.Models.Errors.SDKException exception, which has the following properties:

Property Type Description
Message string The error message
StatusCode int The HTTP status code
RawResponse HttpResponseMessage The raw HTTP response
Body string The response content

When custom error responses are specified for an operation, the SDK may also throw their associated exceptions. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the CreateAccountingAccountAsync method throws the following exceptions:

Error Type Status Code Content Type
UnifiedTo.Models.Errors.SDKException 4XX, 5XX */*

Example

using UnifiedTo;
using UnifiedTo.Models.Components;
using UnifiedTo.Models.Errors;

var sdk = new UnifiedToSDK(security: new Security() {
    Jwt = "<YOUR_API_KEY_HERE>",
});

try
{
    var res = await sdk.Accounting.CreateAccountingAccountAsync(
        accountingAccount: new AccountingAccount() {},
        connectionId: "<id>"
    );

    // handle response
}
catch (Exception ex)
{
    if (ex is UnifiedTo.Models.Errors.SDKException)
    {
        // Handle default exception
        throw;
    }
}

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy

About

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages