Stirling-PDF/src/main/java/stirling/software/SPDF/model/ApiEndpoint.java

36 lines
961 B
Java
Raw Normal View History

2023-12-25 17:15:42 +01:00
package stirling.software.SPDF.model;
import java.util.HashMap;
2023-12-25 17:16:50 +01:00
import java.util.Map;
2023-12-25 17:15:42 +01:00
import com.fasterxml.jackson.databind.JsonNode;
public class ApiEndpoint {
private String name;
private Map<String, JsonNode> parameters;
public ApiEndpoint(String name, JsonNode postNode) {
this.name = name;
this.parameters = new HashMap<>();
postNode.path("parameters").forEach(paramNode -> {
String paramName = paramNode.path("name").asText();
parameters.put(paramName, paramNode);
});
}
public boolean areParametersValid(Map<String, Object> providedParams) {
for (String requiredParam : parameters.keySet()) {
if (!providedParams.containsKey(requiredParam)) {
return false;
}
}
return true;
}
2023-12-25 21:51:32 +01:00
@Override
public String toString() {
return "ApiEndpoint [name=" + name + ", parameters=" + parameters + "]";
}
2023-12-25 17:15:42 +01:00
}