Kayako Department object.

All objects interacting with Kayako REST API should extend this class and define: * Kayako controller * XML element name holding object's data in REST response

author Tomasz Sawicki (https://github.com/Furgas)
link http://wiki.kayako.com/display/DEV/REST+-+Department
since Kayako version 4.01.204
package Object

 Methods

Default constructor.

__construct(array $data) 
Inherited

inherited_from \kyObjectBase::__construct()

Parameters

$data

array

Object data from XML response converted into array.

Returns API field value.

__get(string $api_field_name) : mixed
Inherited

Returns API field value based on API field name used by Kayako.

link http://wiki.kayako.com/display/DEV/REST+API+Reference
inherited_from \kyObjectBase::__get()

Parameters

$api_field_name

string

API field name.

Returns

mixed

Sets API field value.

__set(string $api_field_name, mixed $value) : mixed
Inherited

Sets API field value based on API field name used by Kayako.

link http://wiki.kayako.com/display/DEV/REST+API+Reference
inherited_from \kyObjectBase::__set()

Parameters

$api_field_name

string

API field name.

$value

mixed

API field value.

Returns

mixed

Returns object description with it's type and identifier.

__toString() : string
Inherited

Calls toString() method to get the object description.

inherited_from \kyObjectBase::__toString()

Returns

string

Add user group to the list of groups that can be assigned to this department.

addUserGroup(\kyUserGroup $user_group, bool $clear) : \kyDepartment

Automatically sets custom user visibility flag to True.

Parameters

$user_group

\kyUserGroup

User group that can be assigned to this department.

$clear

bool

Clear the list before adding.

Returns

Should build the array of object data for creating or updating the object.

buildData(bool $create) : array

Values must be set in format accepted by REST API.

Parameters

$create

bool

Indicates if the result will be used to create (true) or update (false) an object.

Returns

array

Checks wheter this object has all required fields set.

checkRequiredAPIFields(bool $create, bool $throw_exception) : string[] | bool
Inherited

inherited_from \kyObjectBase::checkRequiredAPIFields()

Parameters

$create

bool

True when object will be created. False when object will be updated.

$throw_exception

bool

True to throw an exception on missing fields. False to return list of missing fields or true when there are none.

Exceptions

\kyException When there are missing field values and $throw_exception is true.

Returns

string[]boolList of missing API fields or true when there are none.

Creates an object on the server and refreshes its local data.

create() : \kyObjectBase
Inherited

inherited_from \kyObjectBase::create()

Exceptions

\BadMethodCallException
\kyException

Returns

Creates new department.

createNew(string $title, string $type, string $module) : \kyDepartment

WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result.

Parameters

$title

string

Title of new department.

$type

string

Type of new department - one of kyDepartment::TYPE_* constants.

$module

string

Module of new department - one of kyDepartment::MODULE_* constants.

Returns

Deletes the object on the server.

delete() 
Inherited

inherited_from \kyObjectBase::delete()

Fetches the object from server.

get(int | array $id) : \kyObjectBase
Inherited

inherited_from \kyObjectBase::get()

Parameters

$id

intarray

Object identifier or list of identifiers (ex. ticket identifier and ticket post identifier when fetching TicketPost).

Returns

Returns array of API fields.

getAPIFields() : string[]
Inherited

Format of returned array:

array(
    '' => Field description. (getter: , setter: ),
    ...repeat...
)

inherited_from \kyObjectBase::getAPIFields()

Returns

string[]

Fetches objects from server.

getAll(array $search_parameters) : \kyResultSet
Inherited

inherited_from \kyObjectBase::getAll()

Parameters

$search_parameters

array

Optional. Additional search parameters.

Returns

Returns list of available filter methods for use in result sets with objects of this type.

getAvailableFilterMethods(bool $filter_names_only) : array
Inherited

Optionaly you can return get method names used to filter objects.

inherited_from \kyObjectBase::getAvailableFilterMethods()

Parameters

$filter_names_only

bool

True (default) to return array('filterByXXX', 'filterByYYY', ...). False to return array('filterByXXX' => 'getXXX', 'filterByYYY' => 'YYY', ...).

Returns

array

Returns list of available order methods for use in result sets with objects of this type.

getAvailableOrderMethods(bool $order_names_only) : array
Inherited

Optionaly you can return get method names used to order objects.

inherited_from \kyObjectBase::getAvailableOrderMethods()

Parameters

$order_names_only

bool

True (default) to return array('orderByXXX', 'orderByYYY', ...). False to return array('orderByXXX' => 'getXXX', 'orderByYYY' => 'YYY', ...).

Returns

array

Returns object controller.

getController() : string
Inherited

inherited_from \kyObjectBase::getController()

Returns

string

Returns display order of the department.

getDisplayOrder() : int

filterBy
orderBy

Returns

int

Should return object identifier or complete list of identifiers as needed by API to identify the object (ex.

getId(bool $complete) : int | array

ticket identifier and ticket post identifier in case of TicketPost).

Parameters

$complete

bool

True to return complete list of identifiers as needed by API to identify the object.

Returns

intarray

Returns module the department is associated with.

getModule() : string

see \global\kyDepartment::MODULE
filterBy
orderBy

Returns

string

Returns department object that is the parent for this department.

getParentDepartment(bool $reload) : \kyDepartment

Result is cached until the end of script.

Parameters

$reload

bool

True to reload data from server. False to use the cached value (if present).

Returns

Returns identifier of parent department for this department.

getParentDepartmentId() : int

filterBy
orderBy

Returns

int

Returns list of required API fields for objects of this class.

getRequiredAPIFields(bool $create) : string[]
Inherited

inherited_from \kyObjectBase::getRequiredAPIFields()

Parameters

$create

bool

True when object will be created. False when object will be updated.

Returns

string[]

Returns title of the department.

getTitle() : string

filterBy
orderBy

Returns

string

Return type of the department.

getType() : string

see \global\kyDepartment::TYPE
filterBy
orderBy

Returns

string

Returns identifiers of user groups that can be assigned to this department.

getUserGroupIds() : array

filterBy name=UserGroupId

Returns

array

Returns user groups that can be assigned to this department.

getUserGroups(bool $reload) : \kyResultSet

Result is cached until the end of script.

Parameters

$reload

bool

True to reload data from server. False to use the cached value (if present).

Returns

Returns true to indicate that visibility of this department is restricted to particular user groups.

getUserVisibilityCustom() : bool

Use getUserGroupIds to get their identifiers or getUserGroups to get the objects.

filterBy

Returns

bool

Returns whether the object is new and not yet saved on the server.

isNew() : bool
Inherited

inherited_from \kyObjectBase::isNew()

Returns

bool

Returns whether this object is read only.

isReadOnly() : bool
Inherited

inherited_from \kyObjectBase::isReadOnly()

Returns

bool

Returns whether this department is visible to specified user group.

isVisibleToUserGroup(\kyUserGroup | int $user_group) : bool

filterBy

Parameters

$user_group

\kyUserGroupint

User group or its identifier.

Returns

bool

Creates new subdepartment in this department.

newSubdepartment(string $title, string $type) : \kyDepartment

Module of new department will be the same as parent department's module. WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result.

Parameters

$title

string

Title of new department.

$type

string

Type of new department - one of kyDepartment::TYPE_* constants.

Returns

Creates new ticket in this department with creator user automatically created by server using provided name and e-mail.

newTicketAuto(string $creator_full_name, string $creator_email, string $contents, string $subject) : \kyTicket

WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result.

Parameters

$creator_full_name

string

Creator full name.

$creator_email

string

Creator e-mail.

$contents

string

Contents of the first post.

$subject

string

Subject of new ticket.

Returns

Refreshes the object data from server.

refresh() : \kyObjectBase
Inherited

inherited_from \kyObjectBase::refresh()

Exceptions

\BadMethodCallException

Returns

Saves (creates or updates) the object to the server.

save() : \kyObjectBase
Inherited

inherited_from \kyObjectBase::save()

Returns

Sets display order of the department.

setDisplayOrder(int $display_order) : \kyDepartment

Parameters

$display_order

int

A positive integer that the helpdesk will use to sort departments when displaying them (ascending).

Returns

Sets module the department will be associated with.

setModule(string $module) : \kyDepartment

see \global\kyDepartment::MODULE

Parameters

$module

string

Module the department will be associated with.

Returns

Sets parent department for this department.

setParentDepartment(\kyDepartment $parent_department) : \kyDepartment

Parameters

$parent_department

\kyDepartment

Department object that will be the parent for this department.

Returns

Sets the identifier of parent department for this department.

setParentDepartmentId(int $parent_department_id) : \kyDepartment

Parameters

$parent_department_id

int

Identifier of department that will be the parent for this department.

Returns

Sets whether this object is read only.

setReadOnly(bool $read_only) : bool
Inherited

inherited_from \kyObjectBase::setReadOnly()

Parameters

$read_only

bool

Read only flag.

Returns

bool

Sets title of the department.

setTitle(string $title) : \kyDepartment

Parameters

$title

string

Title of the department.

Returns

Sets type of the department.

setType(string $type) : \kyDepartment

see \global\kyDepartment::TYPE

Parameters

$type

string

Type of the department.

Returns

Sets user groups that can be assigned to this department using their identifiers.

setUserGroupIds(int[] $user_group_ids) : \kyDepartment

Parameters

$user_group_ids

int[]

Identifiers of user groups that can be assigned to this department.

Returns

Sets wheter to restrict visibility of this department to particular user groups.

setUserVisibilityCustom(bool $user_visibility_custom) : \kyDepartment

Use setUserGroupIds to set these groups using identifiers or addUserGroup to set them using objects. Automatically clears user groups when set to false.

Parameters

$user_visibility_custom

bool

True to restrict visibility of this department to particular user groups. False otherwise.

Returns

Should return short (one line) description of the object (it's title, name, etc.).

toString() : string

Returns

string

Updates the object on the server and refreshes its local data.

update() : \kyObjectBase
Inherited

inherited_from \kyObjectBase::update()

Exceptions

\BadMethodCallException
\kyException

Returns

Returns REST client.

getRESTClient() : \kyRESTClientInterface
Inherited

inherited_from \kyObjectBase::getRESTClient()

Returns

Should use passed data to fill object properties.

parseData(array $data) 

Parameters

$data

array

Object data from XML response.

Builds API fields list.

initAPIFieldsAccessors() 
Inherited

Scans protected and private properties of called class, searches for

apiField [name=field name] [accessor=setter/getter name] [getter=getter name] [setter=setter name] [required_create=true if field if required when creating object] [required_update=true if field if required when udpating object] [required=true if field if required when creating or updating object] and builds API field list with property name, description, setter and getter method names, and required flags.
see \global\kyObjectBase::$_api_fields
inherited_from \kyObjectBase::initAPIFieldsAccessors()

 Properties

 

Cache for available filter methods.

$_filter_methods : string[]
Inherited

Format: array( '' => array( '' => '', ...repeat for every filtering enabled method... ), ...repeat for every object class... )

inherited_from \kyObjectBase::$$_filter_methods
 

Cache for available order methods.

$_order_methods : string[]
Inherited

Format: array( '' => array( '' => '', ...repeat for every ordering enabled method... ), ...repeat for every object class... )

inherited_from \kyObjectBase::$$_order_methods
 

Default Kayako controller used to operate on this objects.

$controller : string

Override in descending classes.

 

Department display order.

$display_order : int

apiField
 

Department identifier.

$id : int

apiField
 

Department module.

$module : int

apiField required_create=true
 

Indicates the name of object element in XML response.

$object_xml_name : string

Override in descending classes.

 

Parent department identifier.

$parent_department_id : int

apiField
 

Controls if the object can be created/updated/deleted.

$read_only : bool
Inherited

Override in descending classes.

inherited_from \kyObjectBase::$$read_only
 

Department title.

$title : string

apiField required=true
 

Department type.

$type : int

apiField required_create=true
 

User group identifiers this department is visible to.

$user_group_ids : int[]

apiField name=usergroups
 

If this department is visible to specific user groups only.

$user_visibility_custom : bool

see \global\kyDepartment::$user_group_ids
apiField
 

Cache for API fields.

$_api_fields : array
Inherited

Format: array( '' => array( '' => array( 'property' => '', 'description' => '', 'getter' => '', 'setter' => '', 'required_create' => , 'required_update' => ), ...repeat for every class api field... ), ...repeat for every object class... )

inherited_from \kyObjectBase::$$_api_fields
 

Parent department.

$parent_department : \kyDepartment

 

User groups this department is visible to.

$user_groups : \kyUserGroup[]

 Constants

 

Data key for storing files to send as multipart/form-data.

FILES_DATA_NAME : string
Inherited

inherited_from \kyObjectBase::FILES_DATA_NAME
 

Module a department can be associated with - Livechat.

MODULE_LIVECHAT : string

 

Module a department can be associated with - Tickets.

MODULE_TICKETS : string

 

Type of department - private.

TYPE_PRIVATE : string

 

Type of department - public.

TYPE_PUBLIC : string