Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Koba\Informat\Directories\Personnel\GetPhotoForEmployee;

use Koba\Informat\Call\AbstractCall;
use Koba\Informat\Call\HasQueryParamsInterface;
use Koba\Informat\Call\HasQueryParamsTrait;
use Koba\Informat\Directories\DirectoryInterface;
use Koba\Informat\Enums\HttpMethod;
use Koba\Informat\Helpers\JsonMapper;
use Koba\Informat\Responses\Personnel\Photo;

class GetPhotoForEmployeeCall
extends AbstractCall
implements HasQueryParamsInterface
{
use HasQueryParamsTrait;

protected string $personId;

public static function make(
DirectoryInterface $directory,
string $instituteNumber,
string $personId
): self {
return (new self($directory, $instituteNumber))
->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)->mapObject(
$this->performRequest(),
Photo::class
);
}
}
74 changes: 74 additions & 0 deletions src/Informat/Directories/Personnel/GetPhotos/GetPhotosCall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Koba\Informat\Directories\Personnel\GetPhotos;

use Koba\Informat\Call\AbstractCall;
use Koba\Informat\Call\HasQueryParamsInterface;
use Koba\Informat\Call\HasQueryParamsTrait;
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 GetPhotosCall
extends AbstractCall
implements HasQueryParamsInterface
{
use HasQueryParamsTrait;

public static function make(
DirectoryInterface $directory,
string $instituteNumber,
null|int|string $schoolyear = null,
): self {
return (new self($directory, $instituteNumber))
->setSchoolyear($schoolyear);
}

protected function getMethod(): HttpMethod
{
return HttpMethod::GET;
}

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.
*/
public function setStructure(string $structure): self
{
$this->setQueryParam('structure', $structure);
return $this;
}

/**
* Perform the API call.
*/
public function send(): mixed
{
return (new JsonMapper)->mapArray(
$this->performRequest(),
Photo::class
);
}
}
23 changes: 23 additions & 0 deletions src/Informat/Directories/Personnel/PersonnelDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
12 changes: 12 additions & 0 deletions src/Informat/Responses/Personnel/Photo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Koba\Informat\Responses\Personnel;

class Photo
{
public string $id;

public string $personId;

public string $photo;
}