Skip to content

apideck-libraries/sdk-csharp

Repository files navigation

ApideckUnifySdk

Developer-friendly & type-safe Csharp SDK specifically catered to leverage ApideckUnifySdk API.

Summary

Apideck: The Apideck OpenAPI Spec: SDK Optimized

For more information about the API: Apideck Developer Docs

Table of Contents

SDK Installation

NuGet

To add the NuGet package to a .NET project:

dotnet add package ApideckUnifySdk

Locally

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

dotnet add reference src/ApideckUnifySdk/ApideckUnifySdk.csproj

SDK Example Usage

Example

using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Requests;
using System.Collections.Generic;

var sdk = new Apideck(
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    apiKey: "<YOUR_BEARER_TOKEN_HERE>"
);

AccountingTaxRatesAllRequest req = new AccountingTaxRatesAllRequest() {
    ServiceId = "salesforce",
    Filter = new TaxRatesFilter() {
        Assets = true,
        Equity = true,
        Expenses = true,
        Liabilities = true,
        Revenue = true,
    },
    PassThrough = new Dictionary<string, object>() {
        { "search", "San Francisco" },
    },
    Fields = "id,updated_at",
};

AccountingTaxRatesAllResponse? res = await sdk.Accounting.TaxRates.ListAsync(req);

while(res != null)
{
    // handle items

    res = await res.Next!();
}

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
ApiKey http HTTP Bearer

To authenticate with the API the ApiKey parameter must be set when initializing the SDK client instance. For example:

using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Requests;
using System.Collections.Generic;

var sdk = new Apideck(
    apiKey: "<YOUR_BEARER_TOKEN_HERE>",
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"
);

AccountingTaxRatesAllRequest req = new AccountingTaxRatesAllRequest() {
    ServiceId = "salesforce",
    Filter = new TaxRatesFilter() {
        Assets = true,
        Equity = true,
        Expenses = true,
        Liabilities = true,
        Revenue = true,
    },
    PassThrough = new Dictionary<string, object>() {
        { "search", "San Francisco" },
    },
    Fields = "id,updated_at",
};

AccountingTaxRatesAllResponse? res = await sdk.Accounting.TaxRates.ListAsync(req);

while(res != null)
{
    // handle items

    res = await res.Next!();
}

Available Resources and Operations

Available methods
  • Get - Get Aged Creditors
  • Get - Get Aged Debtors
  • Get - Get BalanceSheet
  • List - List Bank Feed Accounts
  • Create - Create Bank Feed Account
  • Get - Get Bank Feed Account
  • Update - Update Bank Feed Account
  • Delete - Delete Bank Feed Account
  • List - List Bank Feed Statements
  • Create - Create Bank Feed Statement
  • Get - Get Bank Feed Statement
  • Update - Update Bank Feed Statement
  • Delete - Delete Bank Feed Statement
  • List - List Bill Payments
  • Create - Create Bill Payment
  • Get - Get Bill Payment
  • Update - Update Bill Payment
  • Delete - Delete Bill Payment
  • List - List Categories
  • Get - Get Category
  • Get - Get company info
  • List - List Credit Notes
  • Create - Create Credit Note
  • Get - Get Credit Note
  • Update - Update Credit Note
  • Delete - Delete Credit Note
  • List - List Departments
  • Create - Create Department
  • Get - Get Department
  • Update - Update Department
  • Delete - Delete Department
  • List - List Invoice Items
  • Create - Create Invoice Item
  • Get - Get Invoice Item
  • Update - Update Invoice Item
  • Delete - Delete Invoice Item
  • List - List Journal Entries
  • Create - Create Journal Entry
  • Get - Get Journal Entry
  • Update - Update Journal Entry
  • Delete - Delete Journal Entry
  • List - List Ledger Accounts
  • Create - Create Ledger Account
  • Get - Get Ledger Account
  • Update - Update Ledger Account
  • Delete - Delete Ledger Account
  • Get - Get Profit and Loss
  • List - List Purchase Orders
  • Create - Create Purchase Order
  • Get - Get Purchase Order
  • Update - Update Purchase Order
  • Delete - Delete Purchase Order
  • List - List Subsidiaries
  • Create - Create Subsidiary
  • Get - Get Subsidiary
  • Update - Update Subsidiary
  • Delete - Delete Subsidiary
  • List - List Tracking Categories
  • Create - Create Tracking Category
  • Get - Get Tracking Category
  • Update - Update Tracking Category
  • Delete - Delete Tracking Category
  • List - List Applications
  • Create - Create Application
  • Get - Get Application
  • Update - Update Application
  • Delete - Delete Application
  • Get - Get API Resource Coverage
  • Get - Get API Resource
  • Get - Get Connector Doc content
  • Get - Get Connector Resource
  • List - List Connectors
  • Get - Get Connector
  • List - List custom objects
  • Create - Create custom object
  • Get - Get custom object
  • Update - Update custom object
  • Delete - Delete custom object
  • List - List custom object schemas
  • Create - Create custom object schema
  • Get - Get custom object schema
  • Update - Update custom object schema
  • Delete - Delete custom object schema
  • List - List opportunities
  • Create - Create opportunity
  • Get - Get opportunity
  • Update - Update opportunity
  • Delete - Delete opportunity
  • List - List Customers
  • Get - Get Customer
  • List - List Orders
  • Get - Get Order
  • List - List Products
  • Get - Get Product
  • Get - Get Store
  • List - List DriveGroups
  • Create - Create DriveGroup
  • Get - Get DriveGroup
  • Update - Update DriveGroup
  • Delete - Delete DriveGroup
  • List - List SharedLinks
  • Create - Create Shared Link
  • Get - Get Shared Link
  • Update - Update Shared Link
  • Delete - Delete Shared Link
  • Create - Start Upload Session
  • Get - Get Upload Session
  • Upload - Upload part of File to Upload Session
  • Delete - Abort Upload Session
  • Finish - Finish Upload Session
  • List - List Departments
  • Create - Create Department
  • Get - Get Department
  • Update - Update Department
  • Delete - Delete Department
  • List - List Employee Payrolls
  • Get - Get Employee Payroll
  • List - List Employee Schedules
  • List - List Payroll
  • Get - Get Payroll
  • List - List Time Off Requests
  • Create - Create Time Off Request
  • Get - Get Time Off Request
  • Update - Update Time Off Request
  • Delete - Delete Time Off Request
  • List - List Collections
  • Get - Get Collection
  • Update - Update consent state
  • List - Get consent records
  • List - List connection custom mappings
  • List - Get all connections
  • Get - Get connection
  • Update - Update connection
  • Delete - Deletes a connection
  • Imports - Import connection
  • Token - Authorize Access Token
  • List - Get resource settings
  • Update - Update settings
  • List - Consumer request counts
  • State - Create Callback State
  • List - Get resource custom fields
  • List - List custom mappings
  • List - Get all consumer request logs
  • State - Validate Connection State
  • List - List webhook subscriptions
  • Create - Create webhook subscription
  • Get - Get webhook subscription
  • Update - Update webhook subscription
  • Delete - Delete webhook subscription

