diff --git a/src/V1/Teacher/ResponseData/ActivityCollection.php b/src/V1/ResponseData/Activity/ActivityCollection.php similarity index 83% rename from src/V1/Teacher/ResponseData/ActivityCollection.php rename to src/V1/ResponseData/Activity/ActivityCollection.php index 8acd0f8..42c0aa3 100644 --- a/src/V1/Teacher/ResponseData/ActivityCollection.php +++ b/src/V1/ResponseData/Activity/ActivityCollection.php @@ -1,7 +1,7 @@ roomId = (int) $data['room_id']; + $this->roomName = (string) $data['room_name']; + $this->activities = ActivityCollection::make($data['activities']); + } + + /** + * @return int + */ + public function getRoomId(): int + { + return $this->roomId; + } + + /** + * @return string + */ + public function getRoomName(): string + { + return $this->roomName; + } + + /** + * @return ActivityCollection + */ + public function getActivities(): ActivityCollection + { + return $this->activities; + } +} diff --git a/src/V1/Room/ResponseData/SearchResponseData.php b/src/V1/ResponseData/Room/RoomSearchResponseData.php similarity index 82% rename from src/V1/Room/ResponseData/SearchResponseData.php rename to src/V1/ResponseData/Room/RoomSearchResponseData.php index 73334c3..2a24a03 100644 --- a/src/V1/Room/ResponseData/SearchResponseData.php +++ b/src/V1/ResponseData/Room/RoomSearchResponseData.php @@ -1,14 +1,14 @@ httpClient->request('GET', '/room-search', [ RequestOptions::QUERY => ['name' => $name], ]); $jsonResponse = json_decode($response->getBody()->getContents(), true); - return new SearchResponseData($jsonResponse); + return new RoomSearchResponseData($jsonResponse); + } + + /** + * @param int $id + * + * @return RoomScheduleResponseData + */ + public function schedule(int $id): RoomScheduleResponseData + { + $response = $this->httpClient->request('GET', "/room-schedule/$id"); + + $jsonResponse = json_decode($response->getBody()->getContents(), true); + + return new RoomScheduleResponseData($jsonResponse); } } diff --git a/src/V1/Teacher/Client.php b/src/V1/Teacher/Client.php index fd9b97d..516e49c 100644 --- a/src/V1/Teacher/Client.php +++ b/src/V1/Teacher/Client.php @@ -5,8 +5,8 @@ use GuzzleHttp\Client as HttpClient; use GuzzleHttp\RequestOptions; -use ZSTU\RozkladClient\V1\Teacher\ResponseData\ScheduleResponseData; -use ZSTU\RozkladClient\V1\Teacher\ResponseData\SearchResponseData; +use ZSTU\RozkladClient\V1\ResponseData\Teacher\TeacherScheduleResponseData; +use ZSTU\RozkladClient\V1\ResponseData\Teacher\TeacherSearchResponseData; /** * Class Client @@ -33,29 +33,29 @@ public function __construct(HttpClient $httpClient) /** * @param string $name * - * @return SearchResponseData + * @return TeacherSearchResponseData */ - public function search(string $name): SearchResponseData + public function search(string $name): TeacherSearchResponseData { $response = $this->httpClient->request('GET', '/teacher-search', [ RequestOptions::QUERY => ['name' => $name], ]); $jsonResponse = json_decode($response->getBody()->getContents(), true); - return new SearchResponseData($jsonResponse); + return new TeacherSearchResponseData($jsonResponse); } /** * @param int $id * - * @return ScheduleResponseData + * @return TeacherScheduleResponseData */ - public function schedule(int $id): ScheduleResponseData + public function schedule(int $id): TeacherScheduleResponseData { $response = $this->httpClient->request('GET', "/teacher-schedule/$id"); $jsonResponse = json_decode($response->getBody()->getContents(), true); - return new ScheduleResponseData($jsonResponse); + return new TeacherScheduleResponseData($jsonResponse); } }