Overview

13min

Getting Started

Kickplan is an innovative approach to powering SaaS app monetization by providing infrastructure to automate and control your accounts' entitlements.

For a full overview of Kickplan, its benefits and features, please visit docs.kickplan.com.

Installation

Add the following to your Gemfile and run bundle install.

Ruby


Create an initializer called kickplan.rb and add the following.

Ruby


Configuration

Config options can be found in the Configuration module.

Ruby


Additionally, the SDK can read from ENV variables and has a set of reasonable defaults.

Resources

All API methods are accessed via the various Resource modules.

Each resource endpoint will generally have a corresponding Request module that is configured to validate input client-side.

Accounts



Creates a new account record:

Ruby


See Requests::Accounts::Create for parameters.



Updates an existing account record:

Ruby


See Requests::Accounts::Update for parameters.

Features



To resolve a single feature, pass the feature key as the first argument:

Ruby


To resolve all features, omit the feature key:

Ruby


See Requests::Features::Resolve for parameters.

Metrics



Sets a metric to a specific value:

Ruby


See Requests::Metrics::Set for parameters.

Adapters

The SDK currently supports 2 adapters: :memory and :http. Additional built-in adapters are planned.

The :memory adapter can be used for testing purposes or as a fully in-memory feature resolution tool.

You can also create and register your own adapter:

Ruby


@todo Add info on the interface required for implementing a custom adapter.

Additional Clients

By default, the Kickplan SDK utilizes a single client for all requests. You may have noticed this client referenced when inspecting the resource modules:

Ruby


There may be scenarios in which multiple clients are necessary (different endpoints, products, etc.). The Kickplan SDK has a thread-safe registry that stores all instantiated clients so you don't have keep up the client instance yourself.

To create a new client, simply reference it by name using Kickplan[] or Kickplan.client():

Ruby


Resources are accessed in the same manner as using the default client:

Ruby


The default client can also be accessed directly, though this is normally omitted. However, when using multiple clients, you may prefer to access the default client explicitly for clarity or configuration purposes:

Ruby


Configuration

The Kickplan SDK can be configured globally or on a per-client level. By default, all clients will utilize the global configuration but you can also configure the client directly:

Ruby




Updated 01 Aug 2024
Doc contributor
Doc contributor
Did this page help you?