Skip to content

.net Core Class library for easy access to the Chayns Backend API

Notifications You must be signed in to change notification settings

TobitSoftware/Chayns-Backend-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chayns Backend API NuGet NuGet

The Chayns.Backend.Api-package is dedicated to support you using the backend api itself.
It shortens and simplifies many features of the api and makes the usage much more cleaned up.

Requirements

To use this project you will need the following prerequisites

  • Visual Studio
  • .NET Framework 4.5.2 or greater or
  • .Net Core 1.0 or greater

Installation

You can install the library by using the VisualStudio nuget-plugin. The plugin will install all dependencies.

If you already have NuGet installed you can install the package running the following command inside your project directory.

nuget install Chayns.Backend.Api

How to use

To authenticate your request you will need your secret and TappId (you can find more information in the chayns backend wiki).
You can find the secret in the tapp administration in the TSPN and the TappId can be found in the JavaScript Frontend API.

Here are some examples:

All examples require the following variables

private const string Secret = "{your Secret}";
private const int LocationId = 1234;
private const int TappId = 1234;

In the first example we want to load some user-informations:

UserResult GetUser(int userId)
{
    var location = new LocationIdentifier(LocationId);
    var cred = new SecretCredentials(Secret, TappId);

    var userRep = new UserRepository(cred);
    var result = userRep.GetUser(userId, location);
    
    return result.Data;
}

In the our second Example we want to load all our female users

IEnumerable<UserResult> GetFemaleUsers()
{
    var cred = new SecretCredentials(TappSecret, TappId);
    var userGet = new UserDataGet(LocationId)
    {
        Gender = "female"
    };

    var userRep = new UserRepository(cred);
    Result<UserResult> result = userRep.GetUser(userGet);

    return result.Data;
}

And in our last example we generate a PageAccessToken that could be used in our frontend

string GetPageAccessToken()
{
    var cred = new SecretCredentials(Secret, TappId);
    var tokenGet = new PageAccessTokenDataGet(LocationId)
    {
        Permissions = new List<string>
        {
            "PublicInfo",
            "UserInfo",
            "SeeUAC",
            "EditUAC",
            "DeviceInfo",
            "Push",
            "Intercom",
            "Email"
        }
    };
    var accesstokenRep = new AccessTokenRepository();
    
    var result = accesstokenRep.GetPageAccessToken(cred, tokenGet);
    
    return result?.Data?.PageAccessToken;
}

Releases

No releases published

Packages

No packages published

Languages