main

API Reference from the most important classes in the API

The main classes are the classes that are needed in almost every function you want to run or event you want to listen for. There are not many of them and their function is quite easy. These variables are mainly used for control and they make sure that there will be less errors with larger functions.

Table of contents

Name
Description

This class is used as ID in many places where things need to be registered. This way, they can be found back quite easily!

The OTVersion class is used for specifying a version of something, but can also be used to compare and check compatibility between versions.

OTMain is the "main" entrance point of the API, it includes all managers where you can register new languages, configs & databases. It's like the highway of the API. This variable is accessible via the global variable openticket!

Reference

class OTId:

constructor(id: String) => OTId Creates an OTId from a string. This class is used in almost every other function!

example usage:
openticket.database.findDatabase(new OTId("openticket_global_database"))

static idValidator(id: String|OTId) => OTId Accepts a String or OTId as input and always returns OTId. This static function is always used on places where an OTId is needed. This way, you can also put a string instead of typing the entire OTId constructor.

example usage:
api.OTId.idValidator("openticket_global_database") //will return OTId from this string
api.OTId.idValidator(new OTId("another_id")) // will just return the same variable

class variables:

Variable
Type
Description

value

String

This is the string representation of the ID.

class OTVersion:

constructor(id: String|OTId, primary: Number, secondary: Number, tertiary: Number) => OTVersion This constructor creates an OTVersion from the 3 numbers. The ID is for differentiating versions from different things/plugins/classes. The version will be constructed with the 3 numbers in the following way: primary.secondary.tertiary so when the numbers are 4, 2, 8. Then the OTVersion will be generated like this: v4.2.8

getStringVersion() => String This function returns a string representation from the OTVersion class. It will always start with the letter v and the numbers will be separated by dots.

compare(secondVersion: OTVersion) => "higher"|"equal"|"lower"|false The compare function compares the current version with the secondVersion and tells you if it's higher, equal, lower or none of these. Returns one of the 3 Strings or false on error.

compatible(list: OTVersion[]) => Boolean The compatible function checks if the list includes the current version. It can be used for plugins that support multiple open ticket versions at the same time.

class variables:

Variable
Type
Description

id

The name of the thing that this OTVersion tells the version for.

primary

Number

The first digit in the version.

secondary

Number

The second digit in the version.

tertiary

Number

The third digit in the version.

class OTMain:

constructor(options: OTMainConstructorOptions) => OTMain Create the OTMain class. This can't be executed by plugins because the plugins require this class to work. Most of the options will be directly assigned to one of the variables in this class.

on(event: String, callback: Function) => void With this function, you can listen for events broadcasted by open ticket. More info about events can be found here:

listening for events

once(event: String, callback: Function) => void With this function, you can listen for events broadcasted by open ticket once! More info about events can be found here:

listening for events

emit(event: String, handler: Function) => void This function is used by open ticket to broadcast events for other plugins. This can also be used by plugins to emit events to other plugins. More info about that can be found here:

emitting events

class variables:

Variable
Type
Description

config

Manager for all config related actions.

database

OTDatabaseManager

Manager for all database related actions.

language

OTLanguageManager

Manager for all translation related actions.

versions

Object

Collection of open ticket versions, more info below

class variables/versions:

Variable
Type
Description

openticket

Open Ticket version.

api

API version.

transcripts

HTML Transcript version.

livestatus

Livestatus system version.

Last updated

Was this helpful?