Class ModelBase

Represents the base class for most model classes and provides utility methods for converting data from raw response objects into model class instances.

class ModelBase()

Represents the base class for most model classes such as Container(), Document() or User().

Arguments
  • json (object()) – Raw response object representation from which a model instance is being created. The resulting model class instance will retain all properties of the underlying raw response object. Some data might be re-encoded depending on the model class.

Methods

ModelBase.updateFromJson(json)

Update this model instance by setting all properties from the given json object.

Arguments
  • json (object()) – Raw response object representation from which a model instance is typically being created.

ModelBase.mapToType(object, type, predicate)

Map the given object to the given model type. For arrays, if a predicate function is provided, only instances passing the predicate filter function are converted; all other instances are omitted.

Arguments
  • object (object()) – Source object representing an object or array of objects that are being converted.

  • type (function()) – Model class constructor function that the given object is converted into.

  • predicate (function()) – Optional: Predicate function that - if provided - is used to filter objects if an array of objects is provided. Only instances for which the predicate filter function returns true are converted; all other instances are omitted.

ModelBase.parseDate(jsonDate)

Parse c# date format (for example /Date(1245398693390)/) to Javascript date object. Also understand dates in the format YYYY-MM-DDTHH:mm:ssZ.

Arguments
  • jsonDate (string()) – Input date in c# date format when encoding c# DateTime objects as JSON.

ModelBase.encodeDate(d)

Construct a date string in c# date format (for example /Date(1245398693390)/) from the given date or ISO string.

Arguments
  • d (date()) – Javascript date object or string representing a date in ISO format.

ModelBase.isMinDate(jsonDate)

Returns true, if the given date in c# format represents the minimum possible date value.

ModelBase.isMaxDate(jsonDate)

Returns true, if the given date in c# format represents the maximum possible date value.

ModelBase.parseDateDisplay(jsonDate)

Format a given date string in c# date format (for example /Date(1245398693390)/) into the standard date format in a human-readable presentation.

Arguments
  • jsonDate (string()) – Input date in c# date format when encoding c# DateTime objects as JSON.

ModelBase.parseDateTimeDisplay(jsonDate)

Format a given date and time string in c# date/time format (for example /Date(1245398693390)/) into the standard date and time format in a human-readable presentation.

Arguments
  • jsonDate (string()) – Input date in c# date format when encoding c# DateTime objects as JSON.

ModelBase.encodeCustomFieldDate(d)

Return the given date encoded in a specific format that is required for custom field data based on the given Javascript date object.

Arguments
  • d (date()) – Javascript date object.

ModelBase.getChoicesDisplay(choices, value)

Returns the display label of the given encoding value based on the given list of choices.

Arguments
  • choices (array()) – List of name/value pairs representing possible a list of possible choices - mapping an encoding value to a presentation label.

  • value (object()) – The encoded value for which the corresponding display label is returned.

ModelBase.getChoicesAsPairs(choices)

Return the given choices as label/value pairs. The result is an array of objects, where each object encodes the properties label and value.

Arguments
  • choices (array()) – List of choices that is converted into a list of name/value pairs.

ModelBase.toJsonDict(dotnetDictionary)
Map a c# dictionary encoding via JSON into a plain object literal

(object properties).

Arguments
  • dotnetDictionary (array()) – c# dictionary encoding via JSON.

ModelBase.toBoolOrNull(value)

Parse given value as a boolean (true or false) or null. For possible boolean expressions, this method will convert 0, 1, no and yes (case-insensitive). For all other cases, null is returned.

Arguments
  • value (object()) – Input object that is converted into a boolean value.

ModelBase.getCustomFieldDictionary(customFieldDescription, customFields)

Return a document-level custom field dictionary object (as required by the default JSON encoding of c# Dictionary objects) based on the given custom field values.

Arguments
  • customFieldDescription (object()) – Meta information about all document-level custom fields that the system supports.

  • customFields (object()) – Custom field values.