-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...java/de/caritas/cob/mailservice/config/apiclient/TranlationMangementServiceApiClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package de.caritas.cob.mailservice.config.apiclient; | ||
|
||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TranlationMangementServiceApiClient { | ||
|
||
@Value("${weblate.api.url}") | ||
private String apiUrl; | ||
|
||
@Value("${weblate.api.key}") | ||
private String apiKey; | ||
|
||
|
||
|
||
private final @NonNull RestTemplate restTemplate; | ||
|
||
public String tryFetchTranslationsFromTranslationManagementService(String project, | ||
String component, String languageCode) { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.set("Authorization", "Token " + apiKey); | ||
String url = apiUrl + "translations/" + project + "/" + component + "/test" + "/" + languageCode | ||
+ "/file.json"; | ||
|
||
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, | ||
new HttpEntity<>(headers), String.class); | ||
return response.getBody(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters