Download the PHP package codelet/sdk without Composer

On this page you can find all versions of the php package codelet/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sdk

Codelet PHP SDK

Official PHP client for the Codelet public API.

Install

For local development from this monorepo:

Usage

Optional constructor args: $baseUrl, $maxAttempts, $headers, $httpClient.

Examples

Create metrics before plans, credit packs, or ingest. Unknown metric names return 400.

Create a metric

Create a credit pack

Create and publish a plan

Create checkout

Credit pack (one-time purchase):

Subscription (plan):

Pass either customer_id or customer_email, not both. Exactly one of pack_id or plan_id is required.

API reference

All generated methods are available on the Client instance (for example $codelet->customers->listCustomers). Prefer $codelet->ingest(…) over $codelet->usage->ingestEvent(…) when recording usage; the helper fills idempotency_key when omitted.

$codelet->ingest($body)

Ingest a usage event. Same as usage->ingestEvent, but generates idempotency_key when omitted.

Method Description
ingest(IngestEventRequest $body) POST /v1/ingest

Account ($codelet->account)

Method Description
getMe() API key context (project + environment)

Checkout ($codelet->checkout)

Method Description
createCheckout($create_checkout_request) Create a credit pack or subscription checkout

Credit packs ($codelet->creditPacks)

Method Description
listCreditPacks($metric = null, $active = 'true', $page_size = 20, $cursor = null) List packs (default: active only)
createCreditPack($create_credit_pack_request) Create a pack
getCreditPack($pack_id) Get a pack by ID
updateCreditPack($pack_id, $update_credit_pack_request) Update name, description, and/or active

Customers ($codelet->customers)

Method Description
listCustomers($page_size = 20, $cursor = null) List customers
createCustomer($create_customer_request) Create a customer
getCustomer($customer_id) Get a customer
updateCustomer($customer_id, $update_customer_request) Update editable fields
getCustomerBalance($customer_id, $metric = null) Credit balances (all metrics, or one)

Metrics ($codelet->metrics)

Method Description
listMetrics($page_size = 20, $cursor = null) List metrics
createMetric($create_metric_request) Create a metric
getMetric($name) Get a metric by name
updateMetric($name, $update_metric_request) Partial update (today: display_name)

Plans ($codelet->plans)

Method Description
listPlans($status = 'published', $page_size = 20, $cursor = null) List plans (default: published)
createPlan($create_plan_request) Create a draft plan
getPlan($plan_id, $include_pricing_details = false) Get a plan
publishPlan($plan_id) Publish the draft version

Subscriptions ($codelet->subscriptions)

Method Description
listSubscriptions($customer = null, $status = null, $page_size = 20, $cursor = null) List subscriptions
getSubscription($subscription_id) Get a subscription
cancelSubscription($subscription_id, $cancel_subscription_request) Cancel (at_period_end or immediate)
resumeSubscription($subscription_id) Clear a scheduled cancellation

Usage ($codelet->usage)

Method Description
ingestEvent($ingest_event_request) Ingest a usage event (no auto idempotency key)

Request and response shapes match the OpenAPI spec. See also codelet.co/SKILL.md for merchant integration guidance.

Errors

Generated APIs throw ApiException from the OpenAPI client. The top-level ingest helper maps those to CodeletException / RateLimitException.

Development

Hand-written surface (src/) stays stable. Generated code under generated/ is overwritten by make sdk-generate.


All versions of sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.3
guzzlehttp/psr7 Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package codelet/sdk contains the following files

Loading the files please wait ...