Pagination

Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the returned response object will have a Next method that can be called to pull down the next group of results. If the return value of Next is null, then there are no more pages to be fetched.

Here's an example of one such pagination call:

using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Requests;
using System.Collections.Generic;

var sdk = new Apideck(
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    apiKey: "<YOUR_BEARER_TOKEN_HERE>"
);

AccountingTaxRatesAllRequest req = new AccountingTaxRatesAllRequest() {
    ServiceId = "salesforce",
    Filter = new TaxRatesFilter() {
        Assets = true,
        Equity = true,
        Expenses = true,
        Liabilities = true,
        Revenue = true,
    },
    PassThrough = new Dictionary<string, object>() {
        { "search", "San Francisco" },
    },
    Fields = "id,updated_at",
};

AccountingTaxRatesAllResponse? res = await sdk.Accounting.TaxRates.ListAsync(req);

while(res != null)
{
    // handle items

    res = await res.Next!();
}

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply pass a RetryConfig to the call:

using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Requests;
using System.Collections.Generic;

var sdk = new Apideck(
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    apiKey: "<YOUR_BEARER_TOKEN_HERE>"
);

AccountingTaxRatesAllRequest req = new AccountingTaxRatesAllRequest() {
    ServiceId = "salesforce",
    Filter = new TaxRatesFilter() {
        Assets = true,
        Equity = true,
        Expenses = true,
        Liabilities = true,
        Revenue = true,
    },
    PassThrough = new Dictionary<string, object>() {
        { "search", "San Francisco" },
    },
    Fields = "id,updated_at",
};

AccountingTaxRatesAllResponse? res = await sdk.Accounting.TaxRates.ListAsync(
    retryConfig: new RetryConfig(
        strategy: RetryConfig.RetryStrategy.BACKOFF,
        backoff: new BackoffStrategy(
            initialIntervalMs: 1L,
            maxIntervalMs: 50L,
            maxElapsedTimeMs: 100L,
            exponent: 1.1
        ),
        retryConnectionErrors: false
    ),
    request: req
);

while(res != null)
{
    // handle items

    res = await res.Next!();
}

If you'd like to override the default retry strategy for all operations that support retries, you can use the RetryConfig optional parameter when intitializing the SDK:

using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Requests;
using System.Collections.Generic;

var sdk = new Apideck(
    retryConfig: new RetryConfig(
        strategy: RetryConfig.RetryStrategy.BACKOFF,
        backoff: new BackoffStrategy(
            initialIntervalMs: 1L,
            maxIntervalMs: 50L,
            maxElapsedTimeMs: 100L,
            exponent: 1.1
        ),
        retryConnectionErrors: false
    ),
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    apiKey: "<YOUR_BEARER_TOKEN_HERE>"
);

