Koople
Search…
C#

Getting Started

If still not registered, sign up and create an account at https://koople.io.
  1. 1.
    Add SDK library
Package Manager
.NET CLI
PackageReference
Paket CLI
1
Install-Package koople-sdk -Version 0.1.1
Copied!
1
dotnet add package koople-sdk --version 0.1.1
Copied!
1
<PackageReference Include="koople-sdk" Version="0.1.1" />
Copied!
1
paket add koople-sdk --version 0.1.1
Copied!
Refer to the Nuget release page to identify the latest version.
2. Initliaze the SDK
1
var client = KClient.Initialize('YOUR_API_KEY');
Copied!
3. Get your feature flags values
1
var user = KUser.Create('aUserId');
2
var isEnabled = client.IsEnabled('myAwesomeFeature', user);
3
if (isEnabled) {
4
// Do something when the feature is enabled.
5
} else {
6
// Do something when the feature is not enabled.
7
}
Copied!
Identify users to allow specific targets. See KUser.
1
var user = KUser.Create('aUserId');
2
var isEnabled = client.IsEnabled('myAwesomeFeature', user);
3
if (isEnabled) {
4
// Do something when the feature is enabled.
5
} else {
6
// Do something when the feature is not enabled.
7
}
Copied!

Methods

Initialize

Use initialize to get a validated client object.
Parameter
Description
apiKey
The server ApiKey for your project environment.
required
poolingInterval
Interval in seconds with which the SDK makes requests to the server to update the evaluation object.
optional
Interval in seconds with which the SDK makes requests to the server to update the evaluation object. The minimum value is 10 seconds. If the value is less than 10 it will be ignored and automatically set to 10. The default value is 60 seconds.
1
var fclient = KClient.Initialize('YOUR_API_KEY', 30);
Copied!

IsEnabled

The isEnabled method will return a boolean indicating whether a release toggle is enabled or disabled.
Name
Type
releaseToggleKey
string
required
user
KUser
optional
1
//anonymous evaluation
2
client.IsEnabled('myAwesomeFeature');
Copied!
1
var user = KUser.create('aUserId');
2
client.IsEnabled('myAwesomeFeature', user);
Copied!
The evaluation of an unexistent releaseToggleKey will return false as an evaluation result.

ValueOf

The valueOf method will return a value for a remote config. You can pass an optional second parameter that will be used as a fallback if there is no value.
Name
Type
remoteConfigKey
string
required
user
KUser
optional
defaultValue
string
optional
1
client.ValueOf('theme');
2
// or
3
client.ValueOf('theme', 'defaultValue');
Copied!
1
var user = KUser.Create('aUserId');
2
3
client.ValueOf('theme', user);
4
//or
5
client.ValueOf('theme', user, 'defaultValue');
Copied!

Objects

KUser

The KUser object represents a user with the properties to be evaluated. The properties can be added in the following ways.
Name
Type
identity
string
required
attributes
List<KUserAttribute>
optional
1
var attributes = new[] {
2
new KUserAttribute("age", 17),
3
new KUserAttribute("gender", "male")
4
};
5
6
var user = KUser.Create("userId", attributes);
Copied!
The user can be created first for adding attributes later.
1
var user = KUser.Create("userId")
2
.With("age", 17)
3
.With("gender", "male");
Copied!
Also, the user can be created as an anonymous user.
1
var user = KUser.Anonymous();
Copied!

KUserAttribute

The KUserAttribute represents a key-value object to set the name and value of a user attribute.
Name
Type
name
string
required
value
Object
required
Value object can be a string, a number or a boolean type.
1
new KUserAttribute("age", 17);
2
new KUserAttribute("gender", "male");
3
new KUserAttribute("vip", true);
Copied!
Last modified 11mo ago