User

Table of contents

See how to create a $factory

List users

Retrieve all users

Usage

$response = $factory->users()->listUsers($isActive, $updatedSince, $meta);
$response instanceof \Lsv\TimeharvestSdk\Response\User\UsersResponse
$meta = $response->getMeta();
$meta instanceof \Lsv\TimeharvestSdk\Response\MetaResponse
foreach ($response->getData() as $client) {
    $client instanceof \Lsv\TimeharvestSdk\Response\User\UserData
}

Parameters

Parameter Required Type Description
$isActive false bool Select only active or inactive clients
$updatedSince false DateTimeInterface Only select clients updated after this date
$meta false \Lsv\TimeharvestSdk\Response\MetaResponse Pagination

Response

$response->getMeta() instanceof \Lsv\TimeharvestSdk\Response\MetaResponse;
$response->getData() array of \Lsv\TimeharvestSdk\Response\User\UserData

Current user

Usage

$response = $factory->users()->me();
$response instanceof \Lsv\TimeharvestSdk\Response\User\UserResponse

Parameters

None

Response

$response->getData() instanceof \Lsv\TimeharvestSdk\Response\User\UserData

Retrieve User

Usage

$response = $factory->users()->retrieveUser($user);
$response instanceof \Lsv\TimeharvestSdk\Response\User\UserResponse

Parameters

Parameter Required Type Description
$user true int | \Lsv\TimeharvestSdk\Response\User\UserData The ID or a UserData of the user needed to be retrieved

Response

$response->getData() instanceof \Lsv\TimeharvestSdk\Response\User\UserData

Create user

Usage

$dto = new \Lsv\TimeharvestSdk\Dto\User\CreateUserDto(
    $firstName,
    $lastName,
    $email,
    $timezone,
    $hasAccessToAllFutureProjects,
    $isContractor,
    $isActive,
    $weeklyCapacity,
    $defaultHourlyRate,
    $costRate,
    $roles,
    $accessRoles,
);
$response = $factory->users()->createUser($dto);
$response instanceof \Lsv\TimeharvestSdk\Response\User\UserResponse

Parameters

Parameter Required Type Description
$firstName true string First name of the user
$lastName true string Last name of the user
$email true string Email of the user
$timezone false string User timezone
$hasAccessToAllFutureProjects false bool Whether the user should be automatically added to future projects
$isContractor false bool Whether the user is a contractor or an employee
$isActive false bool Whether the user is active or archived.
$weeklyCapacity false string The number of hours per week this person is available to work in seconds
$defaultHourlyRate false string The billable rate to use for this user when they are added to a project
$costRate false string The cost rate to use for this user when calculating a project’s costs vs billable amount
$roles false bool Descriptive names of the business roles assigned to this person
$accessRoles false string Access role(s) that determine the user’s permissions in Harvest

Response

$response->getData() instanceof \Lsv\TimeharvestSdk\Response\User\UserData

Update user

Usage

$dto = new \Lsv\TimeharvestSdk\Dto\User\UpdateUserDto(
    $firstName,
    $lastName,
    $email,
    $timezone,
    $hasAccessToAllFutureProjects,
    $isContractor,
    $isActive,
    $weeklyCapacity,
    $defaultHourlyRate,
    $costRate,
    $roles,
    $accessRoles,
);
$response = $factory->users()->updateUser($user, $dto);
$response instanceof \Lsv\TimeharvestSdk\Response\User\UserResponse

Parameters

Parameter Required Type Description
$user true int|\Lsv\TimeharvestSdk\Response\User\UserData User to update
$firstName false string First name of the user
$lastName false string Last name of the user
$email false string Email of the user
$timezone false string User timezone
$hasAccessToAllFutureProjects false bool Whether the user should be automatically added to future projects
$isContractor false bool Whether the user is a contractor or an employee
$isActive false bool Whether the user is active or archived.
$weeklyCapacity false string The number of hours per week this person is available to work in seconds
$defaultHourlyRate false string The billable rate to use for this user when they are added to a project
$costRate false string The cost rate to use for this user when calculating a project’s costs vs billable amount
$roles false bool Descriptive names of the business roles assigned to this person
$accessRoles false string Access role(s) that determine the user’s permissions in Harvest

Response

$response->getData() instanceof \Lsv\TimeharvestSdk\Response\User\UserData

Archive user

Usage

$response = $factory->users()->archiveUser($user);
$response instanceof \Lsv\TimeharvestSdk\Response\User\UserResponse

Parameters

Parameter Required Type Description
$user true int | \Lsv\TimeharvestSdk\Response\User\UserData The ID or a UserData of the user needed to be archived

Response

$response->getData() instanceof \Lsv\TimeharvestSdk\Response\User\UserData

Delete user

Usage

$response = $factory->users()->retrieveUser($user);
$response instanceof \Lsv\TimeharvestSdk\Response\NullResponse

Parameters

Parameter Required Type Description
$user true int | \Lsv\TimeharvestSdk\Response\User\UserData The ID or a UserData of the user needed to be deleted

Response

$response->getData() instanceof \Lsv\TimeharvestSdk\Response\NullResponse