/**
  * Creates new subdepartment in this department. 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.
  *
  * @param string $title Title of new department.
  * @param string $type Type of new department - one of kyDepartment::TYPE_* constants.
  * @return kyDepartment
  */
 public function newSubdepartment($title, $type = self::TYPE_PUBLIC)
 {
     $new_department = kyDepartment::createNew($title, $type, $this->getModule());
     $new_department->setParentDepartment($this);
     return $new_department;
 }
 * Create subdepartment in General department:
 * title: Printers (example)
 * type: public (default)
 * module: tickets (default)
 * WARNING
 * It's not currently possible to assign staff groups to departments via API. You must do it using Admin Control Panel.
 */
$printers_department = $general_department->newSubdepartment("Printers (example)")->create();
print 'Created: ' . $printers_department;
/**
 * Create some livechat department:
 * title: Urgent problems (example)
 * type: public
 * module: livechat
 */
$livechat_department = kyDepartment::createNew("Urgent problems (example)", kyDepartment::TYPE_PUBLIC, kyDepartment::MODULE_LIVECHAT)->create();
print 'Created: ' . $livechat_department;
/**
 * Create a staff group:
 * title: Lazy guys (example)
 * isadmin: false (default)
 */
$lazy_staff_group = kyStaffGroup::createNew("Lazy guys (example)")->create();
print 'Created: ' . $lazy_staff_group;
/**
 * Create a staff user in just created staff group:
 * firstname: John
 * lastname: Doe
 * username: lazyguy
 * email: john.doe@lazycorp.com
 * password: veryhardpassword