PMT-9: Implement an API Client Factory for setting up the API Client with its Config
This commit is contained in:
parent
319f187cae
commit
a2cb7e6a59
1 changed files with 37 additions and 0 deletions
37
src/main/java/de/hmmh/pmt/employee/ApiClientFactory.java
Normal file
37
src/main/java/de/hmmh/pmt/employee/ApiClientFactory.java
Normal 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");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue