Skip to content

shipany.bot.jsonlogic

shipany.bot.jsonlogic package

Submodules

shipany.bot.jsonlogic.apply module

shipany.bot.jsonlogic.apply.apply(logic, ctx)

Apply JSONLogic to the context.

  • Parameters:
    • logic (jl.JsonLogic) — JSONLogic to apply.
    • ctx (ConversationContext) — Conversation context.
  • Returns: Result of the JSONLogic.
  • Return type: JsonValue

shipany.bot.jsonlogic.model module

pydantic model shipany.bot.jsonlogic.model.EqualsOperation

Bases: BaseModel

Equals operation model.

Payload samples

  • Check if two values are equal:
    {
    "==": [1, 1]
    }
  • Check if two variables are equal:
    {
    "==": [
    {"var": "a"},
    {"var": "b"}
    ]
    }
  • Check if the variable a equals to the string b:
    {
    "==": [
    {"var": "a"},
    "b"
    ]
    }

Pydantic model parameters

field args : list[JsonLogic | str | int | bool | float | list[str | int | bool | float]] [Required] (alias ’==’)

Arguments of the operation. Can be a list of JSONLogic, strings, integers, booleans, floats, or lists of strings, integers, booleans, or floats.

validator check_args_length » all fields

Check if the number of arguments is correct. Should be at least 2.

  • Parameters: self (Self)
  • Return type: Self

pydantic model shipany.bot.jsonlogic.model.InOperation

Bases: BaseModel

In operation model.

Payload samples

  • Check if the value is in the list:
    {
    "in": [1, [1, 2, 3]]
    }
  • Check if the variable is in the list:
    {
    "in": [
    {"var": "a"},
    [1, 2, 3]
    ]
    }

Pydantic model parameters

field args : list[JsonLogic | str | int | bool | float | list[str | int | bool | float]] [Required] (alias ‘in’)

Arguments of the operation. Can be a list of JSONLogic, strings, integers, booleans, floats, or lists of strings, integers, booleans, or floats.

validator check_args_length » all fields

Check if the number of arguments is correct. Should be 2.

  • Parameters: self (Self)
  • Return type: Self

pydantic model shipany.bot.jsonlogic.model.AndOperation

Bases: BaseModel

And operation model.

Payload samples

  • Check if all values are true:
    {
    "and": [true, true]
    }
  • Check if all variables are true:
    {
    "and": [
    {"var": "a"},
    {"var": "b"}
    ]
    }
  • Check if all variables are true:
    {
    "and": [
    {"var": "a"},
    {"var": "b"}
    ]
    }

Pydantic model parameters

field args : list[JsonLogic | str | int | bool | float] [Required] (alias ‘and’)

Arguments of the operation. Can be a list of JSONLogic, strings, integers, booleans, or floats.

validator check_args_length » all fields

Check if the number of arguments is correct. Should be at least 2.

  • Parameters: self (Self)
  • Return type: Self

pydantic model shipany.bot.jsonlogic.model.OrOperation

Bases: BaseModel

Or operation model.

Payload samples

  • Check if any value is true:
    {
    "or": [true, false]
    }
  • Check if any variable is true:
    {
    "or": [
    {"var": "a"},
    {"var": "b"}
    ]
    }

Pydantic model parameters

field args : list[JsonLogic | str | int | bool | float] [Required] (alias ‘or’)

Arguments of the operation. Can be a list of JSONLogic, strings, integers, booleans, or floats.

validator check_args_length » all fields

Check if the number of arguments is correct. Should be at least 2.

  • Parameters: self (Self)
  • Return type: Self

pydantic model shipany.bot.jsonlogic.model.NotOperation

Bases: BaseModel

Not operation model.

Payload samples

  • Check if the value is not true:
    {
    "not": true
    }
  • Check if the variable is not true:
    {
    "not": {"var": "a"}
    }

Pydantic model parameters

field args : list[JsonLogic | str | int | bool | float] [Required] (alias ‘not’)

Arguments of the operation. Can be a list of JSONLogic, strings, integers, booleans, or floats.

validator check_args_length » all fields

Check if the number of arguments is correct. Should be 1.

  • Parameters: self (Self)
  • Return type: Self

pydantic model shipany.bot.jsonlogic.model.VarOperation

Bases: BaseModel

Var operation model.

Payload samples

  • Get the value of the variable:
    {
    "var": "a"
    }
  • Get the value of the variable from the specific scope:
    {
    "var": "a",
    "scope": "user"
    }

Pydantic model parameters

field var : str [Required]

Variable name.

  • Constraints:
    • min_length = 1

field scope : Scope | None = None

Scope of the variable. Default is None which means global scope.

Module contents