AccountingTaxRatesAllRequest req = new AccountingTaxRatesAllRequest() {
    ServiceId = "salesforce",
    Filter = new TaxRatesFilter() {
        Assets = true,
        Equity = true,
        Expenses = true,
        Liabilities = true,
        Revenue = true,
    },
    PassThrough = new Dictionary<string, object>() {
        { "search", "San Francisco" },
    },
    Fields = "id,updated_at",
};

AccountingTaxRatesAllResponse? res = await sdk.Accounting.TaxRates.ListAsync(req);

while(res != null)
{
    // handle items

    res = await res.Next!();
}

Error Handling

ApideckError is the base exception class for all HTTP error responses. It has the following properties:

Property Type Description
Message string Error message
Request HttpRequestMessage HTTP request object
Response HttpResponseMessage HTTP response object

Some exceptions in this SDK include an additional Payload field, which will contain deserialized custom error data when present. Possible exceptions are listed in the Error Classes section.

Example

using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Errors;
using ApideckUnifySdk.Models.Requests;
using System.Collections.Generic;

var sdk = new Apideck(
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    apiKey: "<YOUR_BEARER_TOKEN_HERE>"
);

try
{
    AccountingTaxRatesAllRequest req = new AccountingTaxRatesAllRequest() {
        ServiceId = "salesforce",
        Filter = new TaxRatesFilter() {
            Assets = true,
            Equity = true,
            Expenses = true,
            Liabilities = true,
            Revenue = true,
        },
        PassThrough = new Dictionary<string, object>() {
            { "search", "San Francisco" },
        },
        Fields = "id,updated_at",
    };

    AccountingTaxRatesAllResponse? res = await sdk.Accounting.TaxRates.ListAsync(req);

    while(res != null)
    {
        // handle items

        res = await res.Next!();
    }
}
catch (ApideckError ex)  // all SDK exceptions inherit from ApideckError
{
    // ex.ToString() provides a detailed error message
    System.Console.WriteLine(ex);

    // Base exception fields
    HttpRequestMessage request = ex.Request;
    HttpResponseMessage response = ex.Response;
    var statusCode = (int)response.StatusCode;
    var responseBody = ex.Body;

    if (ex is BadRequestResponse) // different exceptions may be thrown depending on the method
    {
        // Check error data fields
        BadRequestResponsePayload payload = ex.Payload;
        double StatusCode = payload.StatusCode;
        string Error = payload.Error;
        // ...
    }

    // An underlying cause may be provided
    if (ex.InnerException != null)
    {
        Exception cause = ex.InnerException;
    }
}
catch (System.Net.Http.HttpRequestException ex)
{
    // Check ex.InnerException for Network connectivity errors
}

Error Classes

Primary exceptions:

Less common exceptions (2)

* Refer to the relevant documentation to determine whether an exception applies to a specific operation.

Server Selection

Override Server URL Per-Client

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

using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Requests;
using System.Collections.Generic;

var sdk = new Apideck(
    serverUrl: "https://unify.apideck.com",
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    apiKey: "<YOUR_BEARER_TOKEN_HERE>"
);

AccountingTaxRatesAllRequest req = new AccountingTaxRatesAllRequest() {
    ServiceId = "salesforce",
    Filter = new TaxRatesFilter() {
        Assets = true,
        Equity = true,
        Expenses = true,
        Liabilities = true,
        Revenue = true,
    },
    PassThrough = new Dictionary<string, object>() {
        { "search", "San Francisco" },
    },
    Fields = "id,updated_at",
};

AccountingTaxRatesAllResponse? res = await sdk.Accounting.TaxRates.ListAsync(req);

while(res != null)
{
    // handle items

    res = await res.Next!();
}

Override Server URL Per-Operation

The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:

using ApideckUnifySdk;
using ApideckUnifySdk.Models.Components;
using ApideckUnifySdk.Models.Requests;
using System;

var sdk = new Apideck(
    consumerId: "test-consumer",
    appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    apiKey: "<YOUR_BEARER_TOKEN_HERE>"
);

AccountingAttachmentsUploadRequest req = new AccountingAttachmentsUploadRequest() {
    ReferenceType = AttachmentReferenceType.Invoice,
    ReferenceId = "123456",
    XApideckMetadata = "{\"name\":\"document.pdf\",\"description\":\"Invoice attachment\"}",
    ServiceId = "salesforce",
    RequestBody = System.Text.Encoding.UTF8.GetBytes("0x506D4BD16D"),
};

var res = await sdk.Accounting.Attachments.UploadAsync(
    request: req,
    serverUrl: "https://upload.apideck.com"
);

// handle response

Development

Maturity

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. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages