Overview
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.
Add the following to your Gemfile and run bundle install.
Create an initializer called kickplan.rb and add the following.
Config options can be found in the Configuration module.
Additionally, the SDK can read from ENV variables and has a set of reasonable defaults.
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.
Creates a new account record:
See Requests::Accounts::Create for parameters.
Updates an existing account record:
See Requests::Accounts::Update for parameters.
To resolve a single feature, pass the feature key as the first argument:
To resolve all features, omit the feature key:
See Requests::Features::Resolve for parameters.
Sets a metric to a specific value:
See Requests::Metrics::Set for parameters.
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:
@todo Add info on the interface required for implementing a custom adapter.
By default, the Kickplan SDK utilizes a single client for all requests. You may have noticed this client referenced when inspecting the resource modules:
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():
Resources are accessed in the same manner as using the default client:
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:
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: