Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

83 Commits

Repository files navigation

Wonde PHP Client

Documentation https://docs.wonde.com/docs/api/sync/

Installation

Requires PHP 7.2.5+ (including PHP 8.0)

Using Composer:

{
"require": {
"wondeltd/php-client": "3.*"
}
}

or

composer require wondeltd/php-client

Early Release

If you wish to get early access to new endpoints / improvements please set your package version to dev-master.

Important Note: Wonde strongly recommends locking to a stable version on production.

Endpoints

Client

$client = new \Wonde\Client('TOKEN_GOES_HERE');

Schools

$client = new \Wonde\Client('TOKEN_GOES_HERE');
// Loop through the schools your account has access toforeach ($client->schools->all() as$school) {
// Display school nameecho$school->name . PHP_EOL;
}

Single School

$client = new \Wonde\Client('TOKEN_GOES_HERE');
// Get single school$school = $client->schools->get('SCHOOL_ID_GOES_HERE');

Pending Schools

$client = new \Wonde\Client('TOKEN_GOES_HERE');
foreach ($client->schools->pending() as$school) {
// Display school nameecho$school->name . PHP_EOL;
}

Search Schools

$client = new \Wonde\Client('TOKEN_GOES_HERE');
// Search for schools with a postcode starting CB21foreach ($client->schools->search([], ['postcode' => 'CB21']) as$school) {
// Display school nameecho$school->name . PHP_EOL;
}
// Search for schools with the establishment number = 6006foreach ($client->schools->search([], ['establishment_number' => '6006']) as$school) {
// Display school nameecho$school->name . PHP_EOL;
}

Request Access

Provide the school ID to request access to a school's data.

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$client->requestAccess('A0000000000');

Revoke Access

Provide the school ID to access already approve or pending approval.

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$client->revokeAccess('A0000000000');

Students

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get studentsforeach ($school->students->all() as$student) {
echo$student->forename . '' . $student->surname . PHP_EOL;
}
// Get single student$student = $school->students->get('STUDENT_ID_GOES_HERE');
// Get students and include contact_details objectforeach ($school->students->all(['contact_details']) as$student) {
echo$student->forename . '' . $student->surname . PHP_EOL;
}
// Get students and include contacts arrayforeach ($school->students->all(['contacts']) as$student) {
echo$student->forename . '' . $student->surname . PHP_EOL;
}
// Get students, include contact_details object, include extended_details object and filter by updated after dateforeach ($school->students->all(['contact_details', 'extended_details'], ['updated_after' => '2016-06-24 00:00:00']) as$student) {
echo$student->forename . '' . $student->surname . PHP_EOL;
}

Pre Admission Students

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get studentsforeach ($school->studentsPreAdmission->all() as$studentPreAdmission) {
echo$studentPreAdmission->forename . '' . $studentPreAdmission->surname . PHP_EOL;
}
// Get single student$student = $school->studentsPreAdmission->get('STUDENT_ID_GOES_HERE');

Achievements

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get achievementsforeach ($school->achievements->all() as$achievement) {
echo$achievement->comment . PHP_EOL;
}

POST Achievements

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
$array = [
'students' => [
[
'student_id' => 'A1039521228',
'points' => 200,
'award' => 'TROP',
'award_date' => '2016-04-05',
],
],
'employee_id' => 'A1375078684',
'date' => '2016-04-04',
'type' => 'NYPA',
'comment' => 'A4',
'activity_type' => 'RE',
];
try {
$response = $school->achievements->create($array);
} catch (\Wonde\Exceptions\ValidationError$error) {
$errors = $error->getErrors();
}

DELETE Achievements

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
$school->achievements->delete('WONDE_ACHIEVEMENTS_ID_HERE');

Achievements Attributes

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get achievement attributesforeach ($school->achievementsAttributes->all() as$achievement) {
echo$achievement->id . PHP_EOL;
}

Assessment - (BETA)

This endpoint is included in the stable release but is likely to change in the future. Please contact support for more information.

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get aspectsforeach ($school->assessment->aspects->all() as$aspect) {
echo$aspect->id . PHP_EOL;
}
// Get templatesforeach ($school->assessment->templates->all() as$templates) {
echo$templates->id . PHP_EOL;
}
// Get result setsforeach ($school->assessment->templates->all() as$resultsets) {
echo$resultsets->id . PHP_EOL;
}
// Get resultsforeach ($school->assessment->results->all() as$results) {
echo$results->id . PHP_EOL;
}
// Get marksheetsforeach ($school->assessment->marksheets->all() as$marksheets) {
echo$marksheets->id . PHP_EOL;
}

Attendance

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get attendanceforeach ($school->attendance->all() as$attendance) {
echo$attendance->comment . PHP_EOL;
}

POST Attendance

$client = new \Wonde\Client('TOKEN_GOES_HERE');
// Initiate a new register$register = new \Wonde\Writeback\SessionRegister();
// Initiate a new attendance record$attendance = new \Wonde\Writeback\SessionAttendanceRecord();
// Set fields$attendance->setStudentId('STUDENT_ID_GOES_HERE');
$attendance->setDate('2017-01-01');
$attendance->setSession('AM'); // AM or PM$attendance->setAttendanceCodeId('ATTENDANCE_CODE_ID_GOES_HERE');
$attendance->setComment('Comment here.');
$attendance->setMinutesLate(10);
// Add attendance mark to register$register->add($attendance);
// Save the session register$result = $school->attendance()->sessionRegister($register);
// Writeback id is part of the responseecho$result->writeback_id;

