test: endpoints
This commit is contained in:
parent
cdf625294a
commit
48e5581525
2 changed files with 71 additions and 10 deletions
|
|
@ -25,62 +25,69 @@ public class Endpoints {
|
|||
return this.configService.getConfig().getServerUrl() + "/api";
|
||||
}
|
||||
|
||||
public String createApiUrl(String route) {
|
||||
return this.baseUrl() + route;
|
||||
}
|
||||
|
||||
public HttpRequest.Builder fetchAllRecipes(List<String> locales) {
|
||||
String url = this.baseUrl() + "/recipes" + "?locales=" + String.join(",", locales);
|
||||
String url = this.createApiUrl(
|
||||
"/recipe" +
|
||||
"?locales=" + String.join(",", locales)
|
||||
);
|
||||
|
||||
return this.http(url).GET();
|
||||
}
|
||||
|
||||
public HttpRequest.Builder fetchRecipe(long recipeId) {
|
||||
String url = this.baseUrl() + "/recipe/" + recipeId;
|
||||
String url = this.createApiUrl("/recipe/" + recipeId);
|
||||
|
||||
return this.http(url).GET();
|
||||
}
|
||||
|
||||
public HttpRequest.Builder createNewRecipe(HttpRequest.BodyPublisher body) {
|
||||
String url = this.baseUrl() + "/recipe/new";
|
||||
String url = this.createApiUrl("/recipe/new");
|
||||
|
||||
return this.http(url).PUT(body);
|
||||
}
|
||||
|
||||
public HttpRequest.Builder updateRecipe(long recipeId, HttpRequest.BodyPublisher body) {
|
||||
String url = this.baseUrl() + "/recipe/" + recipeId;
|
||||
String url = this.createApiUrl("/recipe/" + recipeId);
|
||||
|
||||
return this.http(url).POST(body);
|
||||
}
|
||||
|
||||
public HttpRequest.Builder deleteRecipe(long recipeId) {
|
||||
String url = this.baseUrl() + "/recipe/" + recipeId;
|
||||
String url = this.createApiUrl("/recipe/" + recipeId);
|
||||
|
||||
return this.http(url).DELETE();
|
||||
}
|
||||
|
||||
public HttpRequest.Builder fetchIngredientUsage(long ingredientId) {
|
||||
String url = this.baseUrl() + "/ingredients/" + ingredientId + "/usage";
|
||||
String url = this.createApiUrl("/ingredients/" + ingredientId + "/usage");
|
||||
|
||||
return this.http(url).GET();
|
||||
}
|
||||
|
||||
public HttpRequest.Builder deleteIngredient(long ingredientId) {
|
||||
String url = this.baseUrl() + "/ingredients/" + ingredientId;
|
||||
String url = this.createApiUrl("/ingredients/" + ingredientId);
|
||||
|
||||
return this.http(url).DELETE();
|
||||
}
|
||||
|
||||
public HttpRequest.Builder getIngredients() {
|
||||
String url = this.baseUrl() + "/ingredients";
|
||||
String url = this.createApiUrl("/ingredients");
|
||||
|
||||
return this.http(url).GET();
|
||||
}
|
||||
|
||||
public HttpRequest.Builder createIngredient(HttpRequest.BodyPublisher body) {
|
||||
String url = this.baseUrl() + "/ingredients";
|
||||
String url = this.createApiUrl("/ingredients");
|
||||
|
||||
return this.http(url).POST(body);
|
||||
}
|
||||
|
||||
public HttpRequest.Builder updateIngredient(long ingredientId, HttpRequest.BodyPublisher body) {
|
||||
String url = this.baseUrl() + "/ingredients/" + ingredientId;
|
||||
String url = this.createApiUrl("/ingredients/" + ingredientId);
|
||||
|
||||
return this.http(url).method("PATCH", body);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue