FormanceSDK 1.1.0
dotnet add package FormanceSDK --version 1.1.0
NuGet\Install-Package FormanceSDK -Version 1.1.0
<PackageReference Include="FormanceSDK" Version="1.1.0" />
<PackageVersion Include="FormanceSDK" Version="1.1.0" />
<PackageReference Include="FormanceSDK" />
paket add FormanceSDK --version 1.1.0
#r "nuget: FormanceSDK, 1.1.0"
#addin nuget:?package=FormanceSDK&version=1.1.0
#tool nuget:?package=FormanceSDK&version=1.1.0
formance
SDK Example Usage
Example
using FormanceSDK;
using FormanceSDK.Models.Components;
var sdk = new Formance(security: new Security() {
ClientID = "<YOUR_CLIENT_ID_HERE>",
ClientSecret = "<YOUR_CLIENT_SECRET_HERE>",
});
var res = await sdk.GetVersionsAsync();
// 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 FormanceSDK.Models.Errors.SDKException
exception, which has the following properties:
Property | Type | Description |
---|---|---|
Message |
string | The error message |
Request |
HttpRequestMessage | The HTTP request |
Response |
HttpResponseMessage | The HTTP response |
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 GetInfoAsync
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
FormanceSDK.Models.Errors.ErrorResponse | default | application/json |
FormanceSDK.Models.Errors.SDKException | 4XX, 5XX | */* |
Example
using FormanceSDK;
using FormanceSDK.Models.Components;
using FormanceSDK.Models.Errors;
var sdk = new Formance(security: new Security() {
ClientID = "<YOUR_CLIENT_ID_HERE>",
ClientSecret = "<YOUR_CLIENT_SECRET_HERE>",
});
try
{
var res = await sdk.Ledger.V1.GetInfoAsync();
// handle response
}
catch (Exception ex)
{
if (ex is Models.Errors.ErrorResponse)
{
// Handle exception data
throw;
}
else if (ex is FormanceSDK.Models.Errors.SDKException)
{
// Handle default exception
throw;
}
}
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 | Variables | Description |
---|---|---|---|
0 | http://localhost |
local server | |
1 | https://{organization}.{environment}.formance.cloud |
organization <br/>environment |
A per-organization and per-environment API |
If the selected server has variables, you may override its default values through the additional parameters made available in the SDK constructor:
Variable | Parameter | Supported Values | Default | Description |
---|---|---|---|---|
organization |
organization: string |
string | "orgID-stackID" |
The organization name. Defaults to a generic organization. |
environment |
environment: FormanceSDK.Models.ServerEnvironment |
- "eu.sandbox" <br/>- "sandbox" <br/>- "eu-west-1" <br/>- "us-east-1" |
"eu.sandbox" |
The environment name. Defaults to the production environment. |
Example
using FormanceSDK;
using FormanceSDK.Models.Components;
var sdk = new Formance(
serverIndex: 1,
organization: "<value>",
environment: "us-east-1",
security: new Security() {
ClientID = "<YOUR_CLIENT_ID_HERE>",
ClientSecret = "<YOUR_CLIENT_SECRET_HERE>",
}
);
var res = await sdk.GetVersionsAsync();
// 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 FormanceSDK;
using FormanceSDK.Models.Components;
var sdk = new Formance(
serverUrl: "https://orgID-stackID.eu.sandbox.formance.cloud",
security: new Security() {
ClientID = "<YOUR_CLIENT_ID_HERE>",
ClientSecret = "<YOUR_CLIENT_SECRET_HERE>",
}
);
var res = await sdk.GetVersionsAsync();
// handle response
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
ClientID <br/>ClientSecret |
oauth2 | OAuth2 Client Credentials Flow |
You can set the security parameters through the security
optional parameter when initializing the SDK client instance. For example:
using FormanceSDK;
using FormanceSDK.Models.Components;
var sdk = new Formance(security: new Security() {
ClientID = "<YOUR_CLIENT_ID_HERE>",
ClientSecret = "<YOUR_CLIENT_SECRET_HERE>",
});
var res = await sdk.GetVersionsAsync();
// handle response
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- newtonsoft.json (>= 13.0.3)
- nodatime (>= 3.1.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.