Slamby SDK .NET v1.5.0

Slamby .NET SDK and NuGet Package. This project is open source. Please check the documentation and join to the community group.

GitHub Slamby page: www.github.com/slamby GitHub page: www.github.com/slamby/slamby-sdk-net

Changelog

Features

  • Released v1.5.0

General

Request Basics

Configuration example:

var configuration = new Configuration
    {
        ApiBaseEndpoint = new Uri("https://europe.slamby.com/CLIENT_ID/"),
        ApiSecret = "API_KEY"
    };

You have to use this configuration object for every Manager.

You can find more details about the Authentication here

Slamby SDK.NET sends its version information to the API for version matching. Major and minor values should match in order to prevent version incompatibility.

ParallelLimit property enables you to limit or maximize CPU usage in certain functions. Limit value should be greater than zero in order to be sent.

Note: In some cases API can limit your value if your configuration cannot handle it efficiently

Response Basics

Every request returns one of the following results:

public class ClientResponse
{
    public bool IsSuccessful { get; set; }
    public HttpStatusCode HttpStatusCode { get; set; }
    public string ServerMessage { get; set; }
    public ErrorsModel Errors { get; set; }
    public string ApiVersion { get; set; }
}

public class ClientResponseWithObject<T> : ClientResponse
{
    public T ResponseObject { get; set; }
}

Logging

Logging raw request and response message with RawMessagePublisher. Currently DebugSubscriber is available which writes messages to debug output. Custom subscribers can be created via implementing IRawMessageSubscriber interface.

Example:

IRawMessageSubscriber subscriber = new DebugSubscriber();
RawMessagePublisher.Instance.AddSubscriber(subscriber);

// API calls

RawMessagePublisher.Instance.RemoveSubscriber(subscriber);

Output:

REQUEST #63592531131529252663115
----------------------
POST http://localhost:29689/api/tags
Headers:
Accept|application/json
Authorization|Slamby API_KEY
X-DataSet|test1

Content:  
{"Id":"999","Name":"tag","ParentTagId":null,"Properties":null}

Async methods

In all the Manager class there are async methods. If you would like to use in a synchronized way, you can get the Result object of the task.

Example:

var dataset = manager.GetDataSetAsync().Result;