Skip to content

Commit ae3c16b

Browse files
authored
Feature: get photos for personnel
2 parents f764a75 + 518c8db commit ae3c16b

File tree

4 files changed

+170
-0
lines changed

4 files changed

+170
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace Koba\Informat\Directories\Personnel\GetPhotoForEmployee;
4+
5+
use Koba\Informat\Call\AbstractCall;
6+
use Koba\Informat\Call\HasQueryParamsInterface;
7+
use Koba\Informat\Call\HasQueryParamsTrait;
8+
use Koba\Informat\Directories\DirectoryInterface;
9+
use Koba\Informat\Enums\HttpMethod;
10+
use Koba\Informat\Helpers\JsonMapper;
11+
use Koba\Informat\Responses\Personnel\Photo;
12+
13+
class GetPhotoForEmployeeCall
14+
extends AbstractCall
15+
implements HasQueryParamsInterface
16+
{
17+
use HasQueryParamsTrait;
18+
19+
protected string $personId;
20+
21+
public static function make(
22+
DirectoryInterface $directory,
23+
string $instituteNumber,
24+
string $personId
25+
): self {
26+
return (new self($directory, $instituteNumber))
27+
->setPersonId($personId);
28+
}
29+
30+
protected function getMethod(): HttpMethod
31+
{
32+
return HttpMethod::GET;
33+
}
34+
35+
protected function getEndpoint(): string
36+
{
37+
return "employees/{$this->personId}/photos";
38+
}
39+
40+
/**
41+
* Limits the output results to an employee with the provided personId.
42+
* The ID should contain a GUID.
43+
*/
44+
public function setPersonId(string $personId): self
45+
{
46+
$this->personId = $personId;
47+
return $this;
48+
}
49+
50+
51+
/**
52+
* Perform the API call.
53+
*/
54+
public function send(): mixed
55+
{
56+
return (new JsonMapper)->mapObject(
57+
$this->performRequest(),
58+
Photo::class
59+
);
60+
}
61+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace Koba\Informat\Directories\Personnel\GetPhotos;
4+
5+
use Koba\Informat\Call\AbstractCall;
6+
use Koba\Informat\Call\HasQueryParamsInterface;
7+
use Koba\Informat\Call\HasQueryParamsTrait;
8+
use Koba\Informat\Directories\DirectoryInterface;
9+
use Koba\Informat\Enums\HttpMethod;
10+
use Koba\Informat\Helpers\JsonMapper;
11+
use Koba\Informat\Helpers\Schoolyear;
12+
use Koba\Informat\Responses\Personnel\Photo;
13+
14+
class GetPhotosCall
15+
extends AbstractCall
16+
implements HasQueryParamsInterface
17+
{
18+
use HasQueryParamsTrait;
19+
20+
public static function make(
21+
DirectoryInterface $directory,
22+
string $instituteNumber,
23+
null|int|string $schoolyear = null,
24+
): self {
25+
return (new self($directory, $instituteNumber))
26+
->setSchoolyear($schoolyear);
27+
}
28+
29+
protected function getMethod(): HttpMethod
30+
{
31+
return HttpMethod::GET;
32+
}
33+
34+
protected function getEndpoint(): string
35+
{
36+
return 'employees/photos';
37+
}
38+
39+
/**
40+
* For current & future school years:
41+
* It limits the output results to photos for employees with an assignment
42+
* within the given schoolyear (and instituteNo) or which are marked as
43+
* active for your instituteNo.
44+
*
45+
* For passed school years:
46+
* It limits the output results to photos for employees with an assignment
47+
* within the given schoolyear (and instituteNo).
48+
*/
49+
public function setSchoolyear(null|int|string $schoolyear): self
50+
{
51+
$this->setQueryParam('schoolYear', new Schoolyear($schoolyear));
52+
return $this;
53+
}
54+
55+
/**
56+
* This is an actually an additional restriction on the school year filter.
57+
*/
58+
public function setStructure(string $structure): self
59+
{
60+
$this->setQueryParam('structure', $structure);
61+
return $this;
62+
}
63+
64+
/**
65+
* Perform the API call.
66+
*/
67+
public function send(): mixed
68+
{
69+
return (new JsonMapper)->mapArray(
70+
$this->performRequest(),
71+
Photo::class
72+
);
73+
}
74+
}

src/Informat/Directories/Personnel/PersonnelDirectory.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Koba\Informat\Directories\Personnel\GetInterruptions\GetInterruptionsCall;
1717
use Koba\Informat\Directories\Personnel\GetInterruptionsForEmployee\GetInterruptionsForEmployeeCall;
1818
use Koba\Informat\Directories\Personnel\GetOwnFields\GetOwnFieldsCall;
19+
use Koba\Informat\Directories\Personnel\GetPhotoForEmployee\GetPhotoForEmployeeCall;
20+
use Koba\Informat\Directories\Personnel\GetPhotos\GetPhotosCall;
1921
use Koba\Informat\Enums\BaseUrl;
2022
use Koba\Informat\Enums\InterruptionCode;
2123
use Koba\Informat\Helpers\File;
@@ -244,4 +246,25 @@ public function deleteInterruptionAttachment(
244246
$attachmentId
245247
);
246248
}
249+
250+
/**
251+
* Gets all the photos for the combination institute number, school year
252+
* and structure.
253+
*/
254+
public function getPhotos(
255+
string $instituteNumber,
256+
null|int|string $schoolyear = null,
257+
): GetPhotosCall {
258+
return GetPhotosCall::make($this, $instituteNumber, $schoolyear);
259+
}
260+
261+
/**
262+
* Gets an employee’s photo by personId
263+
*/
264+
public function getPhotoForEmployee(
265+
string $instituteNumber,
266+
string $personId,
267+
): GetPhotoForEmployeeCall {
268+
return GetPhotoForEmployeeCall::make($this, $instituteNumber, $personId);
269+
}
247270
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Koba\Informat\Responses\Personnel;
4+
5+
class Photo
6+
{
7+
public string $id;
8+
9+
public string $personId;
10+
11+
public string $photo;
12+
}

0 commit comments

Comments
 (0)