cmos 0.0.3
dotnet add package cmos --version 0.0.3
NuGet\Install-Package cmos -Version 0.0.3
<PackageReference Include="cmos" Version="0.0.3" />
<PackageVersion Include="cmos" Version="0.0.3" />
<PackageReference Include="cmos" />
paket add cmos --version 0.0.3
#r "nuget: cmos, 0.0.3"
#:package cmos@0.0.3
#addin nuget:?package=cmos&version=0.0.3
#tool nuget:?package=cmos&version=0.0.3
cmos
SDK Example Usage
Example
using cmos;
using cmos.Models.Components;
using cmos.Models.Requests;
var sdk = new Cmos(security: new Security() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
});
var res = await sdk.AccountOperations.GetAccountBalanceAsync(
accountId: "POL-789123",
includeHolds: false,
currency: Currency.Zar
);
// handle response
Authentication
Per-Client Security Schemes
This SDK supports the following security schemes globally:
| Name | Type | Scheme |
|---|---|---|
BearerAuth |
http | HTTP Bearer |
ApiKeyAuth |
apiKey | API key |
You can set the security parameters through the security optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
using cmos;
using cmos.Models.Components;
using cmos.Models.Requests;
var sdk = new Cmos(security: new Security() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
});
var res = await sdk.AccountOperations.GetAccountBalanceAsync(
accountId: "POL-789123",
includeHolds: false,
currency: Currency.Zar
);
// 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 cmos.Models.Errors.APIException 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 GetAccountBalanceAsync method throws the following exceptions:
| Error Type | Status Code | Content Type |
|---|---|---|
| cmos.Models.Errors.ErrorResponse | 400, 401, 404 | application/json |
| cmos.Models.Errors.ErrorResponse | 500, 503 | application/json |
| cmos.Models.Errors.APIException | 4XX, 5XX | */* |
Example
using cmos;
using cmos.Models.Components;
using cmos.Models.Errors;
using cmos.Models.Requests;
var sdk = new Cmos(security: new Security() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
});
try
{
var res = await sdk.AccountOperations.GetAccountBalanceAsync(
accountId: "POL-789123",
includeHolds: false,
currency: Currency.Zar
);
// handle response
}
catch (Exception ex)
{
if (ex is ErrorResponse)
{
// Handle exception data
throw;
}
else if (ex is ErrorResponse)
{
// Handle exception data
throw;
}
else if (ex is cmos.Models.Errors.APIException)
{
// 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 | Description |
|---|---|---|
| 0 | https://api.oldmutual.com/cmos/v1 |
Production CMOS API |
| 1 | https://api-staging.oldmutual.com/cmos/v1 |
Staging Environment |
| 2 | https://api-sandbox.oldmutual.com/cmos/v1 |
Sandbox Environment (Test Data) |
Example
using cmos;
using cmos.Models.Components;
using cmos.Models.Requests;
var sdk = new Cmos(
serverIndex: 2,
security: new Security() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
}
);
var res = await sdk.AccountOperations.GetAccountBalanceAsync(
accountId: "POL-789123",
includeHolds: false,
currency: Currency.Zar
);
// 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 cmos;
using cmos.Models.Components;
using cmos.Models.Requests;
var sdk = new Cmos(
serverUrl: "https://api-sandbox.oldmutual.com/cmos/v1",
security: new Security() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
}
);
var res = await sdk.AccountOperations.GetAccountBalanceAsync(
accountId: "POL-789123",
includeHolds: false,
currency: Currency.Zar
);
// 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.