From cd688a72b23aa9a8704171860e5b938c48880344 Mon Sep 17 00:00:00 2001 From: Geert Huylebroeck Date: Thu, 27 Mar 2025 22:27:46 +0100 Subject: [PATCH 1/2] Photos --- .../GetPhotoForEmployeeCall.php | 61 +++++++++++++++++++ .../Personnel/GetPhotos/GetPhotosCall.php | 55 +++++++++++++++++ src/Informat/Responses/Personnel/Photo.php | 11 ++++ 3 files changed, 127 insertions(+) create mode 100644 src/Informat/Directories/Personnel/GetPhotoForEmployee/GetPhotoForEmployeeCall.php create mode 100644 src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php create mode 100644 src/Informat/Responses/Personnel/Photo.php diff --git a/src/Informat/Directories/Personnel/GetPhotoForEmployee/GetPhotoForEmployeeCall.php b/src/Informat/Directories/Personnel/GetPhotoForEmployee/GetPhotoForEmployeeCall.php new file mode 100644 index 0000000..d15c10b --- /dev/null +++ b/src/Informat/Directories/Personnel/GetPhotoForEmployee/GetPhotoForEmployeeCall.php @@ -0,0 +1,61 @@ +setPersonId($personId); + } + + protected function getMethod(): HttpMethod + { + return HttpMethod::GET; + } + + protected function getEndpoint(): string + { + return "employees/{$this->personId}/photos"; + } + + /** + * Limits the output results to an employee with the provided personId. + * The ID should contain a GUID. + */ + public function setPersonId(string $personId): self + { + $this->personId = $personId; + return $this; + } + + + /** + * Perform the API call. + */ + public function send(): mixed + { + return (new JsonMapper)->mapArray( + $this->performRequest(), + Photo::class + ); + } +} diff --git a/src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php b/src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php new file mode 100644 index 0000000..6e08c32 --- /dev/null +++ b/src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php @@ -0,0 +1,55 @@ +setQueryParam('structure', $structure); + return $this; + } + + /** + * Perform the API call. + */ + public function send(): mixed + { + return (new JsonMapper)->mapArray( + $this->performRequest(), + Photo::class + ); + } +} diff --git a/src/Informat/Responses/Personnel/Photo.php b/src/Informat/Responses/Personnel/Photo.php new file mode 100644 index 0000000..7399757 --- /dev/null +++ b/src/Informat/Responses/Personnel/Photo.php @@ -0,0 +1,11 @@ + Date: Fri, 28 Mar 2025 09:51:03 +0100 Subject: [PATCH 2/2] Add personeel photo calls to directory --- .../GetPhotoForEmployeeCall.php | 2 +- .../Personnel/GetPhotos/GetPhotosCall.php | 23 +++++++++++++++++-- .../Personnel/PersonnelDirectory.php | 23 +++++++++++++++++++ src/Informat/Responses/Personnel/Photo.php | 5 ++-- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/Informat/Directories/Personnel/GetPhotoForEmployee/GetPhotoForEmployeeCall.php b/src/Informat/Directories/Personnel/GetPhotoForEmployee/GetPhotoForEmployeeCall.php index d15c10b..e191d8f 100644 --- a/src/Informat/Directories/Personnel/GetPhotoForEmployee/GetPhotoForEmployeeCall.php +++ b/src/Informat/Directories/Personnel/GetPhotoForEmployee/GetPhotoForEmployeeCall.php @@ -53,7 +53,7 @@ public function setPersonId(string $personId): self */ public function send(): mixed { - return (new JsonMapper)->mapArray( + return (new JsonMapper)->mapObject( $this->performRequest(), Photo::class ); diff --git a/src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php b/src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php index 6e08c32..2c558ea 100644 --- a/src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php +++ b/src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php @@ -8,9 +8,10 @@ use Koba\Informat\Directories\DirectoryInterface; use Koba\Informat\Enums\HttpMethod; use Koba\Informat\Helpers\JsonMapper; +use Koba\Informat\Helpers\Schoolyear; use Koba\Informat\Responses\Personnel\Photo; -class GetPhotos +class GetPhotosCall extends AbstractCall implements HasQueryParamsInterface { @@ -19,8 +20,10 @@ class GetPhotos public static function make( DirectoryInterface $directory, string $instituteNumber, + null|int|string $schoolyear = null, ): self { - return (new self($directory, $instituteNumber)); + return (new self($directory, $instituteNumber)) + ->setSchoolyear($schoolyear); } protected function getMethod(): HttpMethod @@ -33,6 +36,22 @@ protected function getEndpoint(): string return 'employees/photos'; } + /** + * For current & future school years: + * It limits the output results to photos for employees with an assignment + * within the given schoolyear (and instituteNo) or which are marked as + * active for your instituteNo. + * + * For passed school years: + * It limits the output results to photos for employees with an assignment + * within the given schoolyear (and instituteNo). + */ + public function setSchoolyear(null|int|string $schoolyear): self + { + $this->setQueryParam('schoolYear', new Schoolyear($schoolyear)); + return $this; + } + /** * This is an actually an additional restriction on the school year filter. */ diff --git a/src/Informat/Directories/Personnel/PersonnelDirectory.php b/src/Informat/Directories/Personnel/PersonnelDirectory.php index 8fa86fd..2c3efba 100644 --- a/src/Informat/Directories/Personnel/PersonnelDirectory.php +++ b/src/Informat/Directories/Personnel/PersonnelDirectory.php @@ -16,6 +16,8 @@ use Koba\Informat\Directories\Personnel\GetInterruptions\GetInterruptionsCall; use Koba\Informat\Directories\Personnel\GetInterruptionsForEmployee\GetInterruptionsForEmployeeCall; use Koba\Informat\Directories\Personnel\GetOwnFields\GetOwnFieldsCall; +use Koba\Informat\Directories\Personnel\GetPhotoForEmployee\GetPhotoForEmployeeCall; +use Koba\Informat\Directories\Personnel\GetPhotos\GetPhotosCall; use Koba\Informat\Enums\BaseUrl; use Koba\Informat\Enums\InterruptionCode; use Koba\Informat\Helpers\File; @@ -244,4 +246,25 @@ public function deleteInterruptionAttachment( $attachmentId ); } + + /** + * Gets all the photos for the combination institute number, school year + * and structure. + */ + public function getPhotos( + string $instituteNumber, + null|int|string $schoolyear = null, + ): GetPhotosCall { + return GetPhotosCall::make($this, $instituteNumber, $schoolyear); + } + + /** + * Gets an employee’s photo by personId + */ + public function getPhotoForEmployee( + string $instituteNumber, + string $personId, + ): GetPhotoForEmployeeCall { + return GetPhotoForEmployeeCall::make($this, $instituteNumber, $personId); + } } diff --git a/src/Informat/Responses/Personnel/Photo.php b/src/Informat/Responses/Personnel/Photo.php index 7399757..35871ab 100644 --- a/src/Informat/Responses/Personnel/Photo.php +++ b/src/Informat/Responses/Personnel/Photo.php @@ -4,8 +4,9 @@ class Photo { + public string $id; + public string $personId; - public string $photo; - + public string $photo; }