Table of Contents

Interface IApi

Namespace
Geotab.Checkmate
Assembly
Geotab.Checkmate.ObjectModel.dll

Used to make API calls against a MyGeotab web server. This object is typically used when using the API from a Microsoft .Net language, like C#, VB.Net or managed C++. It makes it easy to invoke the various methods and receive the results. It also automates of some tasks such as handling a database that was moved from one server to another or credentials expiring. This class is thread safe.

public interface IApi

Remarks

The maximum number of concurrent connections per server is 64, provided by the default HttpMessageHandler. It can be increased/decreased by providing a custom instance of HttpMessageHandler.

Properties

Database

Gets or sets the specific database on the server to which the API call is being made.

string Database { get; set; }

Property Value

string

A string database name.

LoginResult

Gets or sets the result of the login request.

LoginResult? LoginResult { get; set; }

Property Value

LoginResult

LoginResult

Password

Sets the user's password.

string Password { set; }

Property Value

string

string

Server

Gets or sets the name of the server that the API call is being made to.

string Server { get; set; }

Property Value

string

string

SessionId

Gets or sets the token generated from the authentication call which can be used to make the API call instead of the password.

string? SessionId { get; set; }

Property Value

string

string

Timeout

Gets or sets the timeout for the requests in milliseconds.

int Timeout { get; set; }

Property Value

int

int

UserName

Gets or sets the username (typically an email address) that identifies the user being authenticated.

string UserName { get; set; }

Property Value

string

string

Methods

Authenticate()

Authenticate the user. This method is deprecated. Rather use AuthenticateAsync(CancellationToken)

[Obsolete("Asynchronous AuthenticateAsync method is better for performance.")]
void Authenticate()

Remarks

The method is marked as Obsolete.

AuthenticateAsync(CancellationToken)

Authenticate the user in an async call.

Task AuthenticateAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The CancellationToken used to single that the request should be cancelled.

Returns

Task

A Task which is a result of calling AuthenticateImplAsync.

CallAsync<T>(string, object?, CancellationToken)

Make an API request using a non-generic type method. This is an async call.

Task<T?> CallAsync<T>(string method, object? parameters = null, CancellationToken cancellationToken = default)

Parameters

method string

The method name to call.

parameters object

An anonymous object containing properties (param name) with values (param value). Property name must match that of the method parameter.

cancellationToken CancellationToken

The CancellationToken used to single that the request should be cancelled.

Returns

Task<T>

The result for queries and null for non queries (Add, Set, Remove).

Type Parameters

T

The return object type.

CallAsync<T>(string, Type, object?, CancellationToken)

Make an API call using a generic type method. Generic type methods are methods that have the same name but take a specific object type. This is an async call.

Task<T?> CallAsync<T>(string method, Type type, object? parameters = null, CancellationToken cancellationToken = default)

Parameters

method string

The method name to call.

type Type

The Type use in the generic api call.

parameters object

An anonymous object containing properties (param name) with values (param value). Property name must match that of the method parameter.

cancellationToken CancellationToken

The CancellationToken used to single that the request should be cancelled.

Returns

Task<T>

The result for queries and null for non queries (Add, Set, Remove).

Type Parameters

T

The return object type.

Call<T>(string, object?)

Make an API request using a non-generic type method.

[Obsolete("Asynchronous CallAsync method is better for performance.")]
T? Call<T>(string method, object? parameters = null)

Parameters

method string

The method name to call.

parameters object

An anonymous object containing properties (param name) with values (param value). Property name must match that of the method parameter.

Returns

T

The result for queries and null for non queries (Add, Set, Remove).

Type Parameters

T

The return object type.

Call<T>(string, Type, object?)

Make an API call using a generic type method. Generic type methods are methods that have the same name but take a specific object type.

[Obsolete("Asynchronous CallAsync method is better for performance.")]
T? Call<T>(string method, Type type, object? parameters = null)

Parameters

method string

The method name to call.

type Type

The Type use in the generic call.

parameters object

An anonymous object containing properties (param name) with values (param value). Property name must match that of the method parameter.

Returns

T

The result for queries and null for non queries (Add, Set, Remove).

Type Parameters

T

The return object type.

Remarks

The method is marked as Obsolete.

Clone()

Creates a new object that is a copy of the current instance.

object Clone()

Returns

object

A new object that is a copy of this instance.

DownloadAsync(Stream, MediaFile, CancellationToken)

Make an API call using generic type method to Download a stream of data.

Task DownloadAsync(Stream outputStream, MediaFile mediaFile, CancellationToken cancellationToken = default)

Parameters

outputStream Stream

The Stream to write downloaded binary data to.

mediaFile MediaFile

The MediaFile corresponding to the file to download.

cancellationToken CancellationToken

The CancellationToken used to single that the request should be canceled.

Returns

Task

A Task completed result.

MultiCall(params object[])

Make multiple calls (MultiCall) against the database using a single HTTP request. Each "call" must contain the return Type as the last index.

[Obsolete("Asynchronous MultiCallAsync method is better for performance.")]
List<object?> MultiCall(params object[] arguments)

Parameters

arguments object[]

A an array of object arrays contain call arguments and Type (if not otherwise specified).

Returns

List<object>

A list of. object

MultiCallAsync(params object[])

Make multiple calls (MultiCall) against the database using a single HTTP request. Each "call" must contain the return Type as the last index. This is an async call.

Task<List<object?>> MultiCallAsync(params object[] arguments)

Parameters

arguments object[]

A an array of object arrays contain call arguments and Type (if not otherwise specified).

Returns

Task<List<object>>

A list of. object

UploadAsync(Stream, MediaFile, CancellationToken)

Make an API call using generic type method to Upload a stream of data.

Task UploadAsync(Stream inputStream, MediaFile mediaFile, CancellationToken cancellationToken = default)

Parameters

inputStream Stream

The Stream of binary data to upload.

mediaFile MediaFile

The fully populated MediaFile corresponding to the file to upload.

cancellationToken CancellationToken

The CancellationToken used to single that the request should be canceled.

Returns

Task

A Task completed result.