Skip to content

Latest commit

 

History

History
125 lines (91 loc) · 3.19 KB

File metadata and controls

125 lines (91 loc) · 3.19 KB

Introduction

Kickplan takes care of the complex business logic for monetization, using our SDK, your application only needs to manage access to features and track value metrics. These functions are keyed by account. For detailed terminology, please consult our documentation.

Configuration

To import the package using Composer

composer require kickplan/kickplan-sdk:dev-main

After importing, please initialize your client:

$client = new KickplanApi([
  'apiKey' => '<YOUR_KICKPLAN_API_KEY>',
  'baseUrl' => '<YOUR_KICKPLAN_BASE_URL>'
]);

.env variables are also supported via KICKPLAN_API_KEY and KICKPLAN_BASE_URL respectively.

resolve

To check which features are resolvable

resolve(): object

Example:

$result = $client->features->resolve();

resolveWithAccount

To resolve features with context

resolveWithAccount(string $accountId): object

Example:

$result = $client->features->resolveWithAccount($accountId)

resolveFeatureForAccount

To resolve a specific feature with context

resolveFeatureForAccount(string $featureName,string $accountId): object

Example:

$result = $client->features->resolveFeatureForAccount($featureName, $accountId)

create

In order to resolve features for an account, Kickplan needs to know an account key and the plan key they are on. Plan keys are not currently exposed in the API but will be soon.

create(array: $payload): object

$payload: Associative array with the following keys:

  • key (string): The unique identifier. Any other data in the array will be passed on and matched to custom fields on the Account.

Example:

$payload = [
    "key" => "acme",
    "name" => "Acme",
    "account_plans" => [
        [
            "plan_key" => "essentials"
        ]
    ]
];
$result = $client->accounts->create($payload);

update

To keep accounts up to date, you can update anytime an account changes or it's plan changes.

update(array: $payload): object

$payload: Associative array with the following keys:

  • key (string): The unique identifier. Any other data in the array will be passed on and matched to custom fields on the Account.

Example:

$payload = [
    "key" => "acme",
    "name" => "Acme",
    "account_plans" => [
        [
            "plan_key" => "essentials"
        ]
    ]
];
$result = $client->accounts->update($payload);

setMetricsKey

A request to set a value for a key metric, for a given account.

$result = $client->metrics->setMetricsKey(array $payload);

$payload: Associative array with the following keys:

  • key (string): The unique identifier.
  • account_key (string): The account identifier.
  • value (string | number | boolean | array): The value
  • time (optional, DateTime|string): Timestamp
  • idempotency_key (optional, string): Idempotency key

Example:

$result = $client->metrics->setMetricsKey($payload);

Returns a response with metrics response json object.