} ////////////////////////////////////////////////////////////////////////////////// readline('Press enter to create two new timesheets:'); // Get jobcodes $jobcodes = $tsheets->get(ObjectType::Jobcodes, array('type' => 'regular')); // Pick a first user and jobcode to work on $user = reset($users['results']['users']); $jobcode = reset($jobcodes['results']['jobcodes']); // Create two timesheets with a single api call $request = array(); $request[] = array('user_id' => $user['id'], 'jobcode_id' => $jobcode['id'], 'type' => 'regular', 'start' => '2014-01-18T15:19:21-07:00', 'end' => '2014-01-18T16:19:21-07:00'); $request[] = array('user_id' => $user['id'], 'jobcode_id' => $jobcode['id'], 'type' => 'regular', 'start' => '2014-01-19T08:00:00-07:00', 'end' => '2014-01-19T17:10:00-07:00'); $result = $tsheets->add(ObjectType::Timesheets, $request); print "Create timesheet returned:\n"; print_r($result); ////////////////////////////////////////////////////////////////////////////////// readline('Press enter to edit a timesheet:'); // Save the new timesheet ids $timesheet_ids = array($result['results']['timesheets']['1']['id'], $result['results']['timesheets']['2']['id']); // Edit a timesheet $request = array(); $request[] = array('id' => $timesheet_ids[0], 'end' => '2014-01-18T17:19:21-07:00'); $result = $tsheets->edit(ObjectType::Timesheets, $request); print "Edit timesheet returned:\n"; print_r($result); ////////////////////////////////////////////////////////////////////////////////// readline('Press enter to delete both timesheets:'); // Delete the timesheets $result = $tsheets->delete(ObjectType::Timesheets, $timesheet_ids); print "Delete timesheet returned:\n"; print_r($result);
foreach ($reminders['results']['reminders'] as $reminders) { print "Active: {$reminders['id']} {$reminders['reminder_type']}\n"; // If User ID is 0, that means it is a global (company wide) reminder print "User ID: {$reminders['user_id']}\n"; print "Reminder: {$reminders['active']} {$reminders['enabled']}\n"; } ////////////////////////////////////////////////////////////////////////////////// readline('Press enter to add a reminder:'); // Create a clock-in and a clock-out reminder with a single api call $request = array(); $request[] = array('user_id' => '0', 'reminder_type' => 'clock-in', 'due_time' => '06:00:00', 'due_days_of_week' => 'Mon,Tue,Wed,Thu,Fri', 'distribution_methods' => 'Push', 'active' => 'true', 'enabled' => 'true'); $request[] = array('user_id' => '0', 'reminder_type' => 'clock-out', 'due_time' => '20:00:00', 'due_days_of_week' => 'Mon,Tue,Wed,Thu,Fri', 'distribution_methods' => 'Push', 'active' => 'true', 'enabled' => 'true'); $result = $tsheets->add(ObjectType::Reminders, $request); print "Create reminder returned:\n"; print_r($result); ////////////////////////////////////////////////////////////////////////////////// readline('Press enter to edit an existing reminder:'); // Save the new reminders ids in order to edit them in the next step $reminder_id = array($result['results']['reminders']['1']['id'], $result['results']['reminders']['2']['id']); // Edit the first reminder $request = array(); $request[] = array('id' => $reminder_id[0], 'due_days_of_week' => 'Mon,Wed,Fri'); $result = $tsheets->edit(ObjectType::Reminders, $request); print "Edit reminder returned:\n"; print_r($result); ////////////////////////////////////////////////////////////////////////////////// readline('Press enter to delete both reminders:'); // Delete the reminders we created $result = $tsheets->delete(ObjectType::Reminders, $reminder_id); print "Deleted reminders:\n"; print_r($result);