Kayako User 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+-+User
since Kayako version 4.01.204
package Object\User

 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

Adds an e-mail to the list user e-mails.

addEmail(string $email, bool $clear) 

Parameters

$email

string

E-mail address.

$clear

bool

Clear the list before adding.

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

createNew(string $full_name, string $email, \kyUserGroup $user_group, string $password) : \kyUser

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

Parameters

$full_name

string

Full name of new user.

$email

string

E-mail address of new user.

$user_group

\kyUserGroup

User group of new user.

$password

string

Password of new user.

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 all users.

getAll(int $starting_user_id, int $max_items) : \kyResultSet

Optionaly you can get segment of user objects by defining starting user identifier and maximum items count.

Parameters

$starting_user_id

int

Optional starting user identifier.

$max_items

int

Optional maximum items count. Defaults to 1000 when starting user is defined.

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 date and time when the user was created.

getDateline(string $format) : string

see \global\http://www.php.net/manual/en/function.date.php
filterBy
orderBy

Parameters

$format

string

Output format of the date. If null the format set in client configuration is used.

Returns

string

Return designation of the user.

getDesignation() : string

filterBy
orderBy

Returns

string

Returns first e-mail from the list of user e-mails.

getEmail() : string

Returns

string

Returns list of user e-mails.

getEmails() : string[]

filterBy name=Email

Returns

string[]

Returns whether the user has enabled daylight saving time.

getEnableDST() : bool

filterBy

Returns

bool

Returns full name of the user.

getFullName() : string

filterBy
orderBy

Returns

string

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 whether the user is enabled.

getIsEnabled() : bool

filterBy

Returns

bool

Returns date and time when the user last logged in.

getLastVisit(string $format) : string

see \global\http://www.php.net/manual/en/function.date.php
filterBy
orderBy

Parameters

$format

string

Output format of the date. If null the format set in client configuration is used.

Returns

string

Returns phone number of the user.

getPhone() : string

filterBy

Returns

string

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 expiration date of Service Level Agreement plan assignment or null when expiration is disabled.

getSLAPlanExpiry(string $format) : string

see \global\http://www.php.net/manual/en/function.date.php
filterBy
orderBy

Parameters

$format

string

Output format of the date. If null the format set in client configuration is used.

Returns

string

Return Service Level Agreement plan assigned to the user.

getSLAPlanId() : int

filterBy

Returns

int

Returns salutation of the user.

getSalutation() : string

see \global\kyUser::SALUTATION
filterBy
orderBy

Returns

string

Returns timezone of the user.

getTimezone() : string

filterBy

Returns

string

Returns expiration date of the user or null when expiration is disabled.

getUserExpiry(string $format) : string

see \global\http://www.php.net/manual/en/function.date.php
filterBy
orderBy

Parameters

$format

string

Output format of the date. If null the format set in client configuration is used.

Returns

string

Returns user group of the user.

getUserGroup(bool $reload) : \kyUserGroup

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 user group identifier of the user.

getUserGroupId() : int

filterBy
orderBy

Returns

int

Returns user organization assigned to the user.

getUserOrganization(bool $reload) : \kyUserOrganization

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 user organization assigned to the user.

getUserOrganizationId() : int

filterBy
orderBy

Returns

int

Returns role of the user.

getUserRole() : string

see \global\kyUser:ROLE
filterBy
orderBy

Returns

string

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

Creates new ticket with this User as the author.

newTicket(\kyDepartment $department, string $contents, string $subject) : \kyTicket

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

Parameters

$department

\kyDepartment

Department where the ticket will be created.

$contents

string

Contents of the first post.

$subject

string

Subject of the 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 designation of the user.

setDesignation(string $designation) : \kyUser

Parameters

$designation

string

Designation of the user.

Returns

Sets whether the user has enabled daylight saving time.

setEnableDST(bool $enable_dst) : \kyUser

Parameters

$enable_dst

bool

True, to enable daylight saving time. False, to disable daylight saving time.

Returns

Sets full name of the user.

setFullName(string $full_name) : \kyUser

Parameters

$full_name

string

Full name of the user.

Returns

Sets whether the user is enabled.

setIsEnabled(bool $is_enabled) : \kyUser

Parameters

$is_enabled

bool

True, to enable the user. False, to disable the user.

Returns

Sets password of the user.

setPassword(string $password) : \kyUser

Parameters

$password

string

Password of the user.

Returns

Sets phone number of the user.

setPhone(string $phone) : \kyUser

Parameters

$phone

string

