Skip to content

Latest commit

 

History

History

README.md

Sync for Commerce

Embedded accounting integrations for POS and eCommerce platforms.

Summary

Sync for Commerce: The API for Sync for Commerce.

Sync for Commerce automatically replicates and reconciles sales data from a merchant’s source PoS, Payments, and eCommerce systems into their accounting software. This eliminates manual processing by merchants and transforms their ability to run and grow their business.

Explore product | See our OpenAPI spec

Not seeing the endpoints you're expecting? We've reorganized our products, and you may be using a different version of Sync for Commerce.


Endpoints

Endpoints Description
Connections Create new and manage existing data connections for a company.
Sync Initiate data syncs and monitor their status.
Sync flow settings Control text and visibility settings for the Sync Flow.
Integrations Get a list of integrations supported by Sync for Commerce and their logos.
Advanced controls View and manage mapping configured for a company's commerce sync.

Table of Contents

SDK Installation

NuGet

To add the NuGet package to a .NET project:

dotnet add package Codat.Sync.Commerce

Locally

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

dotnet add reference Codat/Sync/Commerce/Codat.Sync.Commerce.csproj

Example Usage

SDK Example Usage

Example

using Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;

var sdk = new CodatSyncCommerce(authHeader: "Basic BASE_64_ENCODED(API_KEY)");

GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
    CommerceKey = "<value>",
    AccountingKey = "<value>",
};

var res = await sdk.Connections.GetSyncFlowUrlAsync(req);

// handle response

Available Resources and Operations

Available methods

Server Selection

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 Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;

var sdk = new CodatSyncCommerce(
    serverUrl: "https://api.codat.io",
    authHeader: "Basic BASE_64_ENCODED(API_KEY)"
);

GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
    CommerceKey = "<value>",
    AccountingKey = "<value>",
};

var res = await sdk.Connections.GetSyncFlowUrlAsync(req);

// handle response

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
AuthHeader apiKey API key

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

using Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;

var sdk = new CodatSyncCommerce(authHeader: "Basic BASE_64_ENCODED(API_KEY)");

GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
    CommerceKey = "<value>",
    AccountingKey = "<value>",
};

var res = await sdk.Connections.GetSyncFlowUrlAsync(req);

// handle response

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 Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;

var sdk = new CodatSyncCommerce(authHeader: "Basic BASE_64_ENCODED(API_KEY)");

GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
    CommerceKey = "<value>",
    AccountingKey = "<value>",
};

var res = await sdk.Connections.GetSyncFlowUrlAsync(
    retryConfig: new RetryConfig(
        strategy: RetryConfig.RetryStrategy.BACKOFF,
        backoff: new BackoffStrategy(
            initialIntervalMs: 1L,
            maxIntervalMs: 50L,
            maxElapsedTimeMs: 100L,
            exponent: 1.1
        ),
        retryConnectionErrors: false
    ),
    req
);

// handle response

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 Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;

var sdk = new CodatSyncCommerce(
    retryConfig: new RetryConfig(
        strategy: RetryConfig.RetryStrategy.BACKOFF,
        backoff: new BackoffStrategy(
            initialIntervalMs: 1L,
            maxIntervalMs: 50L,
            maxElapsedTimeMs: 100L,
            exponent: 1.1
        ),
        retryConnectionErrors: false
    ),
    authHeader: "Basic BASE_64_ENCODED(API_KEY)"
);

GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
    CommerceKey = "<value>",
    AccountingKey = "<value>",
};

var res = await sdk.Connections.GetSyncFlowUrlAsync(req);

// 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 Codat.Sync.Commerce.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 GetSyncFlowUrlAsync method throws the following exceptions:

Error Type Status Code Content Type
Codat.Sync.Commerce.Models.Errors.ErrorMessage 400, 401, 402, 403, 404, 429, 500, 503 application/json
Codat.Sync.Commerce.Models.Errors.SDKException 4XX, 5XX */*

Example

using Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;
using System;
using Codat.Sync.Commerce.Models.Errors;

var sdk = new CodatSyncCommerce(authHeader: "Basic BASE_64_ENCODED(API_KEY)");

try
{
    GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
        CommerceKey = "<value>",
        AccountingKey = "<value>",
    };

    var res = await sdk.Connections.GetSyncFlowUrlAsync(req);

    // handle response
}
catch (Exception ex)
{
    if (ex is ErrorMessage)
    {
        // Handle exception data
        throw;
    }
    else if (ex is Codat.Sync.Commerce.Models.Errors.SDKException)
    {
        // Handle default exception
        throw;
    }
}

Support

If you encounter any challenges while utilizing our SDKs, please don't hesitate to reach out for assistance. You can raise any issues by contacting your dedicated Codat representative or reaching out to our support team. We're here to help ensure a smooth experience for you.

Library generated by Speakeasy