Skip to main content

1E SDK

Code structure

Internally the SDK code divides into several sections:

APIs

Each class in this namespace represents a single controller from the Consumer API. Each of these classes has methods allowing you to perform every operation the controller allows.

These methods return ApiCallResponse objects.

Models

Models represent data going in and out of the Tachyon platform.

Model

Description

API

API models are high level wrappers that represent a result of an API call.

The ApiCallResponse class is the object returned by every single method you can call on the API classes and contains:

  • Success - a boolean flag indicating call success and based on the status code returned by the HTTP call

  • Errors - if the call was unsuccessful you'll receive the errors in this collection

  • ReceivedObject - if the call was successful the object received will be in this property - note this is a generic property, its type varies depending on the called method

  • ResponseStatusCode - from version 3.3 inclusive, if the HTTP call has finished (for example, there has not been an exception during the call, like a timeout) this property will have the status code that was returned.

Note

Some API methods have no return value. In this instance ReceivedObject may be empty (null), have a 'string' or 'boolean' type. Please check the documentation of the method you're calling for more informtion.

Send

Contains every model representing the data you send to the API, but never receive from it.

These are the classes to use when building the data to make API calls.

Receive

Contains every model representing the data you receive from the API, but not send to it.

These are the classes you receive inside the ApiCallResponse.ReceivedObject.

Common

Contains models that can be either sent to or received from the API.

In many cases the request and return data look exactly the same.

Auxiliary classes that define expression trees, sorting and filtering expressions etc. are in here as well.

Available customization interfaces

Interface

Description

ITransportProxy

ITransportProxy defines a contract for a class to perform all of the HTTP communication with the consumer API.

The Tachyon connector passes in amended (versioned) API root address to it right after it receives them and then use them for all of its HTTP calls.

This interface inherits IDisposable. The TachyonConnector will call its Dispose method when it itself is being disposed of.

Use this interface to fully customize HTTP communication, that is use webclient instead of httpclient.

Note

If you're using a custom implementation of this interface, take care of passing in the consumer name in the HTTP header.

IHttpClientManager

Use IHttpClientManager to customize the behavior of DefaultTransportProxy.

IHttpClientManager manages the lifecycle of the HttpClient object the default proxy uses.

The default client manager creates an HttpClient instance that uses default credentials. If this is not what you want, you should provide our own implementation of IHttpClientManager that will return HttpClient configured to suit your needs.

Note

The HttpClient returned by your implementation must be a fresh instance - meaning it must not have been used for making HTTP calls before. This is because the client has to be configured with the base address of the API etc. and those properties cannot be changed once even if a single HTTP call was made using the client.

ILogProxy

A rudimentary interface allowing you to receive logging from within the SDK.

Default implementations

The SDK contains default implementations for the transport proxy (class DefaultTransportProxy) and http client manager (class DefaultHttpClientManager).

DefaultTransportProxy

Default transport proxy is a class that uses a HttpClient, either created internally by DefaultHttpClientManager or created by a custom class that implements the IHttpClientManager interface and is passed in externally.

This class has two constructors:

  1. public DefaultTransportProxy(ILogProxy logger, string consumerId, string apiRootAddress)

  2. public DefaultTransportProxy(ILogProxy logger, string consumerId, IHttpClientManager clientManager)

The first constructor will use DefaultHttpClientManager to create a HttpClient. This means using default credentials.

The second constructor allows you to provide an object that implements IHttpclientManager, which will provide (and dispose of) the HttpClient object.

DefaultHttpClientManager

Default http client manager is a simple class that creates an HttpClient that uses default credentials and simply disposes of it when told to do so.

Tools

ErrorCreator

Error creator is a helper class containing two static methods allowing you to convert either HttpResponseMessage or an Exception to an Error object that you would receive in an ApiCallResponse object.