Phone number of the user.

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 expiration date of Service Level Agreement plan assignment.

setSLAPlanExpiry(string | int | null $sla_plan_expiry) : \kyUser

see \global\http://www.php.net/manual/en/function.strtotime.php

Parameters

$sla_plan_expiry

stringintnull

Date and time when Service Level Agreement plan for this user will expire (timestamp or string format understood by PHP strtotime). Null to disable expiration.

Returns

Sets identifier of the Service Level Agreement plan assigned to the user.

setSLAPlanId(int $sla_plan_id) : \kyUser

Parameters

$sla_plan_id

int

Service Level Agreement plan identifier.

Returns

Sets salutation of the user.

setSalutation(string $salutation) : \kyUser

see \global\kyUser::SALUTATION

Parameters

$salutation

string

User salutation.

Returns

Sets whether to send welcome email to new user.

setSendWelcomeEmail(bool $send_welcome_email) : \kyUser

Parameters

$send_welcome_email

bool

True, to send welcome email to new user. False, otherwise.

Returns

Sets timezone of the user.

setTimezone(string $timezone) : \kyUser

See http://php.net/manual/en/timezones.php for list of available timezones.

Parameters

$timezone

string

Timezone of the user.

Returns

Sets expiration date of the user.

setUserExpiry(string | int | null $user_expiry) : \kyUser

see \global\http://www.php.net/manual/en/function.strtotime.php

Parameters

$user_expiry

stringintnull

Date and time when the user will expire (timestamp or string format understood by PHP strtotime). Null to disable expiration.

Returns

Sets user group for the user.

setUserGroup(\kyUserGroup $user_group) : \kyUser

Parameters

$user_group

\kyUserGroup

User group.

Returns

Sets user group identifier of the user.

setUserGroupId(int $user_group_id) : \kyUser

Parameters

$user_group_id

int

User group identifier.

Returns

Sets user organization assigned to the user.

setUserOrganization(\kyUserOrganization $user_organization) : \kyUser

Parameters

$user_organization

\kyUserOrganization

User organization.

Returns

Sets user organization assigned the user by its identifier.

setUserOrganizationId(int $user_organization_id) : \kyUser

Parameters

$user_organization_id

int

User organization identifier.

Returns

Sets role of the user.

setUserRole(string $user_role) : \kyUser

see \global\kyUser:ROLE

Parameters

$user_role

string

User role.

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.

 

Timestamp of when the user was created.

$dateline : int

apiField
 

User designation.

$designation : string

apiField
 

List of user's e-mail addresses.

$email : string[]

apiField required_create=true
 

If Daylight Saving Time is enabled for the user.

$enable_dst : bool

apiField
 

Full name of the user.

$full_name : string

apiField required=true
 

User identifier.

$id : int

apiField
 

Whether this user is enabled.

$is_enabled : bool

apiField
 

Timestamp of when the user last visited support center.

$last_visit : int

apiField
 

Indicates the name of object element in XML response.

$object_xml_name : string

Override in descending classes.

 

User password.

$password : string

apiField required_create=true
 

User phone number.

$phone : string

apiField
 

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

$read_only : bool
Inherited

Override in descending classes.

inherited_from \kyObjectBase::$$read_only
 

User salutation.

$salutation : string

see \global\kyUser::SALUTATION
apiField
 

Whether welcome e-mail should be send upon creation of the user.

$send_welcome_email : bool

apiField
 

Timestamp of when the Service Level Agreement plan associated to this user will expire.

$sla_plan_expiry : int

apiField
 

Identifier of Service Level Agreement plan associated to this user.

$sla_plan_id : int

apiField
 

Timezone of the user.

$timezone : string

apiField
 

Timestamp of when the user will expire.

$user_expiry : int

apiField
 

User group identifier.

$user_group_id : int

apiField required_create=true
 

User organization identifier.

$user_organization_id : int

apiField
 

User role.

$user_role : string

see \global\kyUser::ROLE
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
 

Group of the user.

$user_group : \kyUserGroup

 

Organization of the user.

$user_organization : \kyUserOrganization

 Constants

 

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

FILES_DATA_NAME : string
Inherited

inherited_from \kyObjectBase::FILES_DATA_NAME
 

ROLE_MANAGER

ROLE_MANAGER 

 

ROLE_USER

ROLE_USER 

 

SALUTATION_DR

SALUTATION_DR 

 

SALUTATION_MISS

SALUTATION_MISS 

 

SALUTATION_MR

SALUTATION_MR 

 

SALUTATION_MRS

SALUTATION_MRS