SDK

v0.3.2

Add spend control to your application.

Getting started

  • Overview
    What 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
  • Installation
    What each SDK needs, how to install its package, how to call Slen without it, and the API key it calls with.
    3 min
  • Quickstart
    Run a published flow from your application with the SDK and read what it answered.
    6 min
  • Configuration
    The options the SDK is built with, what each one is for, and the one environment variable it reads.
    4 min
  • Laravel integration
    The 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 request
    Run 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 waiting
    Send 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 keys
    Give 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 credits
    Create 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 refused
    The 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

  • Webhooks
    Check the signature of a delivery, read it as a typed event, answer Slen, and tell a delivery from its repeat.
    5 min

Errors & retries

  • Handling errors
    What 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 timeouts
    Which 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 unknown
    How 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 methods
    The 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 objects
    The 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 types
    The 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.
  • Logging
    Hand 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
  • Spans
    The 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 integration
    Use 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.js
    Every call of the two SDKs side by side, and what else tells them apart — the runtime, the HTTP client, the journal, the spans, Laravel.