44import fr .sandro642 .github .api .ApiClient ;
55import fr .sandro642 .github .api .ApiFactory ;
66import fr .sandro642 .github .enums .MethodType ;
7- import fr .sandro642 .github .enums .VersionType ;
87import fr .sandro642 .github .enums .lang .CategoriesType ;
98
109import java .util .Map ;
@@ -27,19 +26,24 @@ public class JobGetInfos {
2726 * ApiClient is used to make API calls.
2827 * It is initialized in the constructor of JobGetInfos.
2928 */
30- private final ApiClient apiClient ;
29+ private ApiClient apiClient ;
3130
3231 /**
3332 * connectLib instance to access its methods and properties.
3433 */
3534 private ConnectLib connectLib = new ConnectLib ();
3635
36+ /**
37+ * URLProvider instance to provide custom URL branches.
38+ * If not set, the default URL from the configuration will be used.
39+ */
40+ private URLProvider urlBranch ;
41+
3742 /**
3843 * Constructor of JobGetInfos.
3944 * Initializes the ApiClient and loads the YAML configuration.
4045 */
4146 public JobGetInfos () {
42- this .apiClient = new ApiClient ();
4347 connectLib .YamlUtils ();
4448 }
4549
@@ -245,6 +249,18 @@ public <R> JobGetInfos getRoutes(VersionProvider versionType, MethodType methodT
245249 return this ;
246250 }
247251
252+ /**
253+ * Set a custom URL branch for the API calls.
254+ * If not set, the default URL from the configuration will be used.
255+ * @param urlBranch The URLProvider instance providing the custom URL branch.
256+ * @return JobGetInfos for chaining
257+ */
258+ public JobGetInfos urlBranch (URLProvider urlBranch ) {
259+
260+ this .urlBranch = urlBranch ;
261+ return this ;
262+ }
263+
248264 /**
249265 * Get the response from the API based on the current route and method.
250266 * This method retrieves the stored route, method, and body from the store,
@@ -261,6 +277,16 @@ public CompletableFuture<ApiFactory> getResponse() {
261277 connectLib .Logger ().ERROR (connectLib .LangManager ().getMessage (CategoriesType .JOBS_PACKAGE , "getresponse.mustbe" ));
262278 }
263279
280+ /** Determine the URL branch to use */
281+ String urlBranchLambda ;
282+
283+ if (urlBranch == null ) {
284+ urlBranchLambda = (String ) connectLib .StoreAndRetrieve ().store .get (connectLib .StoreAndRetrieve ().URL_KEY );
285+ } else {
286+ urlBranchLambda = urlBranch .getURL ();
287+ }
288+ apiClient = new ApiClient (urlBranchLambda );
289+
264290 CompletableFuture <ApiFactory > responseFuture = new CompletableFuture <>();
265291
266292 // Callback to clean up the store after the response
0 commit comments