SDK
v0.3.2Add spend control to your application.
Getting started
- OverviewWhat your application does through the SDK — run flows, wait for them, keep customers and their credits, check webhooks — and what the SDK does by itself on every call.3 min
- InstallationWhat each SDK needs, how to install its package, how to call Slen without it, and the API key it calls with.3 min
- QuickstartRun a published flow from your application with the SDK and read what it answered.6 min
- ConfigurationThe options the SDK is built with, what each one is for, and the one environment variable it reads.4 min
- Laravel integrationThe service provider, the Slen facade and the config file of the PHP SDK — what a Laravel application gets from the package, and what it sets in its environment.5 min
Requests
- Send a requestRun a flow with its input, the customer it is for and the context of the call, and read every field of the execution that comes back.6 min
- Async runs and waitingSend a run without waiting for it, wait for an execution that answered queued or waiting, and read its status and its trace.7 min
- Idempotency keysGive a run or a movement of credits a key that names its piece of work, so that a repeat — by the SDK, by your queue or by your own code — is answered instead of done again.5 min
Customers
- Customers and creditsCreate a customer, top up and charge their credits, read the balance and the statement, run a flow the customer pays for, and block a customer.7 min
- When spend is refusedThe errors that say a budget, a limit or the credits of a customer refused a run, the two forms such a refusal comes in, and what to do about each.3 min
Webhooks
Errors & retries
- Handling errorsWhat an error of the SDK carries, how to catch it by type and branch on its code, and which errors say that a run may have cost money.5 min
- Retries and timeoutsWhich requests the SDK repeats by itself and after which pause, which answers it never repeats, and what each timeout of the SDK bounds.5 min
- When the outcome is unknownHow the SDK tells you that a provider was called and its answer was lost, what Slen does about the money, and how to repeat the run without paying twice.3 min
Reference
- Client and methodsThe entry point of each SDK, its modules and every call they offer, with the request of the API each call makes, the scope it needs and the idempotency key it carries.
- Result objectsThe objects the calls of the SDK return — an execution, its trace, a customer, an account, an entry of the statement, a page — and which field of the answer of the API each of their fields carries.
- Error typesThe type of error each SDK raises for an error code of the API, how the types are related, and the errors the SDKs raise themselves.
- LoggingHand the SDK a logger, and read the events it writes for each request — the route, the status and the time, never a key or a body.5 min
- SpansThe span the SDK writes for each run and each wait — its fields, where it goes, and how it reaches your logs or your traces.6 min
- Testing your integrationUse the test double the SDK ships with to queue the answers of the API and to check the requests your code sent.4 min
- PHP and Node.jsEvery call of the two SDKs side by side, and what else tells them apart — the runtime, the HTTP client, the journal, the spans, Laravel.