This repository was archived by the owner on Feb 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdukacjaAPI.java
More file actions
41 lines (35 loc) · 1.97 KB
/
EdukacjaAPI.java
File metadata and controls
41 lines (35 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package dev.wms.pwrapi.api;
import java.io.IOException;
import java.util.List;
import dev.wms.pwrapi.entity.edukacja.Subject;
import dev.wms.pwrapi.scrapper.edukacja.EdukacjaScrapperService;
import dev.wms.pwrapi.service.edukacja.EduService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/api/edukacja", produces = "application/json")
@RequiredArgsConstructor
public class EdukacjaAPI {
private final EduService edukacjaService;
private final EdukacjaScrapperService scrapperService;
@GetMapping("/wektor")
@Operation(summary = "Return available group for user's most recent enrollments",
description = "This endpoint is probably going to be deprecated, because of migration of enrollment system to USOS. " +
"It's implementation is slow and based on Selenium, rather than scraping HTTP requests")
public ResponseEntity<List<Subject>> getAvailableGroups(@RequestParam("login") String login, @RequestParam("password") String password ) throws IOException {
List<Subject> response = edukacjaService.doFetchSubjects(login, password);
return ResponseEntity.status(HttpStatus.OK).body(response);
}
@GetMapping
@Operation(summary = "Checks if login and password can be used to login to edukacja.cl",
description = "Just a simple endpoint. You can use it to validate data and save it for later")
public void loginToEdukacja(@RequestParam("login") String login, @RequestParam("password") String password) throws IOException{
scrapperService.fetchHTMLConnectionDetails(login, password);
}
}