diff --git a/src/main/java/de/hmmh/pmt/employee/ApiClientFactory.java b/src/main/java/de/hmmh/pmt/employee/ApiClientFactory.java new file mode 100644 index 0000000..621ab58 --- /dev/null +++ b/src/main/java/de/hmmh/pmt/employee/ApiClientFactory.java @@ -0,0 +1,37 @@ +package de.hmmh.pmt.employee; + +import de.hmmh.pmt.auth.JwtToken; +import de.hmmh.pmt.employee.api.EmployeeControllerApi; +import de.hmmh.pmt.employee.api.QualificationControllerApi; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ApiClientFactory { + + @Autowired + private ApiClient apiClient; + @Autowired + private JwtToken apiToken; + @Autowired + private EmployeeControllerApi employee; + @Autowired + private QualificationControllerApi qualification; + + public EmployeeControllerApi getEmployeeApi() { + prepareApiClient(); + employee.setApiClient(apiClient); + return employee; + } + + public QualificationControllerApi getQualificationApi() { + prepareApiClient(); + qualification.setApiClient(apiClient); + return qualification; + } + + private void prepareApiClient() { + apiClient.setAccessToken(apiToken.getToken()); + apiClient.setBasePath("https://employee.szut.dev"); + } +}