Session

An API class representing a session.

Properties

Property Description
currency The currency in which prices will be displayed.
customer The unique identifier of the logged-in customer.
showPricesIncludingVat Whether the price of an article has VAT included.

Methods

delete

Deletes the session with all its stored data.

Errors

Code Message Description
-32602 Invalid params If the unique identifier of the session does not exist.

Example

API Console
Session.delete()
Response
null

get

Fetches information about a session.

Parameters

Which info to return. See Query language.

Example

API Console
Session.get("showPricesIncludingVat")
Response
{
  "showPricesIncludingVat": true
}

getOrder

Retreives data from an active cart (Order) tied to the current session.

Parameters

Parameter Description
query As to Order.get

Returns

Order data or null if there is no cart in the session.

Example

API Console
Session.getOrder({ "uid": true })
Response
{ "uid": 12345 }

getSchema

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

getToken

A class method for getting a token for a customer's session. The session may be tied to a cart.

Returns

The token to be used as context parameter "session".

Example

API Console
Session.getToken()
Response
"523979fe2c0ce"

set

Sets session information. If the session has an order and the patch contains a currency, then the prices in the order (including rounding) are updated in the new currency.

Parameters

Parameter Description
patch An object containing the properties and values to set for the session.
query A query specifying what to return after a successful set (optional).

Example

API Console
Session.set({"currency": "EUR"},["currency"])
Response
{
  "currency": "EUR"
}

setCustomer

Sets a new Customer on the session and associated orders.

Parameters

The unique identifier of a Customer.

Example

API Console
Session.setCustomer(12341234)
Response
null