# Customergroup

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

# Properties

Property Description
uid The unique identifier of the customer group.
name Name of the customer group.
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.

# 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".

Customergroup.count({
  "/name": {
    "startsWith": "Staff"
  }
})

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

Customergroup.create({
  "name": "Students"
}, [
  "uid",
  "name"
])

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

Customergroup.get(123123, "name")

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

# 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:

Customergroup.list([
  "uid",
  "name",
  "changed",
  "created"
], {
  "limit": 2
})

# 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). See Query language.

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

Customergroup.set(123123, {
  "name": "Students and teachers"
}, [
  "uid",
  "name",
  "changed",
  "created"
])

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