PMT-9: Implement an API Client Factory for setting up the API Client with its Config

This commit is contained in:
Dominik Säume 2024-09-30 09:10:01 +02:00
parent 319f187cae
commit a2cb7e6a59
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C

View file

@ -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");
}
}