Browse Source

added url to json

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
main
Stephan Richter 4 months ago
parent
commit
d9698a8695
  1. 3
      de.srsoftware.cal.api/src/main/java/de/srsoftware/cal/api/Appointment.java
  2. 4
      de.srsoftware.cal.base/src/main/java/de/srsoftware/cal/BaseAppointment.java

3
de.srsoftware.cal.api/src/main/java/de/srsoftware/cal/api/Appointment.java

@ -52,9 +52,10 @@ public interface Appointment { @@ -52,9 +52,10 @@ public interface Appointment {
/**
* get a json representation of this Appointment
* @param urlTemplate the url to put into the ical, with "{}" being replaced by the appointment id
* @return a JSON Object
*/
JSONObject json();
JSONObject json(String urlTemplate);
/**
* set of Links that point to related information

4
de.srsoftware.cal.base/src/main/java/de/srsoftware/cal/BaseAppointment.java

@ -150,7 +150,7 @@ public class BaseAppointment implements Appointment { @@ -150,7 +150,7 @@ public class BaseAppointment implements Appointment {
}
@Override
public JSONObject json() {
public JSONObject json(String urlTemplate) {
var json = new JSONObject();
json.put("attachments", attachments.stream().map(Attachment::json).toList());
json.put("coords", nullable(coords).map(Coords::json).orElse(null));
@ -162,7 +162,7 @@ public class BaseAppointment implements Appointment { @@ -162,7 +162,7 @@ public class BaseAppointment implements Appointment {
json.put("tags", tags());
json.put("title", title());
json.put("links", links().stream().map(Link::json).toList());
json.put("url",urlTemplate.replace("{}",""+id()));
return json;
}

Loading…
Cancel
Save