├── .gitignore ├── src ├── Exceptions │ ├── InvalidInputException.php │ ├── InvalidTokenException.php │ ├── InvalidSessionException.php │ ├── InvalidAttendanceException.php │ ├── InvalidLessonAttendanceException.php │ └── ValidationError.php ├── Endpoints │ ├── Rooms.php │ ├── Counts.php │ ├── Events.php │ ├── Groups.php │ ├── Photos.php │ ├── Classes.php │ ├── Contacts.php │ ├── Lessons.php │ ├── Periods.php │ ├── Students.php │ ├── Subjects.php │ ├── Deletions.php │ ├── Employees.php │ ├── MedicalEvents.php │ ├── MedicalNotes.php │ ├── Exclusions.php │ ├── StudentLeavers.php │ ├── AttendanceCodes.php │ ├── Doctors.php │ ├── EmployeeAbsences.php │ ├── MedicalConditions.php │ ├── AttendanceSummaries.php │ ├── BehavioursAttributes.php │ ├── StudentsPreAdmission.php │ ├── AchievementsAttributes.php │ ├── Meta.php │ ├── Assessment │ │ ├── Aspects.php │ │ ├── Results.php │ │ ├── Templates.php │ │ ├── MarkSheets.php │ │ └── ResultSets.php │ ├── Attendance.php │ ├── LessonAttendance.php │ ├── Behaviours.php │ ├── Achievements.php │ ├── Assessment.php │ ├── BootstrapEndpoint.php │ └── Schools.php ├── Writeback │ ├── SessionRegister.php │ ├── LessonRegister.php │ ├── LessonAttendanceRecord.php │ └── SessionAttendanceRecord.php ├── ResultIterator.php └── Client.php ├── composer.json ├── phpunit.xml ├── tests ├── AssessmentTest.php ├── MiscEndPointsTest.php └── MiscEndPointsRegionalDomainTest.php └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | vendor/ 3 | vendor/* 4 | composer.lock 5 | composer.phar 6 | .token 7 | .school 8 | .idea -------------------------------------------------------------------------------- /src/Exceptions/InvalidInputException.php: -------------------------------------------------------------------------------- 1 | post($register); 21 | } 22 | } -------------------------------------------------------------------------------- /src/Exceptions/ValidationError.php: -------------------------------------------------------------------------------- 1 | errors = $errors; 17 | } 18 | 19 | /** 20 | * @return mixed 21 | */ 22 | public function getErrors() 23 | { 24 | return $this->errors; 25 | } 26 | } -------------------------------------------------------------------------------- /src/Endpoints/LessonAttendance.php: -------------------------------------------------------------------------------- 1 | post($lessonRegister); 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/ 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Endpoints/Behaviours.php: -------------------------------------------------------------------------------- 1 | uri . $id); 21 | } 22 | 23 | /** 24 | * Create a behaviour record 25 | * 26 | * @param $array 27 | * @return \stdClass 28 | */ 29 | public function create($array) 30 | { 31 | return parent::post($array); 32 | } 33 | } -------------------------------------------------------------------------------- /src/Endpoints/Achievements.php: -------------------------------------------------------------------------------- 1 | uri . $id); 21 | } 22 | 23 | /** 24 | * Create a achievement record 25 | * 26 | * @param $array 27 | * @return \stdClass 28 | */ 29 | public function create($array) 30 | { 31 | return parent::post($array); 32 | } 33 | } -------------------------------------------------------------------------------- /src/Writeback/SessionRegister.php: -------------------------------------------------------------------------------- 1 | attendance = []; 19 | } 20 | 21 | /** 22 | * Add attendance 23 | * @param SessionAttendanceRecord|array $attendance 24 | * @return void 25 | * @throws InvalidAttendanceException 26 | */ 27 | public function add($attendance) 28 | { 29 | $attendance = is_array($attendance) ? $attendance : [$attendance]; 30 | 31 | foreach ($attendance as $attendanceSingular) { 32 | 33 | if ($attendanceSingular instanceof SessionAttendanceRecord && $attendanceSingular->isValid()) { 34 | $this->attendance[] = $attendanceSingular->toArray(); 35 | } else { 36 | if ( ! $attendanceSingular instanceof SessionAttendanceRecord) { 37 | throw new InvalidAttendanceException('Attendance is not an instance of the Attendance Class.'); 38 | } 39 | 40 | if ( ! $attendanceSingular->isValid()) { 41 | throw new InvalidAttendanceException('Attendance has empty fields.'); 42 | } 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/Endpoints/Assessment.php: -------------------------------------------------------------------------------- 1 | token = $token; 47 | $this->logPath = $logPath; 48 | 49 | if ($id) { 50 | $this->uri = $this->uri . $id; 51 | } 52 | 53 | $this->templates = new Templates($token, $this->uri, $this->logPath); 54 | $this->aspects = new Aspects($token, $this->uri, $this->logPath); 55 | $this->marksheets = new MarkSheets($token, $this->uri, $this->logPath); 56 | $this->results = new Results($token, $this->uri, $this->logPath); 57 | $this->resultsets = new ResultSets($token, $this->uri, $this->logPath); 58 | } 59 | } -------------------------------------------------------------------------------- /src/Writeback/LessonRegister.php: -------------------------------------------------------------------------------- 1 | attendance = []; 19 | } 20 | 21 | /** 22 | * Add attendance 23 | * @param LessonAttendanceRecord|array $lessonAttendance 24 | * @return void 25 | * @throws InvalidLessonAttendanceException 26 | */ 27 | public function add($lessonAttendance) 28 | { 29 | $lessonAttendance = is_array($lessonAttendance) ? $lessonAttendance : [$lessonAttendance]; 30 | 31 | foreach ($lessonAttendance as $lessonAttendanceSingular) { 32 | 33 | if ($lessonAttendanceSingular instanceof LessonAttendanceRecord && $lessonAttendanceSingular->isValid()) { 34 | $this->attendance[] = $lessonAttendanceSingular->toArray(); 35 | } else { 36 | if ( ! $lessonAttendanceSingular instanceof LessonAttendanceRecord) { 37 | throw new InvalidLessonAttendanceException('Attendance is not an instance of the LessonAttendance Class.'); 38 | } 39 | 40 | if ( ! $lessonAttendanceSingular->isValid()) { 41 | throw new InvalidLessonAttendanceException('Attendance has empty fields.'); 42 | } 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/ResultIterator.php: -------------------------------------------------------------------------------- 1 | array = $givenArray->data; 26 | $this->token = $token; 27 | $this->meta = ! empty($givenArray->meta) ? $givenArray->meta : new \stdClass(); 28 | $this->logPath = $logPath; 29 | } 30 | 31 | #[\ReturnTypeWillChange] 32 | function rewind() 33 | { 34 | return reset($this->array); 35 | } 36 | 37 | #[\ReturnTypeWillChange] 38 | function current() 39 | { 40 | return current($this->array); 41 | } 42 | 43 | #[\ReturnTypeWillChange] 44 | function key() 45 | { 46 | return key($this->array); 47 | } 48 | 49 | #[\ReturnTypeWillChange] 50 | function next() 51 | { 52 | return next($this->array); 53 | } 54 | 55 | #[\ReturnTypeWillChange] 56 | function valid() 57 | { 58 | $valid = key($this->array) !== null; 59 | 60 | if ( ! $valid) { 61 | 62 | if ( ! empty($this->meta->pagination->next)) { 63 | 64 | $nextResponse = $this->getUrl($this->meta->pagination->next)->getBody()->getContents(); 65 | $decoded = json_decode($nextResponse); 66 | 67 | $this->logResponse($this->logPath, $this->meta->pagination->next, $nextResponse); 68 | 69 | $this->meta = ! empty($decoded->meta) ? $decoded->meta : new \stdClass(); 70 | $this->array = $decoded->data; 71 | 72 | reset($this->array); 73 | 74 | return (bool) count($this->array); 75 | } 76 | 77 | } else { 78 | return $valid; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /tests/AssessmentTest.php: -------------------------------------------------------------------------------- 1 | school = $client->school(file_get_contents(__DIR__ . '/../.school')); 16 | } 17 | 18 | public function test_templates() 19 | { 20 | $items = []; 21 | foreach ($this->school->assessment->templates->all() as $row) { 22 | $items[] = $row; 23 | $this->assertTrue($row instanceof stdClass); 24 | $this->assertNotEmpty($row); 25 | } 26 | $this->assertTrue($items > 10); 27 | } 28 | 29 | public function test_aspects() 30 | { 31 | $items = []; 32 | foreach ($this->school->assessment->aspects->all() as $row) { 33 | $items[] = $row; 34 | $this->assertTrue($row instanceof stdClass); 35 | $this->assertNotEmpty($row); 36 | } 37 | $this->assertTrue($items > 10); 38 | } 39 | 40 | public function test_results() 41 | { 42 | $items = []; 43 | foreach ($this->school->assessment->results->all() as $row) { 44 | $items[] = $row; 45 | $this->assertTrue($row instanceof stdClass); 46 | $this->assertNotEmpty($row); 47 | } 48 | $this->assertTrue($items > 10); 49 | } 50 | 51 | public function test_resultsets() 52 | { 53 | $items = []; 54 | foreach ($this->school->assessment->resultsets->all() as $row) { 55 | $items[] = $row; 56 | $this->assertTrue($row instanceof stdClass); 57 | $this->assertNotEmpty($row); 58 | } 59 | $this->assertTrue($items > 10); 60 | } 61 | 62 | public function test_marksheets() 63 | { 64 | $items = []; 65 | foreach ($this->school->assessment->marksheets->all() as $row) { 66 | $items[] = $row; 67 | $this->assertTrue($row instanceof stdClass); 68 | $this->assertNotEmpty($row); 69 | } 70 | $this->assertTrue($items > 10); 71 | } 72 | } -------------------------------------------------------------------------------- /src/Client.php: -------------------------------------------------------------------------------- 1 | token = $token; 56 | $this->schools = new Schools($token, false, $logPath); 57 | $this->meta = new Meta($token, false, $logPath); 58 | $this->attendanceCodes = new AttendanceCodes($token, false, $logPath); 59 | $this->logPath = $logPath; 60 | } 61 | 62 | /** 63 | * Return endpoints for single school 64 | * 65 | * @param $id 66 | * @return Schools 67 | */ 68 | public function school($id) 69 | { 70 | if(!empty($this->logPath)) { 71 | $this->logPath .= DIRECTORY_SEPARATOR . $id; 72 | } 73 | return new Schools($this->token, $id, $this->logPath); 74 | } 75 | 76 | /** 77 | * Request access to the current school 78 | * 79 | * @return \stdClass 80 | */ 81 | public function requestAccess($schoolId, $payload = []) 82 | { 83 | $uri = 'schools/' . $schoolId . '/request-access'; 84 | 85 | return (new BootstrapEndpoint($this->token, $uri))->post($payload); 86 | } 87 | 88 | /** 89 | * Revoke access to the current school 90 | * 91 | * @return \stdClass 92 | */ 93 | public function revokeAccess($schoolId) 94 | { 95 | $uri = 'schools/' . $schoolId . '/revoke-access'; 96 | 97 | return (new BootstrapEndpoint($this->token, $uri))->deleteRequestReturnBody($uri); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/Writeback/LessonAttendanceRecord.php: -------------------------------------------------------------------------------- 1 | student_id = $studentId; 36 | } 37 | 38 | /** 39 | * Set lesson_id 40 | * 41 | * @param string $lessonId 42 | * @return void 43 | * @throws InvalidLessonAttendanceException 44 | */ 45 | public function setLessonId($lessonId) 46 | { 47 | if (empty($lessonId)) { 48 | throw new InvalidLessonAttendanceException('Lesson id can not be set to null.'); 49 | } 50 | 51 | $this->lesson_id = $lessonId; 52 | } 53 | 54 | /** 55 | * Set attendance code id 56 | * 57 | * @param string $attendanceCodeId 58 | * @return void 59 | * @throws InvalidLessonAttendanceException 60 | */ 61 | public function setAttendanceCodeId($attendanceCodeId) 62 | { 63 | if (empty($attendanceCodeId)) { 64 | throw new InvalidLessonAttendanceException('Attendance code id can not be set to null.'); 65 | } 66 | 67 | $this->attendance_code_id = $attendanceCodeId; 68 | } 69 | 70 | /** 71 | * Check that all required attributes are set 72 | * 73 | * @return bool 74 | */ 75 | public function isValid() 76 | { 77 | return ! (empty($this->student_id) || empty($this->lesson_id) || empty($this->attendance_code_id)); 78 | } 79 | 80 | /** 81 | * @return string 82 | */ 83 | public function getStudentId() 84 | { 85 | return $this->student_id; 86 | } 87 | 88 | /** 89 | * @return string 90 | */ 91 | public function getLessonId() 92 | { 93 | return $this->lesson_id; 94 | } 95 | 96 | /** 97 | * @return string 98 | */ 99 | public function getAttendanceCodeId() 100 | { 101 | return $this->attendance_code_id; 102 | } 103 | 104 | /** 105 | * Return object as array 106 | * 107 | * @return array 108 | */ 109 | public function toArray() 110 | { 111 | $required = [ 112 | 'lesson_id' => $this->getLessonId(), 113 | 'student_id' => $this->getStudentId(), 114 | 'attendance_code_id' => $this->getAttendanceCodeId() 115 | ]; 116 | 117 | return $required; 118 | } 119 | 120 | } -------------------------------------------------------------------------------- /src/Writeback/SessionAttendanceRecord.php: -------------------------------------------------------------------------------- 1 | student_id = $studentId; 58 | } 59 | 60 | /** 61 | * Set employee id 62 | * 63 | * @param string $employeeId 64 | * @return void 65 | * @throws InvalidAttendanceException 66 | */ 67 | public function setEmployeeId($employeeId) 68 | { 69 | $this->employee_id = $employeeId; 70 | } 71 | 72 | /** 73 | * Set date 74 | * 75 | * @param string $date 76 | * @return void 77 | * @throws InvalidAttendanceException 78 | */ 79 | public function setDate($date) 80 | { 81 | if (empty($date)) { 82 | throw new InvalidAttendanceException('Date can not be set to null.'); 83 | } 84 | 85 | $time = strtotime($date); 86 | 87 | if ($time === false) { 88 | throw new InvalidAttendanceException('Date provided is invalid'); 89 | } 90 | 91 | $date = date('Y-m-d', $time); 92 | $this->date = $date; 93 | } 94 | 95 | /** 96 | * Set date 97 | * 98 | * @param string $session 99 | * @return void 100 | * @throws InvalidSessionException 101 | */ 102 | public function setSession($session) 103 | { 104 | $session = strtoupper($session); 105 | 106 | if ($session == 'AM' || $session == 'PM') { 107 | $this->session = $session; 108 | } else { 109 | throw new InvalidSessionException('The session is invalid'); 110 | } 111 | } 112 | 113 | /** 114 | * Set attendance code id 115 | * 116 | * Attendance codes can be fetched from the attendance-code endpoint 117 | * 118 | * @param string $attendanceCodeId 119 | * @return void 120 | * @throws InvalidAttendanceException 121 | */ 122 | public function setAttendanceCodeId($attendanceCodeId) 123 | { 124 | if (empty($attendanceCodeId)) { 125 | throw new InvalidAttendanceException('Attendance code id can not be set to null.'); 126 | } 127 | 128 | $this->attendance_code_id = $attendanceCodeId; 129 | } 130 | 131 | /** 132 | * Check that all required attributes are set 133 | * 134 | * @return bool 135 | */ 136 | public function isValid() 137 | { 138 | return ! (empty($this->date) || empty($this->student_id) || empty($this->session) || empty($this->attendance_code_id)); 139 | } 140 | 141 | /** 142 | * Return the student id 143 | * 144 | * @return string 145 | */ 146 | public function getStudentId() 147 | { 148 | return $this->student_id; 149 | } 150 | 151 | /** 152 | * Return the student id 153 | * 154 | * @return string 155 | */ 156 | public function getEmployeeId() 157 | { 158 | return $this->employee_id; 159 | } 160 | 161 | /** 162 | * Return the date 163 | * 164 | * @return string 165 | */ 166 | public function getDate() 167 | { 168 | return $this->date; 169 | } 170 | 171 | /** 172 | * Return the session 173 | * 174 | * @return string 175 | */ 176 | public function getSession() 177 | { 178 | return $this->session; 179 | } 180 | 181 | /** 182 | * Return the attendance code 183 | * 184 | * @return string 185 | */ 186 | public function getAttendanceCodeId() 187 | { 188 | return $this->attendance_code_id; 189 | } 190 | 191 | /** 192 | * Return object as array 193 | * 194 | * @return array 195 | */ 196 | public function toArray() 197 | { 198 | $required = [ 199 | 'date' => $this->getDate(), 200 | 'session' => $this->getSession(), 201 | 'student_id' => $this->getStudentId(), 202 | 'attendance_code_id' => $this->getAttendanceCodeId() 203 | ]; 204 | 205 | $comment = $this->getComment(); 206 | 207 | if ( ! empty($comment)) { 208 | $required['comment'] = $comment; 209 | } 210 | 211 | $employeeId = $this->getEmployeeId(); 212 | 213 | if ( ! empty($employeeId)) { 214 | $required['employee_id'] = $employeeId; 215 | } 216 | 217 | $minutesLate = $this->getMinutesLate(); 218 | 219 | if ( ! empty($minutesLate)) { 220 | $required['minutes_late'] = $minutesLate; 221 | } 222 | 223 | return $required; 224 | } 225 | 226 | /** 227 | * Get the comment value 228 | * 229 | * @return string 230 | */ 231 | public function getComment() 232 | { 233 | return $this->comment; 234 | } 235 | 236 | /** 237 | * Set the comment value 238 | * 239 | * @param string $comment 240 | */ 241 | public function setComment($comment) 242 | { 243 | $this->comment = $comment; 244 | } 245 | 246 | /** 247 | * Set minutes late 248 | * 249 | * @param $number 250 | * @throws InvalidInputException 251 | */ 252 | public function setMinutesLate($number) 253 | { 254 | if ( ! is_numeric($number)) { 255 | throw new InvalidInputException('Only pass a numeric value to minutes late'); 256 | } 257 | 258 | $this->minutesLate = $number; 259 | } 260 | 261 | /** 262 | * Get minutes late 263 | * 264 | * @return int 265 | */ 266 | public function getMinutesLate() 267 | { 268 | return $this->minutesLate; 269 | } 270 | } 271 | -------------------------------------------------------------------------------- /src/Endpoints/BootstrapEndpoint.php: -------------------------------------------------------------------------------- 1 | token = $token; 49 | $this->logPath = $logPath; 50 | 51 | if ($uri) { 52 | $this->uri = $uri . $this->uri; 53 | } 54 | } 55 | 56 | /** 57 | * Get the default guzzle client 58 | * 59 | * @return Client 60 | */ 61 | private function client() 62 | { 63 | return new Client([ 64 | 'headers' => [ 65 | 'Authorization' => 'Basic ' . base64_encode($this->token . ':'), 66 | 'User-Agent' => 'wonde-php-client-' . \Wonde\Client::version 67 | ] 68 | ]); 69 | } 70 | 71 | /** 72 | * Throw an error 73 | * 74 | * @param ClientException $exception 75 | * @return null 76 | * @throws ValidationError 77 | */ 78 | private function throwError(ClientException $exception) 79 | { 80 | if ($exception->getResponse()->getStatusCode() === 422) { 81 | 82 | // Status code 422 is a validation error 83 | $validationError = new ValidationError('Validation has failed'); 84 | $validationError->setErrors(json_decode($exception->getResponse()->getBody()->getContents())); 85 | throw $validationError; 86 | } else { 87 | throw $exception; 88 | } 89 | } 90 | 91 | /** 92 | * Get all of resource 93 | * 94 | * @param array $includes 95 | * @param array $parameters 96 | * @return mixed|\Psr\Http\Message\ResponseInterface 97 | */ 98 | public function all($includes = [], $parameters = []) 99 | { 100 | if ( ! empty($includes)) { 101 | $parameters['include'] = implode(',', $includes); 102 | } 103 | 104 | $uri = ! empty($parameters) ? $this->uri . '?' . http_build_query($parameters) : $this->uri; 105 | 106 | $response = $this->getRequest($uri)->getBody()->getContents(); 107 | $decoded = json_decode($response); 108 | 109 | $this->logResponse($this->logPath, $uri, $response); 110 | 111 | return new ResultIterator($decoded, $this->token, $this->logPath); 112 | } 113 | 114 | /** 115 | * Make a get request 116 | * 117 | * @param $endpoint 118 | * @return mixed|\Psr\Http\Message\ResponseInterface 119 | */ 120 | private function getRequest($endpoint) 121 | { 122 | return $this->getUrl($this->getEndpoint() . $endpoint); 123 | } 124 | 125 | /** 126 | * Make a get request to url 127 | * 128 | * @param $url 129 | * @return mixed|\Psr\Http\Message\ResponseInterface 130 | */ 131 | public function getUrl($url) 132 | { 133 | return $this->client()->get($url); 134 | } 135 | 136 | /** 137 | * Get single resource, data only 138 | * 139 | * @param $id 140 | * @return mixed 141 | */ 142 | public function get($id, $includes = [], $parameters = []) 143 | { 144 | $decoded = $this->getWithMeta($id, $includes, $parameters); 145 | 146 | return $decoded->data; 147 | } 148 | 149 | /** 150 | * Get single resource, data and meta 151 | * 152 | * @param $id 153 | * @return mixed 154 | */ 155 | public function getWithMeta($id, $includes = [], $parameters = []) 156 | { 157 | if ( ! empty($includes)) { 158 | $parameters['include'] = implode(',', $includes); 159 | } 160 | 161 | $uri = ! empty($parameters) ? $this->uri . $id . '?' . http_build_query($parameters) : $this->uri . $id; 162 | 163 | $response = $this->getRequest($uri)->getBody()->getContents(); 164 | $decoded = json_decode($response); 165 | 166 | $this->logResponse($this->logPath, $uri, $response); 167 | 168 | return $decoded; 169 | } 170 | 171 | /** 172 | * Make a post request 173 | * 174 | * @param $endpoint 175 | * @param array $body 176 | * @return mixed|\Psr\Http\Message\ResponseInterface 177 | */ 178 | public function postRequest($endpoint, $body = []) 179 | { 180 | return $this->postUrl($this->getEndpoint() . $endpoint, $body); 181 | } 182 | 183 | /** 184 | * Make a post request to url 185 | * 186 | * @param $url 187 | * @param array $body 188 | * @return mixed|\Psr\Http\Message\ResponseInterface 189 | */ 190 | private function postUrl($url, $body = []) 191 | { 192 | return $this->client()->post($url, $body); 193 | } 194 | 195 | /** 196 | * Make a post request and decode the response 197 | * 198 | * @param array $body 199 | * @return \stdClass 200 | */ 201 | public function post($body = []) 202 | { 203 | $body = ['body' => json_encode($body)]; 204 | $body['headers']['Content-Type'] = 'application/json'; 205 | 206 | try { 207 | $post = $this->postRequest($this->uri, $body); 208 | } catch ( ClientException $exception ) { 209 | return $this->throwError($exception); 210 | } 211 | 212 | $response = $post->getBody()->getContents(); 213 | 214 | $decoded = json_decode($response); 215 | 216 | return $decoded; 217 | } 218 | 219 | 220 | /** 221 | * Make a delete request 222 | * 223 | * @param $endpoint 224 | * @param array $body 225 | * @return mixed|\Psr\Http\Message\ResponseInterface 226 | */ 227 | public function deleteRequest($endpoint, $body = []) 228 | { 229 | return $this->deleteUrl($this->getEndpoint() . $endpoint, $body); 230 | } 231 | 232 | /** 233 | * Make a delete request and return json decoded body 234 | * 235 | * @param $endpoint 236 | * @param array $body 237 | * @return mixed|\Psr\Http\Message\ResponseInterface 238 | */ 239 | public function deleteRequestReturnBody($endpoint, $body = []) 240 | { 241 | /** @var Response $response */ 242 | $response = $this->deleteUrl($this->getEndpoint() . $endpoint, $body); 243 | return json_decode($response->getBody()->getContents()); 244 | } 245 | 246 | /** 247 | * Make a delete request to url 248 | * 249 | * @param $url 250 | * @param array $body 251 | * @return mixed|\Psr\Http\Message\ResponseInterface 252 | */ 253 | private function deleteUrl($url, $body = []) 254 | { 255 | return $this->client()->delete($url, $body); 256 | } 257 | 258 | /** 259 | * Get base endpoint 260 | * 261 | * @return string 262 | */ 263 | public function getEndpoint() 264 | { 265 | return "https://{$this->domain}/{$this->version}/"; 266 | } 267 | 268 | 269 | /** 270 | * Log response to filesystem 271 | * 272 | * @param string $logPath 273 | * @param string $uri 274 | * @param string $response 275 | */ 276 | protected function logResponse(string $logPath, string $uri, string $response) { 277 | if(!empty($logPath)) { 278 | if (!is_dir($logPath)) { 279 | mkdir($logPath, 0777, true); 280 | } 281 | $filename = sha1($uri) . '.json'; 282 | file_put_contents($logPath . DIRECTORY_SEPARATOR . $filename, "URI: $uri\nRESPONSE:\n$response"); 283 | } 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /src/Endpoints/Schools.php: -------------------------------------------------------------------------------- 1 | token = $token; 169 | $this->logPath = $logPath; 170 | 171 | if ($id) { 172 | $this->uri = $this->uri . $id . '/'; 173 | } 174 | 175 | $this->achievements = new Achievements($token, $this->uri, $this->logPath); 176 | $this->achievementsAttributes = new AchievementsAttributes($token, $this->uri, $this->logPath); 177 | $this->assessment = new Assessment($token, $this->uri, $this->logPath); 178 | $this->attendance = new Attendance($token, $this->uri, $this->logPath); 179 | $this->attendanceCodes = new AttendanceCodes($token, $this->uri, $this->logPath); 180 | $this->attendanceSummaries = new AttendanceSummaries($token, $this->uri, $this->logPath); 181 | $this->behaviours = new Behaviours($token, $this->uri, $this->logPath); 182 | $this->behavioursAttributes = new BehavioursAttributes($token, $this->uri, $this->logPath); 183 | $this->classes = new Classes($token, $this->uri, $this->logPath); 184 | $this->contacts = new Contacts($token, $this->uri, $this->logPath); 185 | $this->counts = new Counts($token, $this->uri, $this->logPath); 186 | $this->deletions = new Deletions($token, $this->uri, $this->logPath); 187 | $this->doctors = new Doctors($token, $this->uri, $this->logPath); 188 | $this->employees = new Employees($token, $this->uri, $this->logPath); 189 | $this->employeeAbsences = new EmployeeAbsences($token, $this->uri, $this->logPath); 190 | $this->events = new Events($token, $this->uri, $this->logPath); 191 | $this->exclusions = new Exclusions($token, $this->uri, $this->logPath); 192 | $this->groups = new Groups($token, $this->uri, $this->logPath); 193 | $this->lessons = new Lessons($token, $this->uri, $this->logPath); 194 | $this->lessonAttendance = new LessonAttendance($token, $this->uri, $this->logPath); 195 | $this->medicalConditions = new MedicalConditions($token, $this->uri, $this->logPath); 196 | $this->medicalEvents = new MedicalEvents($token, $this->uri, $this->logPath); 197 | $this->medicalNotes = new MedicalNotes($token, $this->uri, $this->logPath); 198 | $this->periods = new Periods($token, $this->uri, $this->logPath); 199 | $this->photos = new Photos($token, $this->uri, $this->logPath); 200 | $this->rooms = new Rooms($token, $this->uri, $this->logPath); 201 | $this->students = new Students($token, $this->uri, $this->logPath); 202 | $this->studentsPreAdmission = new StudentsPreAdmission($token, $this->uri, $this->logPath); 203 | $this->studentLeavers = new StudentLeavers($token, $this->uri, $this->logPath); 204 | $this->subjects = new Subjects($token, $this->uri, $this->logPath); 205 | } 206 | 207 | public function updateDomain($domain) 208 | { 209 | $this->achievements->domain = $domain; 210 | $this->achievementsAttributes->domain = $domain; 211 | $this->assessment->domain = $domain; 212 | $this->attendance->domain = $domain; 213 | $this->attendanceCodes->domain = $domain; 214 | $this->attendanceSummaries->domain = $domain; 215 | $this->behaviours->domain = $domain; 216 | $this->behavioursAttributes->domain = $domain; 217 | $this->classes->domain = $domain; 218 | $this->contacts->domain = $domain; 219 | $this->counts->domain = $domain; 220 | $this->deletions->domain = $domain; 221 | $this->doctors->domain = $domain; 222 | $this->employees->domain = $domain; 223 | $this->employeeAbsences->domain = $domain; 224 | $this->events->domain = $domain; 225 | $this->exclusions->domain = $domain; 226 | $this->groups->domain = $domain; 227 | $this->lessons->domain = $domain; 228 | $this->lessonAttendance->domain = $domain; 229 | $this->medicalConditions->domain = $domain; 230 | $this->medicalEvents->domain = $domain; 231 | $this->medicalNotes->domain = $domain; 232 | $this->periods->domain = $domain; 233 | $this->photos->domain = $domain; 234 | $this->rooms->domain = $domain; 235 | $this->students->domain = $domain; 236 | $this->studentsPreAdmission->domain = $domain; 237 | $this->studentLeavers->domain = $domain; 238 | $this->subjects->domain = $domain; 239 | 240 | return $this; 241 | } 242 | 243 | /** 244 | * Return all pending schools 245 | * 246 | * @param array $includes 247 | * @param array $parameters 248 | * @return mixed|\Psr\Http\Message\ResponseInterface 249 | */ 250 | public function pending($includes = [], $parameters = []) 251 | { 252 | $this->uri = $this->uri . 'pending/'; 253 | return $this->all($includes, $parameters); 254 | } 255 | 256 | /** 257 | * Return all audited schools 258 | * 259 | * @param array $includes 260 | * @param array $parameters 261 | * @return mixed|\Psr\Http\Message\ResponseInterface 262 | */ 263 | public function audited($includes = [], $parameters = []) 264 | { 265 | $this->uri = $this->uri . 'audited/'; 266 | return $this->all($includes, $parameters); 267 | } 268 | 269 | /** 270 | * Return all declined schools 271 | * 272 | * @param array $includes 273 | * @param array $parameters 274 | * @return mixed|\Psr\Http\Message\ResponseInterface 275 | */ 276 | public function declined($includes = [], $parameters = []) 277 | { 278 | $this->uri = $this->uri . 'declined/'; 279 | return $this->all($includes, $parameters); 280 | } 281 | 282 | /** 283 | * Return all revoked schools 284 | * 285 | * @param array $includes 286 | * @param array $parameters 287 | * @return mixed|\Psr\Http\Message\ResponseInterface 288 | */ 289 | public function revoked($includes = [], $parameters = []) 290 | { 291 | $this->uri = $this->uri . 'revoked/'; 292 | return $this->all($includes, $parameters); 293 | } 294 | 295 | /** 296 | * Search available schools 297 | * 298 | * @param array $includes 299 | * @param array $parameters 300 | * @return mixed|\Psr\Http\Message\ResponseInterface 301 | */ 302 | public function search($includes = [], $parameters = []) 303 | { 304 | $this->uri = $this->uri . 'all/'; 305 | return $this->all($includes, $parameters); 306 | } 307 | 308 | /** 309 | * Override the get method for single school fetch 310 | * 311 | * @param $id 312 | * @param array $includes 313 | * @param array $parameters 314 | * @return mixed 315 | */ 316 | public function get($id, $includes = [], $parameters = []) 317 | { 318 | $this->uri = 'schools/'; 319 | return parent::get($id, $includes, $parameters); 320 | } 321 | 322 | 323 | /** 324 | * Init attendance record 325 | * 326 | * @return Attendance 327 | */ 328 | public function attendance() 329 | { 330 | return $this->attendance; 331 | } 332 | 333 | /** 334 | * Init attendance record 335 | * 336 | * @return LessonAttendance 337 | */ 338 | public function lessonAttendance() 339 | { 340 | return $this->lessonAttendance; 341 | } 342 | } 343 | -------------------------------------------------------------------------------- /tests/MiscEndPointsTest.php: -------------------------------------------------------------------------------- 1 | token = file_get_contents(__DIR__ . '/../.token'); 24 | $this->client = new \Wonde\Client($this->token); 25 | $this->schoolId = file_get_contents(__DIR__ . '/../.school'); 26 | $this->school = $this->client->school($this->schoolId); 27 | } 28 | 29 | public function test_request_access() 30 | { 31 | $response = $this->client->requestAccess($this->schoolId); 32 | $this->assertTrue($response->success); 33 | } 34 | 35 | public function test_revoke_access() 36 | { 37 | $response = $this->client->revokeAccess($this->schoolId); 38 | $this->assertTrue($response->success); 39 | } 40 | 41 | public function test_single_school() 42 | { 43 | $school = $this->client->schools->get(file_get_contents(__DIR__ . '/../.school')); 44 | $this->assertTrue($school instanceof stdClass); 45 | } 46 | 47 | public function tests_students() 48 | { 49 | $items = []; 50 | foreach ($this->school->students->all() as $row) { 51 | $items[] = $row; 52 | $this->assertTrue($row instanceof stdClass); 53 | $this->assertNotEmpty($row); 54 | } 55 | $this->assertTrue($items > 10); 56 | } 57 | 58 | public function tests_students_pre_admission() 59 | { 60 | $items = []; 61 | foreach ($this->school->studentsPreAdmission->all() as $row) { 62 | $items[] = $row; 63 | $this->assertTrue($row instanceof stdClass); 64 | $this->assertNotEmpty($row); 65 | } 66 | $this->assertTrue($items > 10); 67 | } 68 | 69 | public function tests_attendance_codes() 70 | { 71 | $items = []; 72 | foreach ($this->school->attendanceCodes->all() as $row) { 73 | $items[] = $row; 74 | $this->assertTrue($row instanceof stdClass); 75 | $this->assertNotEmpty($row); 76 | } 77 | $this->assertTrue($items > 10); 78 | } 79 | 80 | public function tests_student_leavers() 81 | { 82 | $items = []; 83 | foreach ($this->school->studentLeavers->all() as $row) { 84 | $items[] = $row; 85 | $this->assertTrue($row instanceof stdClass); 86 | $this->assertNotEmpty($row); 87 | } 88 | $this->assertTrue($items > 10); 89 | } 90 | 91 | public function tests_attendance_summaries() 92 | { 93 | $items = []; 94 | foreach ($this->school->attendanceSummaries->all() as $row) { 95 | $items[] = $row; 96 | $this->assertTrue($row instanceof stdClass); 97 | $this->assertNotEmpty($row); 98 | } 99 | $this->assertTrue($items > 10); 100 | } 101 | 102 | public function tests_employees() 103 | { 104 | $items = []; 105 | foreach ($this->school->employees->all() as $row) { 106 | $items[] = $row; 107 | $this->assertTrue($row instanceof stdClass); 108 | $this->assertNotEmpty($row); 109 | } 110 | $this->assertTrue($items > 10); 111 | } 112 | 113 | public function test_contacts() 114 | { 115 | $items = []; 116 | foreach ($this->school->contacts->all() as $row) { 117 | $items[] = $row; 118 | $this->assertTrue($row instanceof stdClass); 119 | $this->assertNotEmpty($row); 120 | } 121 | $this->assertTrue($items > 10); 122 | } 123 | 124 | public function test_doctors() 125 | { 126 | $items = []; 127 | foreach ($this->school->doctors->all() as $row) { 128 | $items[] = $row; 129 | $this->assertTrue($row instanceof stdClass); 130 | $this->assertNotEmpty($row); 131 | } 132 | $this->assertTrue($items > 10); 133 | } 134 | 135 | public function test_counts() 136 | { 137 | $items = []; 138 | foreach ($this->school->counts->all() as $row) { 139 | $items[] = $row; 140 | $this->assertTrue($row instanceof stdClass); 141 | $this->assertNotEmpty($row); 142 | } 143 | $this->assertTrue($items > 10); 144 | } 145 | 146 | public function test_employee_absences() 147 | { 148 | $items = []; 149 | foreach ($this->school->employeeAbsences->all() as $row) { 150 | $items[] = $row; 151 | $this->assertTrue($row instanceof stdClass); 152 | $this->assertNotEmpty($row); 153 | } 154 | $this->assertTrue($items > 10); 155 | } 156 | 157 | public function test_subjects() 158 | { 159 | $items = []; 160 | foreach ($this->school->subjects->all() as $row) { 161 | $items[] = $row; 162 | $this->assertTrue($row instanceof stdClass); 163 | $this->assertNotEmpty($row); 164 | } 165 | $this->assertTrue($items > 10); 166 | } 167 | 168 | public function test_rooms() 169 | { 170 | $items = []; 171 | foreach ($this->school->rooms->all() as $row) { 172 | $items[] = $row; 173 | $this->assertTrue($row instanceof stdClass); 174 | $this->assertNotEmpty($row); 175 | } 176 | $this->assertTrue($items > 10); 177 | } 178 | 179 | public function test_groups() 180 | { 181 | $items = []; 182 | foreach ($this->school->groups->all() as $row) { 183 | $items[] = $row; 184 | $this->assertTrue($row instanceof stdClass); 185 | $this->assertNotEmpty($row); 186 | } 187 | $this->assertTrue($items > 10); 188 | } 189 | 190 | public function test_classes() 191 | { 192 | $items = []; 193 | foreach ($this->school->classes->all() as $row) { 194 | $items[] = $row; 195 | $this->assertTrue($row instanceof stdClass); 196 | $this->assertNotEmpty($row); 197 | } 198 | $this->assertTrue($items > 10); 199 | } 200 | 201 | public function test_events() 202 | { 203 | $items = []; 204 | foreach ($this->school->events->all() as $row) { 205 | $items[] = $row; 206 | $this->assertTrue($row instanceof stdClass); 207 | $this->assertNotEmpty($row); 208 | } 209 | $this->assertTrue($items > 10); 210 | } 211 | 212 | public function test_medical_events() 213 | { 214 | $items = []; 215 | foreach ($this->school->medicalEvents->all() as $row) { 216 | $items[] = $row; 217 | $this->assertTrue($row instanceof stdClass); 218 | $this->assertNotEmpty($row); 219 | } 220 | $this->assertTrue($items > 10); 221 | } 222 | 223 | public function test_medical_conditions() 224 | { 225 | $items = []; 226 | foreach ($this->school->medicalConditions->all() as $row) { 227 | $items[] = $row; 228 | $this->assertTrue($row instanceof stdClass); 229 | $this->assertNotEmpty($row); 230 | } 231 | $this->assertTrue($items > 10); 232 | } 233 | 234 | public function test_medical_notes() 235 | { 236 | $items = []; 237 | foreach ($this->school->medicalNotes->all() as $row) { 238 | $items[] = $row; 239 | $this->assertTrue($row instanceof stdClass); 240 | $this->assertNotEmpty($row); 241 | } 242 | $this->assertTrue($items > 10); 243 | } 244 | 245 | public function test_periods() 246 | { 247 | $items = []; 248 | foreach ($this->school->periods->all() as $row) { 249 | $items[] = $row; 250 | $this->assertTrue($row instanceof stdClass); 251 | $this->assertNotEmpty($row); 252 | } 253 | $this->assertTrue($items > 10); 254 | } 255 | 256 | public function test_photos() 257 | { 258 | $items = []; 259 | foreach ($this->school->photos->all() as $row) { 260 | $items[] = $row; 261 | $this->assertTrue($row instanceof stdClass); 262 | $this->assertNotEmpty($row); 263 | } 264 | $this->assertTrue($items > 10); 265 | } 266 | 267 | public function test_lessons() 268 | { 269 | $items = []; 270 | foreach ($this->school->lessons->all() as $row) { 271 | $items[] = $row; 272 | $this->assertTrue($row instanceof stdClass); 273 | $this->assertNotEmpty($row); 274 | } 275 | $this->assertTrue($items > 10); 276 | } 277 | 278 | public function test_achievements() 279 | { 280 | $items = []; 281 | foreach ($this->school->achievements->all() as $row) { 282 | $items[] = $row; 283 | $this->assertTrue($row instanceof stdClass); 284 | $this->assertNotEmpty($row); 285 | } 286 | $this->assertTrue($items > 10); 287 | } 288 | 289 | public function test_achievements_attributes() 290 | { 291 | $items = []; 292 | foreach ($this->school->achievementsAttributes->all() as $row) { 293 | $items[] = $row; 294 | $this->assertTrue($row instanceof stdClass); 295 | $this->assertNotEmpty($row); 296 | } 297 | $this->assertTrue($items > 10); 298 | } 299 | 300 | public function test_behaviour() 301 | { 302 | $items = []; 303 | foreach ($this->school->behaviours->all() as $row) { 304 | $items[] = $row; 305 | $this->assertTrue($row instanceof stdClass); 306 | $this->assertNotEmpty($row); 307 | } 308 | $this->assertTrue($items > 10); 309 | } 310 | 311 | public function test_behaviour_attributes() 312 | { 313 | $items = []; 314 | foreach ($this->school->behavioursAttributes->all() as $row) { 315 | $items[] = $row; 316 | $this->assertTrue($row instanceof stdClass); 317 | $this->assertNotEmpty($row); 318 | } 319 | $this->assertTrue($items > 10); 320 | } 321 | 322 | public function test_delete_behaviour() 323 | { 324 | $response = $this->school->behaviours->delete('A1971302099'); 325 | $this->assertTrue($response instanceof stdClass); 326 | } 327 | 328 | public function test_delete_achievement() 329 | { 330 | $response = $this->school->achievements->delete('A125747323'); 331 | $this->assertTrue($response instanceof stdClass); 332 | } 333 | 334 | public function test_behaviour_post() 335 | { 336 | $array = [ 337 | 'students' => [ 338 | [ 339 | 'student_id' => 'A1039521228', 340 | 'role' => 'AG', 341 | 'action' => 'COOL', 342 | 'action_date' => '2016-04-01', 343 | 'points' => 200, 344 | ], 345 | [ 346 | 'student_id' => 'A870869351', 347 | 'role' => 'TA', 348 | 'points' => 2, 349 | ], 350 | ], 351 | 'employee_id' => 'A1375078684', 352 | 'date' => '2016-03-31', 353 | 'status' => 'REV2', 354 | 'type' => 'BULL', 355 | 'bullying_type' => 'B_INT', 356 | 'comment' => 'Bulling incident', 357 | 'activity_type' => 'RE', 358 | 'location' => 'CORR', 359 | 'time' => 'LUN', 360 | ]; 361 | 362 | try { 363 | $response = $this->school->behaviours->create($array); 364 | } catch ( \Wonde\Exceptions\ValidationError $error ) { 365 | $errors = $error->getErrors(); 366 | } 367 | } 368 | 369 | public function test_achievement_post() 370 | { 371 | $array = [ 372 | 'students' => [ 373 | [ 374 | 'student_id' => 'A1039521228', 375 | 'points' => 200, 376 | 'award' => 'TROP', 377 | 'award_date' => '2016-04-05', 378 | ], 379 | ], 380 | 'employee_id' => 'A1375078684', 381 | 'date' => '2016-04-04', 382 | 'type' => 'NYPA', 383 | 'comment' => 'A4', 384 | 'activity_type' => 'RE', 385 | ]; 386 | 387 | try { 388 | $response = $this->school->achievements->create($array); 389 | } catch ( \Wonde\Exceptions\ValidationError $error ) { 390 | $errors = $error->getErrors(); 391 | } 392 | } 393 | } 394 | 395 | -------------------------------------------------------------------------------- /tests/MiscEndPointsRegionalDomainTest.php: -------------------------------------------------------------------------------- 1 | token = file_get_contents(__DIR__ . '/../.token'); 24 | $this->client = new \Wonde\Client($this->token); 25 | $this->schoolId = file_get_contents(__DIR__ . '/../.school'); 26 | $this->school = $this->client->school($this->schoolId); 27 | 28 | $schoolData = $this->client->schools->get($this->schoolId); 29 | $this->school->updateDomain($schoolData->region->domain); 30 | } 31 | 32 | public function test_request_access() 33 | { 34 | $response = $this->client->requestAccess($this->schoolId); 35 | $this->assertTrue($response->success); 36 | } 37 | 38 | public function test_revoke_access() 39 | { 40 | $response = $this->client->revokeAccess($this->schoolId); 41 | $this->assertTrue($response->success); 42 | } 43 | 44 | public function test_single_school() 45 | { 46 | $school = $this->client->schools->get(file_get_contents(__DIR__ . '/../.school')); 47 | $this->assertTrue($school instanceof stdClass); 48 | } 49 | 50 | public function tests_students() 51 | { 52 | $items = []; 53 | foreach ($this->school->students->all() as $row) { 54 | $items[] = $row; 55 | $this->assertTrue($row instanceof stdClass); 56 | $this->assertNotEmpty($row); 57 | } 58 | $this->assertTrue($items > 10); 59 | } 60 | 61 | public function tests_students_pre_admission() 62 | { 63 | $items = []; 64 | foreach ($this->school->studentsPreAdmission->all() as $row) { 65 | $items[] = $row; 66 | $this->assertTrue($row instanceof stdClass); 67 | $this->assertNotEmpty($row); 68 | } 69 | $this->assertTrue($items > 10); 70 | } 71 | 72 | public function tests_attendance_codes() 73 | { 74 | $items = []; 75 | foreach ($this->school->attendanceCodes->all() as $row) { 76 | $items[] = $row; 77 | $this->assertTrue($row instanceof stdClass); 78 | $this->assertNotEmpty($row); 79 | } 80 | $this->assertTrue($items > 10); 81 | } 82 | 83 | public function tests_student_leavers() 84 | { 85 | $items = []; 86 | foreach ($this->school->studentLeavers->all() as $row) { 87 | $items[] = $row; 88 | $this->assertTrue($row instanceof stdClass); 89 | $this->assertNotEmpty($row); 90 | } 91 | $this->assertTrue($items > 10); 92 | } 93 | 94 | public function tests_attendance_summaries() 95 | { 96 | $items = []; 97 | foreach ($this->school->attendanceSummaries->all() as $row) { 98 | $items[] = $row; 99 | $this->assertTrue($row instanceof stdClass); 100 | $this->assertNotEmpty($row); 101 | } 102 | $this->assertTrue($items > 10); 103 | } 104 | 105 | public function tests_employees() 106 | { 107 | $items = []; 108 | foreach ($this->school->employees->all() as $row) { 109 | $items[] = $row; 110 | $this->assertTrue($row instanceof stdClass); 111 | $this->assertNotEmpty($row); 112 | } 113 | $this->assertTrue($items > 10); 114 | } 115 | 116 | public function test_contacts() 117 | { 118 | $items = []; 119 | foreach ($this->school->contacts->all() as $row) { 120 | $items[] = $row; 121 | $this->assertTrue($row instanceof stdClass); 122 | $this->assertNotEmpty($row); 123 | } 124 | $this->assertTrue($items > 10); 125 | } 126 | 127 | public function test_doctors() 128 | { 129 | $items = []; 130 | foreach ($this->school->doctors->all() as $row) { 131 | $items[] = $row; 132 | $this->assertTrue($row instanceof stdClass); 133 | $this->assertNotEmpty($row); 134 | } 135 | $this->assertTrue($items > 10); 136 | } 137 | 138 | public function test_counts() 139 | { 140 | $items = []; 141 | foreach ($this->school->counts->all() as $row) { 142 | $items[] = $row; 143 | $this->assertTrue($row instanceof stdClass); 144 | $this->assertNotEmpty($row); 145 | } 146 | $this->assertTrue($items > 10); 147 | } 148 | 149 | public function test_employee_absences() 150 | { 151 | $items = []; 152 | foreach ($this->school->employeeAbsences->all() as $row) { 153 | $items[] = $row; 154 | $this->assertTrue($row instanceof stdClass); 155 | $this->assertNotEmpty($row); 156 | } 157 | $this->assertTrue($items > 10); 158 | } 159 | 160 | public function test_subjects() 161 | { 162 | $items = []; 163 | foreach ($this->school->subjects->all() as $row) { 164 | $items[] = $row; 165 | $this->assertTrue($row instanceof stdClass); 166 | $this->assertNotEmpty($row); 167 | } 168 | $this->assertTrue($items > 10); 169 | } 170 | 171 | public function test_rooms() 172 | { 173 | $items = []; 174 | foreach ($this->school->rooms->all() as $row) { 175 | $items[] = $row; 176 | $this->assertTrue($row instanceof stdClass); 177 | $this->assertNotEmpty($row); 178 | } 179 | $this->assertTrue($items > 10); 180 | } 181 | 182 | public function test_groups() 183 | { 184 | $items = []; 185 | foreach ($this->school->groups->all() as $row) { 186 | $items[] = $row; 187 | $this->assertTrue($row instanceof stdClass); 188 | $this->assertNotEmpty($row); 189 | } 190 | $this->assertTrue($items > 10); 191 | } 192 | 193 | public function test_classes() 194 | { 195 | $items = []; 196 | foreach ($this->school->classes->all() as $row) { 197 | $items[] = $row; 198 | $this->assertTrue($row instanceof stdClass); 199 | $this->assertNotEmpty($row); 200 | } 201 | $this->assertTrue($items > 10); 202 | } 203 | 204 | public function test_events() 205 | { 206 | $items = []; 207 | foreach ($this->school->events->all() as $row) { 208 | $items[] = $row; 209 | $this->assertTrue($row instanceof stdClass); 210 | $this->assertNotEmpty($row); 211 | } 212 | $this->assertTrue($items > 10); 213 | } 214 | 215 | public function test_medical_events() 216 | { 217 | $items = []; 218 | foreach ($this->school->medicalEvents->all() as $row) { 219 | $items[] = $row; 220 | $this->assertTrue($row instanceof stdClass); 221 | $this->assertNotEmpty($row); 222 | } 223 | $this->assertTrue($items > 10); 224 | } 225 | 226 | public function test_medical_conditions() 227 | { 228 | $items = []; 229 | foreach ($this->school->medicalConditions->all() as $row) { 230 | $items[] = $row; 231 | $this->assertTrue($row instanceof stdClass); 232 | $this->assertNotEmpty($row); 233 | } 234 | $this->assertTrue($items > 10); 235 | } 236 | 237 | public function test_medical_notes() 238 | { 239 | $items = []; 240 | foreach ($this->school->medicalNotes->all() as $row) { 241 | $items[] = $row; 242 | $this->assertTrue($row instanceof stdClass); 243 | $this->assertNotEmpty($row); 244 | } 245 | $this->assertTrue($items > 10); 246 | } 247 | 248 | public function test_periods() 249 | { 250 | $items = []; 251 | foreach ($this->school->periods->all() as $row) { 252 | $items[] = $row; 253 | $this->assertTrue($row instanceof stdClass); 254 | $this->assertNotEmpty($row); 255 | } 256 | $this->assertTrue($items > 10); 257 | } 258 | 259 | public function test_photos() 260 | { 261 | $items = []; 262 | foreach ($this->school->photos->all() as $row) { 263 | $items[] = $row; 264 | $this->assertTrue($row instanceof stdClass); 265 | $this->assertNotEmpty($row); 266 | } 267 | $this->assertTrue($items > 10); 268 | } 269 | 270 | public function test_lessons() 271 | { 272 | $items = []; 273 | foreach ($this->school->lessons->all() as $row) { 274 | $items[] = $row; 275 | $this->assertTrue($row instanceof stdClass); 276 | $this->assertNotEmpty($row); 277 | } 278 | $this->assertTrue($items > 10); 279 | } 280 | 281 | public function test_achievements() 282 | { 283 | $items = []; 284 | foreach ($this->school->achievements->all() as $row) { 285 | $items[] = $row; 286 | $this->assertTrue($row instanceof stdClass); 287 | $this->assertNotEmpty($row); 288 | } 289 | $this->assertTrue($items > 10); 290 | } 291 | 292 | public function test_achievements_attributes() 293 | { 294 | $items = []; 295 | foreach ($this->school->achievementsAttributes->all() as $row) { 296 | $items[] = $row; 297 | $this->assertTrue($row instanceof stdClass); 298 | $this->assertNotEmpty($row); 299 | } 300 | $this->assertTrue($items > 10); 301 | } 302 | 303 | public function test_behaviour() 304 | { 305 | $items = []; 306 | foreach ($this->school->behaviours->all() as $row) { 307 | $items[] = $row; 308 | $this->assertTrue($row instanceof stdClass); 309 | $this->assertNotEmpty($row); 310 | } 311 | $this->assertTrue($items > 10); 312 | } 313 | 314 | public function test_behaviour_attributes() 315 | { 316 | $items = []; 317 | foreach ($this->school->behavioursAttributes->all() as $row) { 318 | $items[] = $row; 319 | $this->assertTrue($row instanceof stdClass); 320 | $this->assertNotEmpty($row); 321 | } 322 | $this->assertTrue($items > 10); 323 | } 324 | 325 | public function test_delete_behaviour() 326 | { 327 | $response = $this->school->behaviours->delete('A1971302099'); 328 | $this->assertTrue($response instanceof stdClass); 329 | } 330 | 331 | public function test_delete_achievement() 332 | { 333 | $response = $this->school->achievements->delete('A125747323'); 334 | $this->assertTrue($response instanceof stdClass); 335 | } 336 | 337 | public function test_behaviour_post() 338 | { 339 | $array = [ 340 | 'students' => [ 341 | [ 342 | 'student_id' => 'A1039521228', 343 | 'role' => 'AG', 344 | 'action' => 'COOL', 345 | 'action_date' => '2016-04-01', 346 | 'points' => 200, 347 | ], 348 | [ 349 | 'student_id' => 'A870869351', 350 | 'role' => 'TA', 351 | 'points' => 2, 352 | ], 353 | ], 354 | 'employee_id' => 'A1375078684', 355 | 'date' => '2016-03-31', 356 | 'status' => 'REV2', 357 | 'type' => 'BULL', 358 | 'bullying_type' => 'B_INT', 359 | 'comment' => 'Bulling incident', 360 | 'activity_type' => 'RE', 361 | 'location' => 'CORR', 362 | 'time' => 'LUN', 363 | ]; 364 | 365 | try { 366 | $response = $this->school->behaviours->create($array); 367 | } catch ( \Wonde\Exceptions\ValidationError $error ) { 368 | $errors = $error->getErrors(); 369 | } 370 | } 371 | 372 | public function test_achievement_post() 373 | { 374 | $array = [ 375 | 'students' => [ 376 | [ 377 | 'student_id' => 'A1039521228', 378 | 'points' => 200, 379 | 'award' => 'TROP', 380 | 'award_date' => '2016-04-05', 381 | ], 382 | ], 383 | 'employee_id' => 'A1375078684', 384 | 'date' => '2016-04-04', 385 | 'type' => 'NYPA', 386 | 'comment' => 'A4', 387 | 'activity_type' => 'RE', 388 | ]; 389 | 390 | try { 391 | $response = $this->school->achievements->create($array); 392 | } catch ( \Wonde\Exceptions\ValidationError $error ) { 393 | $errors = $error->getErrors(); 394 | } 395 | } 396 | } 397 | 398 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Wonde PHP Client 2 | 3 | Documentation https://wonde.com/docs/api/1.0/ 4 | 5 | ## Installation 6 | 7 | Requires PHP 7.2.5+ (including PHP 8.0) 8 | 9 | Using Composer: 10 | 11 | ```json 12 | { 13 | "require": { 14 | "wondeltd/php-client": "3.*" 15 | } 16 | } 17 | ``` 18 | 19 | or 20 | 21 | ```bash 22 | composer require wondeltd/php-client 23 | ``` 24 | 25 | ## Early Release 26 | 27 | If you wish to get early access to new endpoints / improvements please set your package version to `dev-master`. 28 | 29 | **Important Note:** Wonde strongly recommends locking to a stable version on production. 30 | 31 | ## Endpoints 32 | 33 | ### Client 34 | 35 | ```php 36 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 37 | ``` 38 | 39 | ### Schools 40 | 41 | ```php 42 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 43 | 44 | // Loop through the schools your account has access to 45 | foreach ($client->schools->all() as $school) { 46 | // Display school name 47 | echo $school->name . PHP_EOL; 48 | } 49 | ``` 50 | 51 | ### Single School 52 | 53 | ```php 54 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 55 | 56 | // Get single school 57 | $school = $client->schools->get('SCHOOL_ID_GOES_HERE'); 58 | ``` 59 | 60 | ### Pending Schools 61 | 62 | ```php 63 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 64 | 65 | foreach ($client->schools->pending() as $school) { 66 | // Display school name 67 | echo $school->name . PHP_EOL; 68 | } 69 | ``` 70 | 71 | ### Search Schools 72 | 73 | ```php 74 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 75 | 76 | // Search for schools with a postcode starting CB21 77 | foreach ($client->schools->search([], ['postcode' => 'CB21']) as $school) { 78 | // Display school name 79 | echo $school->name . PHP_EOL; 80 | } 81 | 82 | // Search for schools with the establishment number = 6006 83 | foreach ($client->schools->search([], ['establishment_number' => '6006']) as $school) { 84 | // Display school name 85 | echo $school->name . PHP_EOL; 86 | } 87 | ``` 88 | 89 | ### Request Access 90 | 91 | Provide the school ID to request access to a school's data. 92 | 93 | ```php 94 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 95 | $client->requestAccess('A0000000000'); 96 | ``` 97 | 98 | ### Revoke Access 99 | 100 | Provide the school ID to access already approve or pending approval. 101 | 102 | ```php 103 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 104 | $client->revokeAccess('A0000000000'); 105 | ``` 106 | 107 | ### Students 108 | 109 | ```php 110 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 111 | 112 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 113 | 114 | // Get students 115 | foreach ($school->students->all() as $student) { 116 | echo $student->forename . ' ' . $student->surname . PHP_EOL; 117 | } 118 | 119 | // Get single student 120 | $student = $school->students->get('STUDENT_ID_GOES_HERE'); 121 | 122 | // Get students and include contact_details object 123 | foreach ($school->students->all(['contact_details']) as $student) { 124 | echo $student->forename . ' ' . $student->surname . PHP_EOL; 125 | } 126 | 127 | // Get students and include contacts array 128 | foreach ($school->students->all(['contacts']) as $student) { 129 | echo $student->forename . ' ' . $student->surname . PHP_EOL; 130 | } 131 | 132 | // Get students, include contact_details object, include extended_details object and filter by updated after date 133 | foreach ($school->students->all(['contact_details', 'extended_details'], ['updated_after' => '2016-06-24 00:00:00']) as $student) { 134 | echo $student->forename . ' ' . $student->surname . PHP_EOL; 135 | } 136 | ``` 137 | 138 | ### Pre Admission Students 139 | 140 | ```php 141 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 142 | 143 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 144 | 145 | // Get students 146 | foreach ($school->studentsPreAdmission->all() as $studentPreAdmission) { 147 | echo $studentPreAdmission->forename . ' ' . $studentPreAdmission->surname . PHP_EOL; 148 | } 149 | 150 | // Get single student 151 | $student = $school->studentsPreAdmission->get('STUDENT_ID_GOES_HERE'); 152 | ``` 153 | 154 | ### Achievements 155 | 156 | ```php 157 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 158 | 159 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 160 | 161 | // Get achievements 162 | foreach ($school->achievements->all() as $achievement) { 163 | echo $achievement->comment . PHP_EOL; 164 | } 165 | ``` 166 | 167 | ### POST Achievements 168 | 169 | ```php 170 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 171 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 172 | 173 | $array = [ 174 | 'students' => [ 175 | [ 176 | 'student_id' => 'A1039521228', 177 | 'points' => 200, 178 | 'award' => 'TROP', 179 | 'award_date' => '2016-04-05', 180 | ], 181 | ], 182 | 'employee_id' => 'A1375078684', 183 | 'date' => '2016-04-04', 184 | 'type' => 'NYPA', 185 | 'comment' => 'A4', 186 | 'activity_type' => 'RE', 187 | ]; 188 | 189 | try { 190 | $response = $school->achievements->create($array); 191 | } catch (\Wonde\Exceptions\ValidationError $error) { 192 | $errors = $error->getErrors(); 193 | } 194 | ``` 195 | 196 | ### DELETE Achievements 197 | 198 | ```php 199 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 200 | 201 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 202 | 203 | $school->achievements->delete('WONDE_ACHIEVEMENTS_ID_HERE'); 204 | ``` 205 | 206 | ### Achievements Attributes 207 | 208 | ```php 209 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 210 | 211 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 212 | 213 | // Get achievement attributes 214 | foreach ($school->achievementsAttributes->all() as $achievement) { 215 | echo $achievement->id . PHP_EOL; 216 | } 217 | ``` 218 | 219 | ### Assessment - (BETA) 220 | 221 | This endpoint is included in the stable release but is likely to change in the future. Please contact support for more information. 222 | 223 | ```php 224 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 225 | 226 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 227 | 228 | // Get aspects 229 | foreach ($school->assessment->aspects->all() as $aspect) { 230 | echo $aspect->id . PHP_EOL; 231 | } 232 | 233 | // Get templates 234 | foreach ($school->assessment->templates->all() as $templates) { 235 | echo $templates->id . PHP_EOL; 236 | } 237 | 238 | // Get result sets 239 | foreach ($school->assessment->templates->all() as $resultsets) { 240 | echo $resultsets->id . PHP_EOL; 241 | } 242 | 243 | // Get results 244 | foreach ($school->assessment->results->all() as $results) { 245 | echo $results->id . PHP_EOL; 246 | } 247 | 248 | // Get marksheets 249 | foreach ($school->assessment->marksheets->all() as $marksheets) { 250 | echo $marksheets->id . PHP_EOL; 251 | } 252 | ``` 253 | 254 | ### Attendance 255 | 256 | ```php 257 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 258 | 259 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 260 | 261 | // Get attendance 262 | foreach ($school->attendance->all() as $attendance) { 263 | echo $attendance->comment . PHP_EOL; 264 | } 265 | ``` 266 | 267 | ### POST Attendance 268 | 269 | ```php 270 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 271 | 272 | // Initiate a new register 273 | $register = new \Wonde\Writeback\SessionRegister(); 274 | 275 | // Initiate a new attendance record 276 | $attendance = new \Wonde\Writeback\SessionAttendanceRecord(); 277 | 278 | // Set fields 279 | $attendance->setStudentId('STUDENT_ID_GOES_HERE'); 280 | $attendance->setDate('2017-01-01'); 281 | $attendance->setSession('AM'); // AM or PM 282 | $attendance->setAttendanceCodeId('ATTENDANCE_CODE_ID_GOES_HERE'); 283 | $attendance->setComment('Comment here.'); 284 | $attendance->setMinutesLate(10); 285 | 286 | // Add attendance mark to register 287 | $register->add($attendance); 288 | 289 | // Save the session register 290 | $result = $school->attendance()->sessionRegister($register); 291 | 292 | // Writeback id is part of the response 293 | echo $result->writeback_id; 294 | ``` 295 | 296 | ### Attendance Codes 297 | 298 | ```php 299 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 300 | 301 | // Get attendance codes 302 | foreach ($client->attendanceCodes->all() as $attendanceCode) { 303 | echo $attendanceCode->code . PHP_EOL; 304 | } 305 | 306 | // Get school attendance codes 307 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 308 | foreach ($school->attendanceCodes->all() as $attendanceCode) { 309 | echo $attendanceCode->code . PHP_EOL; 310 | } 311 | ``` 312 | 313 | ### Attendance Summaries 314 | 315 | ```php 316 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 317 | 318 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 319 | 320 | // Get attendance summaries 321 | foreach ($school->attendanceSummaries->all() as $attendanceSummary) { 322 | echo $attendance->possible_marks . PHP_EOL; 323 | } 324 | ``` 325 | 326 | ### Behaviours 327 | 328 | ```php 329 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 330 | 331 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 332 | 333 | // Get behaviours 334 | foreach ($school->behaviours->all() as $behaviour) { 335 | echo $behaviour->incident . PHP_EOL; 336 | } 337 | ``` 338 | 339 | ### POST Behaviours 340 | 341 | ```php 342 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 343 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 344 | 345 | $array = [ 346 | 'students' => [ 347 | [ 348 | 'student_id' => 'A1039521228', 349 | 'role' => 'AG', 350 | 'action' => 'COOL', 351 | 'action_date' => '2016-04-01', 352 | 'points' => 200, 353 | ], 354 | [ 355 | 'student_id' => 'A870869351', 356 | 'role' => 'TA', 357 | 'points' => 2, 358 | ], 359 | ], 360 | 'employee_id' => 'A1375078684', 361 | 'date' => '2016-03-31', 362 | 'status' => 'REV2', 363 | 'type' => 'BULL', 364 | 'bullying_type' => 'B_INT', 365 | 'comment' => 'Bulling incident', 366 | 'activity_type' => 'RE', 367 | 'location' => 'CORR', 368 | 'time' => 'LUN', 369 | ]; 370 | 371 | try { 372 | $response = $school->behaviours->create($array); 373 | } catch (\Wonde\Exceptions\ValidationError $error) { 374 | $errors = $error->getErrors(); 375 | } 376 | ``` 377 | 378 | ### DELETE Behaviours 379 | 380 | ```php 381 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 382 | 383 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 384 | 385 | $school->behaviours->delete('WONDE_BEHAVIOUR_ID_HERE'); 386 | ``` 387 | 388 | ### Behaviours Attributes 389 | 390 | ```php 391 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 392 | 393 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 394 | 395 | // Get behaviours 396 | foreach ($school->behavioursAttributes->all() as $behaviour) { 397 | echo $behaviour->id . PHP_EOL; 398 | } 399 | ``` 400 | 401 | ### Classes 402 | 403 | ```php 404 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 405 | 406 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 407 | 408 | // Get classes 409 | foreach ($school->classes->all() as $class) { 410 | echo $class->name . PHP_EOL; 411 | } 412 | ``` 413 | 414 | ### Contacts 415 | 416 | ```php 417 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 418 | 419 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 420 | 421 | // Get contacts 422 | foreach ($school->contacts->all() as $contacts) { 423 | echo $contacts->forename . ' ' . $contacts->surname . PHP_EOL; 424 | } 425 | ``` 426 | 427 | ### Counts 428 | 429 | ```php 430 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 431 | 432 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 433 | 434 | // Get counts 435 | $counts = $school->counts->all(['students','contacts']); 436 | echo $counts->array->students->data->count . PHP_EOL; 437 | echo $counts->array->contacts->data->count . PHP_EOL; 438 | ``` 439 | 440 | ### Deletions 441 | 442 | ```php 443 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 444 | 445 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 446 | 447 | // Get deletions 448 | foreach ($school->deletions->all() as $deletions) { 449 | echo $deletions->id; 450 | } 451 | ``` 452 | 453 | ### Employees 454 | 455 | ```php 456 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 457 | 458 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 459 | 460 | // Get employees 461 | foreach ($school->employees->all() as $employee) { 462 | echo $employee->forename . ' ' . $employee->surname . PHP_EOL; 463 | } 464 | ``` 465 | 466 | ### Employee Absences 467 | 468 | ```php 469 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 470 | 471 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 472 | 473 | // Get employee absences 474 | foreach ($school->employeeAbsences->all() as $employeeAbsence) { 475 | echo $employeeAbsence->employee . ' ' . $employeeAbsence->absence_type . PHP_EOL; 476 | } 477 | ``` 478 | 479 | ### Events 480 | 481 | ```php 482 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 483 | 484 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 485 | 486 | // Get events 487 | foreach ($school->events->all() as $event) { 488 | echo $event->id . PHP_EOL; 489 | } 490 | ``` 491 | 492 | ### Groups 493 | 494 | ```php 495 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 496 | 497 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 498 | 499 | // Get groups 500 | foreach ($school->groups->all() as $group) { 501 | echo $group->name . PHP_EOL; 502 | } 503 | ``` 504 | 505 | ### Lessons 506 | 507 | ```php 508 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 509 | 510 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 511 | 512 | // Get lessons 513 | foreach ($school->lessons->all() as $lesson) { 514 | echo $lesson->period_id . '-' . $lesson->class_id . PHP_EOL; 515 | } 516 | ``` 517 | 518 | ### Lesson Attendance 519 | 520 | ```php 521 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 522 | 523 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 524 | 525 | // Get lesson attendance 526 | foreach ($school->lessonAttendance->all() as $lessonAttendance) { 527 | echo $lessonAttendance->comment . PHP_EOL; 528 | } 529 | ``` 530 | 531 | ### POST Lesson Attendance 532 | 533 | ```php 534 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 535 | 536 | // Initiate a new register 537 | $register = new \Wonde\Writeback\LessonRegister(); 538 | 539 | // Initiate a new attendance record 540 | $attendance = new \Wonde\Writeback\LessonAttendanceRecord(); 541 | 542 | // Set fields 543 | $attendance->setStudentId('STUDENT_ID_GOES_HERE'); 544 | $attendance->setLessonId('LESSON_ID_GOES_HERE'); 545 | $attendance->setAttendanceCodeId('ATTENDANCE_CODE_ID_GOES_HERE'); 546 | 547 | // Add attendance mark to register 548 | $register->add($attendance); 549 | 550 | // Save the lesson register 551 | $result = $school->lessonAttendance()->lessonRegister($register); 552 | 553 | // Writeback id is part of the response 554 | echo $result->writeback_id; 555 | ``` 556 | 557 | ### Medical Conditions 558 | 559 | ```php 560 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 561 | 562 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 563 | 564 | // Get medical conditions 565 | foreach ($school->medicalConditions->all() as $medicalCondition) { 566 | echo $medicalCondition->description . PHP_EOL; 567 | } 568 | ``` 569 | 570 | ### Medical Events 571 | 572 | ```php 573 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 574 | 575 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 576 | 577 | // Get medical events 578 | foreach ($school->medicalEvents->all() as $medicalEvent) { 579 | echo $medicalEvent->description . PHP_EOL; 580 | } 581 | ``` 582 | 583 | ### Doctors 584 | 585 | ```php 586 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 587 | 588 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 589 | 590 | // Get doctors 591 | foreach ($school->doctors->all() as $doctor) { 592 | echo $doctor->surname . PHP_EOL; 593 | echo $doctor->practice_name . PHP_EOL; 594 | echo $doctor->telephone . PHP_EOL; 595 | } 596 | ``` 597 | 598 | ### Periods 599 | 600 | ```php 601 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 602 | 603 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 604 | 605 | // Get periods 606 | foreach ($school->periods->all() as $period) { 607 | echo $period->name . PHP_EOL; 608 | } 609 | ``` 610 | 611 | ### Photos 612 | 613 | ```php 614 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 615 | 616 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 617 | 618 | // Get photos 619 | foreach ($school->photos->all() as $photo) { 620 | echo $photo->hash . PHP_EOL; 621 | } 622 | ``` 623 | 624 | ### Rooms 625 | 626 | ```php 627 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 628 | 629 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 630 | 631 | // Get rooms 632 | foreach ($school->rooms->all() as $room) { 633 | echo $room->name . PHP_EOL; 634 | } 635 | ``` 636 | 637 | ### Subjects 638 | 639 | ```php 640 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 641 | 642 | $school = $client->school('SCHOOL_ID_GOES_HERE'); 643 | 644 | // Get subjects 645 | foreach ($school->subjects->all() as $subject) { 646 | echo $subject->name . PHP_EOL; 647 | } 648 | ``` 649 | 650 | ### Meta 651 | 652 | ```php 653 | $client = new \Wonde\Client('TOKEN_GOES_HERE'); 654 | 655 | $metaObject = $client->meta->get('SCHOOL_ID_GOES_HERE'); 656 | ``` 657 | --------------------------------------------------------------------------------