edu.ksu.canvas.requestOptions.ListCalendarEventsOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of canvas-api Show documentation
Show all versions of canvas-api Show documentation
A native Java library to talk to the Canvas REST API
package edu.ksu.canvas.requestOptions;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.List;
/**
* These are the options for listing calendar events.
* The same options are used for both the current user and a specific user.
*/
public class ListCalendarEventsOptions extends BaseOptions {
public enum Type {
EVENT, ASSIGNMENT;
@Override
public String toString() { return name().toLowerCase(); }
}
public enum Exclude {
DESCRIPTION, CHILD_EVENTS, ASSIGNMENT;
@Override
public String toString() { return name().toLowerCase(); }
}
public ListCalendarEventsOptions type(Type eventType) {
addSingleItem("type", eventType.toString());
return this;
}
public ListCalendarEventsOptions startDate(LocalDate startDate) {
addSingleItem("start_date", DateTimeFormatter.ISO_LOCAL_DATE.format(startDate));
return this;
}
public ListCalendarEventsOptions startDate(TemporalAccessor startDate) {
addSingleItem("start_date", DateTimeFormatter.ISO_INSTANT.format(startDate));
return this;
}
public ListCalendarEventsOptions endDate(LocalDate endDate) {
addSingleItem("end_date", DateTimeFormatter.ISO_LOCAL_DATE.format(endDate));
return this;
}
public ListCalendarEventsOptions endDate(TemporalAccessor endDate) {
addSingleItem("end_date", DateTimeFormatter.ISO_INSTANT.format(endDate));
return this;
}
public ListCalendarEventsOptions includeUndated(boolean include) {
addSingleItem("undated", Boolean.toString(include));
return this;
}
public ListCalendarEventsOptions includeAllEvents(boolean all) {
addSingleItem("all_events", Boolean.toString(all));
return this;
}
// TODO could have limiting to 10 and building of strings in here.
public ListCalendarEventsOptions contextCodes(List contextCodes) {
optionsMap.put("context_codes[]", contextCodes);
return this;
}
public ListCalendarEventsOptions excludes(List excludes) {
addEnumList("excludes[]", excludes);
return this;
}
}