Attendance Codes

$client = new \Wonde\Client('TOKEN_GOES_HERE');
// Get attendance codesforeach ($client->attendanceCodes->all() as$attendanceCode) {
echo$attendanceCode->code . PHP_EOL;
}
// Get school attendance codes$school = $client->school('SCHOOL_ID_GOES_HERE');
foreach ($school->attendanceCodes->all() as$attendanceCode) {
echo$attendanceCode->code . PHP_EOL;
}

Attendance Summaries

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get attendance summariesforeach ($school->attendanceSummaries->all() as$attendanceSummary) {
echo$attendance->possible_marks . PHP_EOL;
}

Behaviours

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get behavioursforeach ($school->behaviours->all() as$behaviour) {
echo$behaviour->incident . PHP_EOL;
}

POST Behaviours

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
$array = [
'students' => [
[
'student_id' => 'A1039521228',
'role' => 'AG',
'action' => 'COOL',
'action_date' => '2016-04-01',
'points' => 200,
],
[
'student_id' => 'A870869351',
'role' => 'TA',
'points' => 2,
],
],
'employee_id' => 'A1375078684',
'date' => '2016-03-31',
'status' => 'REV2',
'type' => 'BULL',
'bullying_type' => 'B_INT',
'comment' => 'Bulling incident',
'activity_type' => 'RE',
'location' => 'CORR',
'time' => 'LUN',
];
try {
$response = $school->behaviours->create($array);
} catch (\Wonde\Exceptions\ValidationError$error) {
$errors = $error->getErrors();
}

DELETE Behaviours

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
$school->behaviours->delete('WONDE_BEHAVIOUR_ID_HERE');

Behaviours Attributes

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get behavioursforeach ($school->behavioursAttributes->all() as$behaviour) {
echo$behaviour->id . PHP_EOL;
}

Classes

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get classesforeach ($school->classes->all() as$class) {
echo$class->name . PHP_EOL;
}

Contacts

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get contactsforeach ($school->contacts->all() as$contacts) {
echo$contacts->forename . '' . $contacts->surname . PHP_EOL;
}

Counts

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get counts$counts = $school->counts->all(['students','contacts']);
echo$counts->array->students->data->count . PHP_EOL;
echo$counts->array->contacts->data->count . PHP_EOL;

Deletions

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get deletionsforeach ($school->deletions->all() as$deletions) {
echo$deletions->id;
}

Employees

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get employeesforeach ($school->employees->all() as$employee) {
echo$employee->forename . '' . $employee->surname . PHP_EOL;
}

Employee Absences

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get employee absencesforeach ($school->employeeAbsences->all() as$employeeAbsence) {
echo$employeeAbsence->employee . '' . $employeeAbsence->absence_type . PHP_EOL;
}

Events

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get eventsforeach ($school->events->all() as$event) {
echo$event->id . PHP_EOL;
}

Groups

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get groupsforeach ($school->groups->all() as$group) {
echo$group->name . PHP_EOL;
}

Lessons

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get lessonsforeach ($school->lessons->all() as$lesson) {
echo$lesson->period_id . '-' . $lesson->class_id . PHP_EOL;
}

Lesson Attendance

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get lesson attendanceforeach ($school->lessonAttendance->all() as$lessonAttendance) {
echo$lessonAttendance->comment . PHP_EOL;
}

POST Lesson Attendance

$client = new \Wonde\Client('TOKEN_GOES_HERE');
// Initiate a new register$register = new \Wonde\Writeback\LessonRegister();
// Initiate a new attendance record$attendance = new \Wonde\Writeback\LessonAttendanceRecord();
// Set fields$attendance->setStudentId('STUDENT_ID_GOES_HERE');
$attendance->setLessonId('LESSON_ID_GOES_HERE');
$attendance->setAttendanceCodeId('ATTENDANCE_CODE_ID_GOES_HERE');
// Add attendance mark to register$register->add($attendance);
// Save the lesson register$result = $school->lessonAttendance()->lessonRegister($register);
// Writeback id is part of the responseecho$result->writeback_id;

Medical Conditions

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get medical conditionsforeach ($school->medicalConditions->all() as$medicalCondition) {
echo$medicalCondition->description . PHP_EOL;
}

Medical Events

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get medical eventsforeach ($school->medicalEvents->all() as$medicalEvent) {
echo$medicalEvent->description . PHP_EOL;
}

Doctors

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get doctorsforeach ($school->doctors->all() as$doctor) {
echo$doctor->surname . PHP_EOL;
echo$doctor->practice_name . PHP_EOL;
echo$doctor->telephone . PHP_EOL;
}

Periods

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get periodsforeach ($school->periods->all() as$period) {
echo$period->name . PHP_EOL;
}

Photos

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get photosforeach ($school->photos->all() as$photo) {
echo$photo->hash . PHP_EOL;
}

Rooms

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get roomsforeach ($school->rooms->all() as$room) {
echo$room->name . PHP_EOL;
}

Subjects

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$school = $client->school('SCHOOL_ID_GOES_HERE');
// Get subjectsforeach ($school->subjects->all() as$subject) {
echo$subject->name . PHP_EOL;
}

Meta

$client = new \Wonde\Client('TOKEN_GOES_HERE');
$metaObject = $client->meta->get('SCHOOL_ID_GOES_HERE');

About

Wonde PHP Client

Resources

Stars

24 stars

Watchers

20 watching

Forks

Releases

Packages

Used by

Contributors

Languages