Customergroup

An object representing a customer group. Customer groups are accessible to administrators only.

Properties

Property Description
changed Date and time of when the customer group was last modified. If never modified, the value will be that of when the customer group was created.
created Date and time of when the customer group was created.
name Name of the customer group.
uid The unique identifier of the customer group.

Methods

count

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

Parameters

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

Example

The request below returns the number of customer groups found where the name in English starts with "Staff".

API Console
Customergroup.count(
  {
    "/name": {
      "startsWith": "Staff"
    }
  }
)
Response
1

create

Creates a new customer group. This is a shorthand for set with null as the first parameter.

Parameters

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

Example

The request below creates a customer group with the name "Students" and returns the name and unique identifier of the customer group.

API Console
Customergroup.create({"name": "Students"}, ["uid", "name"])
Response
{
  "name": "Students",
  "uid": 123123
}

get

Fetches information about a customer group.

Parameters

Parameter Description
uid The unique identifier of a customer group.
query Which info to return. See Query language.

Example

The request below returns the name of the customer group with the unique identifier 123123.

API Console
Customergroup.get(123123, "name")
Response
{
 "name": "Students"
}

getSchema

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

Parameters

The unique identifier of an existing customer group or null for a new customer group.

Example

JSON
{
  "uid": {
    "type":        "integer",
    "description": "Customer group instance's UID."
  },
  "name": {
    "type":        "string",
    "description": "Customer group name.",
    "title":       "Name"
  }
}

list

Returns an array of objects representing customer groups.

Parameters

Parameter Description
query A query object specifying what to fetch from each customer group. This is the same as for get. See Query language.
selection A list selection specifying which customer groups to fetch. See List selection.

These orderings are available:

  • uid
  • customerCount
  • name

Example

The following request returns an array of max two customer groups with the properties name, created, changed and uid:

API Console
Customergroup.list(["changed", "created", "name", "uid"], {"limit": 2})
Response
[
  {
    "changed": "2013-12-03T15:06:57Z",
    "created": "2013-12-03T15:06:57Z",
    "name": "Staff",
    "uid": 123122
  },
  {
    "changed": "2014-01-16T14:14:18Z",
    "created": "2014-01-16T14:14:18Z",
    "name": "Students",
    "uid": 123123
  }
]

set

Creates or updates a customer group.

Parameters

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

Example

The request below changes the name of the customer group with the unique identifier 123123 and returns the properties name, changed, created and uid of the customer group.

API Console
Customergroup.set(123123, {"name": "Students and teachers"}, ["name", "changed", "created", "uid"])
Response
{
  "changed": "2014-11-06T10:28:38Z",
  "created": "2014-01-16T14:14:18Z",
  "name": "Students and teachers",
  "uid": 123123
}

validate

Validates the data to be set. The performed validation is the same as in set; it validates the resulting object and includes all the required properties. However, nothing is saved.

Parameters

Parameter Description
uid The unique identifier of an existing customer group or null.
patch An object containing the properties and values to set before validating.

Returns

An array of validation-error objects, each containing the keys pointer (a property referenced using a JSON Pointer) and message (a readable text in the language of the context). If there are no validation errors, then an empty array is returned.