Theme

An object representing a theme.

Properties

Property Description
active Whether the Theme is active for Customers.
changed Date and time of when the Theme was last changed.
conditions See Conditions below.
created Date and time of when the Theme was created.
name The name of the Theme.
params The parameters of the Theme.
uid The unique identifier of the Theme.

Conditions

The different conditions that may be set for a Theme.

Condition Description
deviceType 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.

API Console
Theme.count(
  {
    "/active": true
  }
)
Response
1

create

Creates a new theme. This is a shorthand for set with UID 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).

Example

API Console
Theme.create({
  "name": "PurpleMobile",
  "conditions": {
    "deviceType": "mobile"
  },
  "params": {
    "layout": "bootstrap-layout-funky",
    "settings": {
      "colorScheme": "purplish",
      "centerfold": [{
        "component": "tws-minicart",
        "settings":  {"type": "small"}
      }]
    }
  }
})
Response
{
  "uid": 2423,
  "name": "PurpleMobile",
  "active": false,
  "conditions": {
    "deviceType": "mobile"
  },
  "created": "2014-06-11T09:40:02Z",
  "changed": "2014-06-11T09:40:02Z",
  "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

API Console
Theme.delete(2423)
Response
null

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

API Console
Theme.get(1234, true)
Response
{
  "uid": 1234,
  "name": "PurpleDesktop",
  "active": true,
  "conditions: {
    "deviceType": "pc"
  },
  "created": "2014-06-11T09:40:02Z",
  "changed": "2014-08-17T08:21:21Z",
  "params": {
    "layout": "bootstrap-layout-funky",
    "settings": {
      "colorScheme": "purplish",
      "centerfold": [{
        "component": "tws-minicart",
        "settings":  {"type": "small"}
      }]
    }
  }
}

getSchema

Parameters

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

Example

API Console
Theme.getSchema(null)
Response
{
  "title": "Theme",
  "description": "An object representing a theme.",
  "type": object,
  "additionalProperties": false,
  "properties": {
    "uid": {
      "type": integer,
    },
    "name": {
      "type": string
    },
    "active": {
      "type": boolean
    },
    "conditions": {},
    "created": {
      "type": string,
      "format": 'date-time'
    },
    "changed": {
      "type": string,
      "format": 'date-time'
    }
    "params": {
      "type": object,
      "format": "diversity"
    }
  }
}

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

API Console
Theme.list("name", {"filters": {"/active": true}})
Response
[{"name": "PurpleMobile"}, {"name": "PurpleDesktop"}, {"name": "GreenDesktop"}]

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:

API Console
Theme.select(["name"])
Response
{"name": "BlackMobile"}

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).

Example

API Console
Theme.set(2423, {
  "active": true,
  "conditions": {
    "deviceType": "mobile"
  },
  "name": "BlackMobile",
  "params": {
    "settings": {
      "colorScheme": "black"
    }
  }
}, ["name", "active", "settings"])
Response
{
  "name": "BlackMobile",
  "active": true,
  "params": {
    "settings": {
      "colorScheme": "black",
      "centerfold": [{
        "component": "tws-minicart",
        "settings": {"type": "small"}
      }]
    }
  }
}