Kayako TicketTimeTrack 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+-+TicketTimeTrack
since Kayako version 4.01.240
package Object\Ticket

 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

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 ticket time track.

createNew(\kyTicket $ticket, string $contents, \kyStaff $staff, string $time_worked, string $time_billable) : \kyTicketTimeTrack

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

Parameters

$ticket

\kyTicket

Ticket to attach the timetrack to.

$contents

string

Note contents.

$staff

\kyStaff

Staff user - both creator and worker.

$time_worked

string

Worked time formatted as hh:mm. Work date will be set to current datetime.

$time_billable

string

Billable time formatted as hh:mm. Bill date will be set to current datetime.

Returns

Deletes the object on the server.

delete() 
Inherited

inherited_from \kyObjectBase::delete()

Returns ticket time track.

get(int $ticket_id, int $id) : \kyTicketTimeTrack

Parameters

$ticket_id

int

Ticket identifier.

$id

int

Ticket time track identifier.

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[]

Returns all time tracks of the ticket.

getAll(int $ticket_id) : \kyResultSet

Parameters

$ticket_id

int

Ticket identifier.

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 date and time when to bill the worker.

getBillDate(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 contents of the time track.

getContents() : string

filterBy

Returns

string

Returns object controller.

getController() : string
Inherited

inherited_from \kyObjectBase::getController()

Returns

string

Returns staff user that creates the time track.

getCreatorStaff(bool $reload) : \kyStaff

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 staff user that created the time track.

getCreatorStaffId() : int

filterBy
orderBy

Returns

int

Returns full name of staff user that created the time track.

getCreatorStaffName() : 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 color of the time track - one of kyTicketTimeTrack::COLOR_* constants.

getNoteColor() : int

see \global\kyTicketTimeTrack::COLOR

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 the ticket that this time track is connected with.

getTicket(bool $reload) : \kyTicket

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 ticket identifier of this time track.

getTicketId() : int

Returns

int

Returns billable time for this time track.

getTimeBillable(bool $formatted) : int | string

filterBy
orderBy

Parameters

$formatted

bool

True to format result nicely (ex. 02:30:00). False to return amount of seconds.

Returns

intstring

Returns time worked for this time track.

getTimeWorked(bool $formatted) : int | string

filterBy
orderBy

Parameters

$formatted

bool

True to format result nicely (ex. 02:30:00). False to return amount of seconds.

Returns

intstring

Returns date and time when the work was executed.

getWorkDate(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 staff user object that has done the work.

getWorkerStaff(bool $reload) : \kyStaff

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 staff user that has done the work.

getWorkerStaffId() : int

filterBy
orderBy

Returns

int

Returns full name of staff user that has done the work.

getWorkerStaffName() : string

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

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 date and time when to bill the worker.

setBillDate(string | int $bill_date) : \kyTicketTimeTrack

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

Parameters

$bill_date

stringint

Date and time when the work was executed (timestamp or string format understood by PHP strtotime).

Returns

Shortcut function for setting billable time and when to bill the worker.

setBillingData(string | int $time_billable, string $bill_date) 

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

Parameters

$time_billable

stringint

Billable time (as seconds or formatted as hh:mm).

$bill_date

string

Date and time when to bill the worker (timestamp or string format understood by PHP strtotime). Defaults to current datetime.

Sets contents of the time track.

setContents(string $contents) : \kyTicketTimeTrack

Parameters

$contents

string

Contents of the time track.

Returns

Sets staff user that creates the time track.

setCreatorStaff(\kyStaff $creator_staff) : \kyTicketTimeTrack

Parameters

$creator_staff

\kyStaff

Staff user that creates the time track.

Returns

Sets the identifier of staff user that creates the time track.

setCreatorStaffId(int $creator_staff_id) : \kyTicketTimeTrack

Parameters

$creator_staff_id

int

Identifier of staff user that creates the time track.

Returns

Sets color of the time track.

setNoteColor(int $note_color) : \kyTicketTimeTrack

see \global\kyTicketTimeTrack::COLOR

Parameters

$note_color

int

Color of the time track - one of kyTicketTimeTrack::COLOR_* constants.

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 the ticket that this time track will be connected with.

setTicket(\kyTicket $ticket) : \kyTicketTimeTrack

Parameters

$ticket

\kyTicket

Ticket.

Returns

Sets ticket identifier of the time track.

setTicketId(int $ticket_id) : \kyTicketTimeTrack

Parameters

$ticket_id

int

Ticket identifier of the time track

Returns

Sets billable time for this time track.

setTimeBillable(string | int $time_billable) : \kyTicketTimeTrack

Parameters

$time_billable

stringint

Billable time (as seconds or formatted as hh:mm).

Returns

Sets worked time for this time track.

setTimeWorked(string | int $time_worked) : \kyTicketTimeTrack

Parameters

$time_worked

stringint

Worked time (as seconds or formatted as hh:mm).

Returns

Sets date and time when the work was executed.

setWorkDate(string | int $work_date) : \kyTicketTimeTrack

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

Parameters

$work_date

stringint

Date and time when the work was executed (timestamp or string format understood by PHP strtotime).

Returns

Shortcut function for setting worked time and when the work was executed.

setWorkedData(string | int $time_worked, string $work_date) 

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

Parameters

$time_worked

stringint

Worked time (as seconds or formatted as hh:mm).

$work_date

string

Date and time when the work was exectued (timestamp or string format understood by PHP strtotime). Defaults to current datetime.

Sets staff user that has done the work.

setWorkerStaff(\kyStaff $worker_staff) : \kyTicketTimeTrack

Parameters

$worker_staff

\kyStaff

Staff user that has done the work.

Returns

Sets the identifier of staff user that has done the work.

setWorkerStaffId(int $worker_staff_id) : \kyTicketTimeTrack

Parameters

$worker_staff_id

int

Identifier of staff user that has done the work.

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

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
 

Bill timestamp of this ticket time track.

$bill_date : int

apiField required_create=true alias=billtimeline
 

Note contents of this ticket time track.

$contents : int

apiField required_create=true
 

Default Kayako controller used to operate on this objects.

$controller : string

Override in descending classes.

 

Creator staff identifier.

$creator_staff_id : int

apiField required_create=true alias=staffid
 

Creator staff full name.

$creator_staff_name : string

apiField
 

Ticket time track identifier.

$id : int

apiField
 

Ticket time track note color.

$note_color : int

see \global\kyTicketTimeTrack::COLOR
apiField
 

Indicates the name of object element in XML response.

$object_xml_name : string

Override in descending classes.

 

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

$read_only : bool
Inherited

Override in descending classes.

inherited_from \kyObjectBase::$$read_only
 

Ticket identifier.

$ticket_id : int

apiField required_create=true
 

Billable time (in seconds) in this ticket time track.

$time_billable : int

apiField required_create=true
 

Time worked (in seconds) in this ticket time track.

$time_worked : int

apiField required_create=true alias=timespent
 

Work timestamp of this ticket time track.

$work_date : int

apiField required_create=true alias=worktimeline
 

Worker staff identifier.

$worker_staff_id : int

apiField
 

Worker staff full name.

$worker_staff_name : string

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
 

Creator staff.

$creator_staff : \kyStaff

 

The ticket that this time track will be connected with.

$ticket : \kyTicket

 

Worker staff.

$worker_staff : \kyStaff

 Constants

 

Color of time track - blue.

COLOR_BLUE : int

 

Color of time track - green.

COLOR_GREEN : int

 

Color of time track - purple.

COLOR_PURPLE : int

 

Color of time track - red.

COLOR_RED : int

 

Color of time track - yellow.

COLOR_YELLOW : int

 

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

FILES_DATA_NAME : string
Inherited

inherited_from \kyObjectBase::FILES_DATA_NAME