Skip to content

superhero

Server Commands

This package provides a way to send multiple commands to the backend without the need of a custom endpoint. The most basic use case is making arbitrary updates to multiple limeobjects in a single request.

Take me directly to the implementation details:

I'm writing a web component I'm writing my own command

Installation

poetry add limepkg-server-commands

Requires Lime CRM 2020.3.481 (2.114.0) or later

What's in a command?

Synonyms: action, command, mutation

A command is a request from a client (desktop, web or integration) application for the CRM backend to process. Similar to an ordinary HTTP request, it has a name/verb and a payload. Unlike most POST/PUT/DELETE requests, multiple server commands are often sent together. This makes them perfect when you want to let the server do multiple changes in one go, which reduces complexity at the client side.

Just like POST/PUT/DELETE requests, server commands are ment to have side-effects. That's why these are used to change data in the backend and other systems.

Terminology

Command

A command is a simple object sent in the payload to the provided endpoint:

{
    "name": "send-sms",
    "parameters": {
        "to": "+46732123456",
        "text": "You have created another customer magnet!"
    }
}

Similar to an ordinary HTTP requests verb and payload, the command has a name and parameters.

Command batch

The provided endpoint accepts an array of commands, which is called a command batch.

{
    "commands": [
        {
            "name": "send-sms",
            "parameters": {
                "to": "+46732123456",
                "text": "You have created another customer magnet!"
            }
        },
        {
            "name": "send-sms",
            "parameters": {
                "to": "+46732678901",
                "text": "You have also created another customer magnet!"
            }
        }
    ]
}

What are the available command names?

In the examples above, the fictious command send-sms was used. Custom commands can be added by any package by registering so called command handlers. Two general purpose commands targeting limeobjects are provided by the server commands package itself that provide the same features as POST/PUT/DELETE requests to the limeobjects API:

In short, sending a array of upsert-limeobject commands to the endpoint is the same as issuing several POST/PUT requests to the limeobjects API.

Back to top