public static function demo() { echo "LiquidPlanner email: "; $email = trim(fgets(STDIN)); echo "LiquidPlanner password for {$email}: "; system('stty -echo'); $password = trim(fgets(STDIN)); system('stty echo'); echo PHP_EOL; $lp = new LiquidPlanner($email, $password); $workspaces = $lp->workspaces(); $lp->workspace_id = $workspaces[0]->id; $help = $lp->help(); if (!isset($help->Task) || !isset($help->Task->assignments)) { print "LiquidPlanner does not yet support multiple owners" . PHP_EOL; exit; } $two_tasks = $lp->tasks("?limit=2"); $two_events = $lp->events("?limit=2"); if (count($two_tasks) < 2 || count($two_events) < 2) { print "Make sure you have at least two tasks and at least two events." . PHP_EOL; exit; } $lp->member_lookup = $lp->workspace_members(); $lp->team_lookup = $lp->workspace_teams(); print "We're going to swap ownership for the first two tasks, and the " . "two events: " . PHP_EOL; print "Tasks: (before)" . PHP_EOL; foreach ($two_tasks as &$task) { $lp->inspect_ownership($task); } print "Events: (before)" . PHP_EOL; foreach ($two_events as &$event) { $lp->inspect_ownership($event); } list($assignment_1, $assignment_2) = array_map(function ($task) { return $task->assignments[0]; }, $two_tasks); $two_tasks[0] = $lp->update_assignment($two_tasks[0]->id, array("assignment_id" => $assignment_1->id, "person_id" => isset($assignment_2->person_id) ? $assignment_2->person_id : NULL, "team_id" => isset($assignment_2->team_id) ? $assignment_2->team_id : NULL)); $two_tasks[1] = $lp->update_assignment($two_tasks[1]->id, array("assignment_id" => $assignment_2->id, "person_id" => isset($assignment_1->person_id) ? $assignment_1->person_id : NULL, "team_id" => isset($assignment_1->team_id) ? $assignment_1->team_id : NULL)); list($assignment_1, $assignment_2) = array_map(function ($event) use($lp) { return $lp->event_owners($event); }, $two_events); $two_events[0] = $lp->update_assignment($two_events[0]->id, $assignment_2); $two_events[1] = $lp->update_assignment($two_events[1]->id, $assignment_1); print "Tasks: (after)" . PHP_EOL; foreach ($two_tasks as &$task) { $lp->inspect_ownership($task); } print "Events: (after)" . PHP_EOL; foreach ($two_events as &$event) { $lp->inspect_ownership($event); } }