# Theme

An object representing a theme.

# Properties

Property Type Description
uid integer The unique identifier of the Theme.
name string The name of the Theme.
active boolean Whether the Theme is active for customers.
conditions Conditions Conditions for when the Theme should be considered active.
created string Date and time of when the Theme was created.
changed string Date and time of when the Theme was last changed.
params object The parameters of the Theme.
theme string Name of the theme-component.
version string Version of the theme-component.
parent integer The unique identifier of the parent Theme.
ssr boolean Whether the Theme has Server-Side Rendering (SSR) enabled.
description string A description of the Theme.
webshop integer The unique identifier of the Webshop that the Theme belongs to.
engine string The theme engine used by the theme "diversity", "tpl" or "unity" (read only for existing themes).

# Conditions

The different conditions that may be set for a Theme.

Property Type Description
deviceType string At present, "mobile" is the only existing device-type value. If not "mobile", deviceType does not exist.)

# Methods

# count

Takes a filter object and returns the number of themes found, as an integer.

# Parameters

A filter object specifying which themes to count. See Filter objects on the page List selection.

# Example

The request below returns the number of active themes.

Theme.count({
  "/active": true
})

# create

Creates a new theme. This is shorthand for set with the uniquer identifier null.

# Parameters

Parameter Description
patch An object containing the properties and values to set for the new theme.
query A query specifying what to return after theme creation has been successful (optional). See Query language.

# Example

Theme.create({
  "name": "PurpleMobile",
  "conditions": {
    "deviceType": "mobile"
  },
  "params": {
    "layout": "bootstrap-layout-funky",
    "settings": {
      "colorScheme": "purplish",
      "centerfold": [
        {
          "component": "tws-minicart",
          "settings": {
            "type": "small"
          }
        }
      ]
    }
  }
})

# delete

Deletes a theme for a given unique identifier.

# Parameters

The unique identifier of the theme to be deleted.

# Example

Theme.delete(2423)

# Errors

Code Message Description
-32602 Invalid Params If the object does not exist or is unavailable.
1006 Forbidden Method call is not allowed.

# get

Retreives a specific theme.

# Parameters

Parameter Description
uid The unique identifier of the theme.
query Which info to return. See Query language.

# Example

Theme.get(1234, true)

# getSchema

Fetches the JSON Schema which can be used for client-side validation.

# Parameters

The unique identifier of a theme or null to create a new theme.

# list

Fetches multiple themes as an array.

# Parameters

Parameter Description
query Which info to return. See Query language.
selection Which themes to list. See List selection.

# Example

Theme.list("name", {
  "filters": {
    "/active": true
  }
})

# select

Selects and returns a Theme that satisfies the current connection and context. This method returns only ONE Theme which may be ANY of the Themes that are suitable.

# Parameters

Parameter Description
query Which info to return. See Query language.

# Example

From a mobile device:

Theme.select("name")

# set

Creates or updates a theme.

# Parameters

Parameter Description
uid The unique identifier of the theme or null to create a new theme.
patch An object containing the properties and values to set for the theme.
query A query specifying what to return after a successful set (optional). See Query language.

# Example

Theme.set(2423, {
  "active": true,
  "conditions": {
    "deviceType": "mobile"
  },
  "name": "BlackMobile",
  "params": {
    "settings": {
      "colorScheme": "black"
    }
  }
}, [
  "name",
  "active",
  "params"
])