working on calendar application

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2024-12-26 12:00:43 +01:00
parent 0731613a07
commit 9f806637c2
20 changed files with 484 additions and 156 deletions
+1
View File
@@ -2,4 +2,5 @@ description = "OpenCloudCal : API"
dependencies {
implementation("de.srsoftware:tools.util:1.2.1")
implementation("org.json:json:20240303")
}
@@ -4,6 +4,7 @@ package de.srsoftware.cal.api;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.Set;
import org.json.JSONObject;
/**
* This is the central object of the calendar: An appointment
@@ -41,6 +42,12 @@ public interface Appointment {
long id();
/**
* get a json representation of this Appointment
* @return a JSON Object
*/
JSONObject json();
/**
* descriptive text of the location, e.g. address
* @return location text
@@ -2,6 +2,8 @@
package de.srsoftware.cal.api;
import java.net.URL;
import java.util.Map;
import org.json.JSONObject;
/**
* an attachment for appointments
@@ -9,4 +11,7 @@ import java.net.URL;
* @param mime the mime type of the attached document
*/
public record Attachment(URL url, String mime) {
public JSONObject json() {
return new JSONObject(Map.of("url", url.toString(), "mime", mime));
}
}
@@ -1,10 +1,16 @@
/* © SRSoftware 2024 */
package de.srsoftware.cal.api;
import java.util.Map;
import org.json.JSONObject;
/**
* cartesian coords
* @param longitude the longitude
* @param latitude the latitude
*/
public record Coords(double longitude, double latitude) {
public JSONObject json() {
return new JSONObject(Map.of("lon", longitude, "lat", latitude));
}
}
@@ -2,6 +2,8 @@
package de.srsoftware.cal.api;
import java.net.URL;
import java.util.Map;
import org.json.JSONObject;
/**
* Links are additional content that may be added to appointments
@@ -9,4 +11,7 @@ import java.net.URL;
* @param desciption some information about the target of the link
*/
public record Link(URL url, String desciption) {
public JSONObject json() {
return new JSONObject(Map.of("description", desciption(), "url", url().toString()));
}
}