Skip to content

Latest commit

 

History

History
71 lines (53 loc) · 1.91 KB

teacher-api.md

File metadata and controls

71 lines (53 loc) · 1.91 KB

Add the teacher

require 'vendor/autoload.php';

use mikemix\Wiziq;

$auth    = new Wiziq\API\Auth('your-secret-access-key', 'public-access-key');
$gateway = new Wiziq\API\Gateway($auth);
$api     = new Wiziq\API\TeacherApi($gateway);

try {
    $teacher = Wiziq\Entity\Teacher::build('Mike Test', '[email protected]', 'his_password')
        ->withAbout('I am the best teacher there is!')
        ->withTimeZone('Europe/Warsaw')
        ->withImage('http://some.cdn.net/my-avatar.png');

    $teacherId = $api->addTeacher($teacher);

    printf('Teacher %s added!', $teacher);
} catch (Wiziq\Common\Api\Exception\CallException $e) {
    die($e->getMessage());
} catch (Wiziq\Common\Http\Exception\InvalidResponseException $e) {
    die($e->getMessage());
}

Edit the teacher

require 'vendor/autoload.php';

use mikemix\Wiziq;

$auth    = new Wiziq\API\Auth('your-secret-access-key', 'public-access-key');
$gateway = new Wiziq\API\Gateway($auth);
$api     = new Wiziq\API\TeacherApi($gateway);

try {
    $teacher = Wiziq\Entity\Teacher::build('Mike Test', '[email protected]', 'his_new_password');
    $api->editTeacher($teacherId, $teacher);

    printf('Teacher %s edited!', $teacher);
} catch (Wiziq\Common\Api\Exception\CallException $e) {
    die($e->getMessage());
} catch (Wiziq\Common\Http\Exception\InvalidResponseException $e) {
    die($e->getMessage());
}

Get teacher details

require 'vendor/autoload.php';

use mikemix\Wiziq;

$auth    = new Wiziq\API\Auth('your-secret-access-key', 'public-access-key');
$gateway = new Wiziq\API\Gateway($auth);
$api     = new Wiziq\API\TeacherApi($gateway);

try {
    $details = $api->getTeacherDetails($teacherId);

    printf('Teacher details: %s', var_export($details, true));
} catch (Wiziq\Common\Api\Exception\CallException $e) {
    die($e->getMessage());
} catch (Wiziq\Common\Http\Exception\InvalidResponseException $e) {
    die($e->getMessage());
}