Mbs SDK


Mbs SDK is a client library that enables easier integration with the Mbs web interface. SDK provides entities (messages sent to and recevived from the server) as well as websocket connection handling.

Installation

SDK can be obtained from nuget repository.

Usage

Initialize the SDK

Create MbsSdkConfig configuration object with the values provided by Sportradar:

MbsSdkConfig config = new MbsSdkConfig(
        wsServer, authServer, authClientId, authClientSecret, authAudience, operatorId);

Use the config to create MbsSdk instance and establish a connection to the server:

MbsSdk mbsSdk = new MbsSdk(config);
mbsSdk.Connect();

The SDK is threadsafe and a single instance can be used for the entire application lifespan.

Use the SDK

Operations that are supported by the SDK are grouped into protocols, eg: all ticket operations are available under ITicketProtocol.

The SDK instances exposes all the protocols through getter property, eg:

mbsSdk.TicketProtocol;

Each operation (method) exposed by the protocol is generally of a request/response form. Each method accepts its Request object (eg: TicketRequest, CancelRequest, ...) and returns matching Response object (eg: TicketResponse, CancelResponse, ...) and each method can be used in async or blocking context:

// create appropriate request
OperationRequest request = new OperationRequest();
// async
OperationResponse response = await mbsSdk.Protocol.executeOperationAsync(request);
// blocking
OperationResponse response = mbsSdk.Protocol.executeOperationAsync(request).Result;

Example of ticket place operation:

TicketRequest request = new TicketRequest
{
    Context = new TicketContext
    {
        LimitId = 1234567890,
        ... // omitted for brevity
    },
    TicketId = "ticketId-1234567890",
    ... // omitted for brevity
};
TicketResponse response = await sdk.TicketProtocol.SendTicketAsync(request);

Close the SDK

When MbsSdk instance is not needed anymore, invoke Dispose() to release the resources:

mbsSdk.Dispose();

Further reading

Betradar documentation