package com.robinpowered.sdk.model; import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; import org.joda.time.DateTime; import java.util.List; /** * A meeting or reservation, booked in a {@link Space}. * * <p> * While {@link Presence} represents the current state of who is within a space, an event is a pre-booked * reservation for a space that multiple people may be invited to. * * <p> * Events are often synchronized from an external calendar service, such as Google Calendar or * Office 365. Events may also be created by booking a Space through Robin. * * @todo This class needs further design once APIs are fully realized. */ public class Event implements IdentifiableApiResponseModel<String> { /** * Constants */ public static final String MIME_TYPE = "vnd.robinpowered.event.v1"; public enum CreationType { /** * The event was created manually. */ @SerializedName("manual") MANUAL("manual"), /** * The event was automatically generated by robin based on presence. */ @SerializedName("automatic") AUTOMATIC("automatic"), /** * The event was synced from a remote service. */ @SerializedName("synced") SYNCED("synced"); private final String value; public String getValue() { return value; } CreationType(String value) { this.value = value; } public static CreationType fromString(String value) { return valueOf(value.toUpperCase()); } } /** * Properties */ private final String id; private Integer organizerId; private String organizerEmail; private Integer creatorId; private String creatorEmail; private Integer spaceId; private String title; private String description; private String location; private String remoteEventId; private String remoteType; private CreationType creationType; private DateTime startedAt; private DateTime endedAt; private Boolean isAllDay; private List<Invitable> invitees; private Confirmation confirmation; /** * Methods */ public Event(String id) { this.id = id; } @Override public String getId() { return id; } public Integer getOrganizerId() { return organizerId; } public void setOrganizerId(Integer organizerId) { this.organizerId = organizerId; } public String getOrganizerEmail() { return organizerEmail; } public void setOrganizerEmail(String organizerEmail) { this.organizerEmail = organizerEmail; } public Integer getCreatorId() { return creatorId; } public void setCreatorId(Integer creatorId) { this.creatorId = creatorId; } public String getCreatorEmail() { return creatorEmail; } public void setCreatorEmail(String creatorEmail) { this.creatorEmail = creatorEmail; } public Integer getSpaceId() { return spaceId; } public void setSpaceId(Integer spaceId) { this.spaceId = spaceId; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } public String getRemoteEventId() { return remoteEventId; } public void setRemoteEventId(String remoteEventId) { this.remoteEventId = remoteEventId; } public String getRemoteType() { return remoteType; } public void setRemoteType(String remoteType) { this.remoteType = remoteType; } public CreationType getCreationType() { return creationType; } public void setCreationType(CreationType creationType) { this.creationType = creationType; } public DateTime getStartedAt() { return startedAt; } public void setStartedAt(DateTime startedAt) { this.startedAt = startedAt; } public DateTime getEndedAt() { return endedAt; } public void setEndedAt(DateTime endedAt) { this.endedAt = endedAt; } public Boolean isAllDay() { return isAllDay; } public void setIsAllDay(Boolean isAllDay) { this.isAllDay = isAllDay; } public void setInvitees(List<Invitable> invitees) { this.invitees = invitees; } public Confirmation getConfirmation() { return confirmation; } /** * Returns a list of the event's invitees. This may return {@code null} if the {@code invitees} * submodel collection wasn't provided by the API. * * @return A list of the event's invitees. */ public List<Invitable> getInvitees() { return invitees; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Event event = (Event) o; return Objects.equal(id, event.id); } @Override public int hashCode() { return Objects.hashCode(id); } @Override public String toString() { return "Event{" + "id=" + id + ", organizerId=" + organizerId + ", organizerEmail='" + organizerEmail + '\'' + ", creatorId=" + creatorId + ", creatorEmail='" + creatorEmail + '\'' + ", spaceId=" + spaceId + ", title='" + title + '\'' + ", description='" + description + '\'' + ", location='" + location + '\'' + ", remoteEventId='" + remoteEventId + '\'' + ", remoteType='" + remoteType + '\'' + ", creationType=" + creationType + ", startedAt=" + startedAt + ", endedAt=" + endedAt + ", isAllDay=" + isAllDay + ", invitees=" + invitees + '}'; } @Override public String getMimeType() { return MIME_TYPE; } /** * An intention to create an {@link Event} and book a space. */ public static class Booking { private final String ownerRef; private final String title; private final String description; private final DateTime startedAt; private final DateTime endedAt; private final boolean isAllDay; private final List<Invitable> invitees; public Booking(String ownerRef, String title, String description, DateTime startedAt, DateTime endedAt, boolean isAllDay, List<Invitable> invitees) { this.ownerRef = ownerRef; this.title = title; this.description = description; this.startedAt = startedAt; this.endedAt = endedAt; this.isAllDay = isAllDay; this.invitees = invitees; } } }