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.
To import the package using Composer
composer require kickplan/kickplan-sdk:dev-mainAfter 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.
To check which features are resolvable
resolve(): object
Example:
$result = $client->features->resolve();To resolve features with context
resolveWithAccount(string $accountId): object
Example:
$result = $client->features->resolveWithAccount($accountId)To resolve a specific feature with context
resolveFeatureForAccount(string $featureName,string $accountId): object
Example:
$result = $client->features->resolveFeatureForAccount($featureName, $accountId)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);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);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 valuetime(optional, DateTime|string): Timestampidempotency_key(optional, string): Idempotency key
Example:
$result = $client->metrics->setMetricsKey($payload);Returns a response with metrics response json object.