Skip to content

Commit b5bfa6f

Browse files
Added endpoints for free-busy spaces.
1 parent 7347aa7 commit b5bfa6f

5 files changed

Lines changed: 194 additions & 4 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.robinpowered.sdk.model;
2+
3+
import org.joda.time.DateTime;
4+
5+
import java.util.List;
6+
7+
public class Busy {
8+
9+
/**
10+
* Constants
11+
*/
12+
13+
public static final String MIME_TYPE = "vnd.robinpowered.busy.v1";
14+
15+
16+
/**
17+
* Properties
18+
*/
19+
20+
private DateTime from;
21+
private DateTime to;
22+
private List<SimpleEvent> events;
23+
24+
25+
/**
26+
* Methods
27+
*/
28+
29+
public Busy(DateTime from, DateTime to, List<SimpleEvent> events) {
30+
this.from = from;
31+
this.to = to;
32+
this.events = events;
33+
}
34+
35+
public static String getMimeType() {
36+
return MIME_TYPE;
37+
}
38+
39+
public List<SimpleEvent> getSimpleEvents() {
40+
return events;
41+
}
42+
43+
public DateTime getFrom() {
44+
return from;
45+
}
46+
47+
public DateTime getTo() {
48+
return to;
49+
}
50+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.robinpowered.sdk.model;
2+
3+
import java.util.List;
4+
5+
public interface FreeBusy {
6+
7+
List<Busy> getBusy();
8+
9+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.robinpowered.sdk.model;
2+
3+
import java.util.List;
4+
5+
public class FreeBusySpace implements ApiResponseModel, FreeBusy {
6+
7+
/**
8+
* Constants
9+
*/
10+
11+
public static final String MIME_TYPE = "vnd.robinpowered.free-busy-space.v1";
12+
13+
14+
/**
15+
* Properties
16+
*/
17+
18+
private boolean hasPresence;
19+
private Space space;
20+
private List<Busy> busy;
21+
22+
23+
/**
24+
* Methods
25+
*/
26+
27+
public FreeBusySpace(boolean hasPresence, Space space, List<Busy> busy) {
28+
this.hasPresence = hasPresence;
29+
this.space = space;
30+
this.busy = busy;
31+
}
32+
33+
@Override
34+
public String getMimeType() {
35+
return MIME_TYPE;
36+
}
37+
38+
public boolean isHasPresence() {
39+
return hasPresence;
40+
}
41+
42+
public Space getSpace() {
43+
return space;
44+
}
45+
46+
public List<Busy> getBusy() {
47+
return busy;
48+
}
49+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.robinpowered.sdk.model;
2+
3+
import com.google.common.base.Objects;
4+
5+
import org.joda.time.DateTime;
6+
7+
/**
8+
* A simplified {@link Event}.
9+
*
10+
* <p>
11+
* A simplified version of an event containing start and end times, as well as a matching ID for
12+
* referencing the associated {@link Event}.
13+
*/
14+
public class SimpleEvent implements ApiResponseModel {
15+
16+
/**
17+
* Constants
18+
*/
19+
20+
public static final String MIME_TYPE = "vnd.robinpowered.simple-event.v1";
21+
22+
23+
/**
24+
* Properties
25+
*/
26+
27+
private int id;
28+
private DateTime startedAt;
29+
private DateTime endedAt;
30+
31+
32+
/**
33+
* Methods
34+
*/
35+
36+
/**
37+
* Constructs a SimpleEvent.
38+
*
39+
* @param id The id of the event.
40+
* @param startedAt When the event started.
41+
* @param endedAt When the event ended.
42+
*/
43+
public SimpleEvent(int id, DateTime startedAt, DateTime endedAt) {
44+
this.id = id;
45+
this.startedAt = startedAt;
46+
this.endedAt = endedAt;
47+
}
48+
49+
@Override
50+
public boolean equals(Object that) {
51+
if (this == that) return true;
52+
if (that == null || !(that instanceof SimpleEvent)) return false;
53+
return Objects.equal(id, ((SimpleEvent) that).id);
54+
}
55+
56+
@Override
57+
public String getMimeType() {
58+
return MIME_TYPE;
59+
}
60+
61+
public int getId() {
62+
return id;
63+
}
64+
65+
public DateTime getStartedAt() {
66+
return startedAt;
67+
}
68+
69+
public DateTime getEndedAt() {
70+
return endedAt;
71+
}
72+
}

src/main/java/com/robinpowered/sdk/service/EventService.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
import com.robinpowered.sdk.http.DELETE;
44
import com.robinpowered.sdk.model.ApiResponse;
55
import com.robinpowered.sdk.model.Event;
6+
import com.robinpowered.sdk.model.FreeBusySpace;
67
import com.robinpowered.sdk.model.User;
8+
9+
import java.io.IOException;
10+
import java.util.List;
11+
import java.util.Map;
12+
713
import retrofit.Callback;
814
import retrofit.http.Body;
915
import retrofit.http.GET;
@@ -12,10 +18,6 @@
1218
import retrofit.http.Path;
1319
import retrofit.http.QueryMap;
1420

15-
import java.io.IOException;
16-
import java.util.List;
17-
import java.util.Map;
18-
1921
public interface EventService {
2022

2123
// Sync
@@ -92,6 +94,14 @@ public interface EventService {
9294
@POST("/spaces/{spaceId}/events")
9395
void bookSpace(@Path("spaceId") int spaceId, @Body Event.Booking eventBooking, Callback<ApiResponse<Event>> callback);
9496

97+
// Sync
98+
@GET("/free-busy/spaces")
99+
ApiResponse<List<FreeBusySpace>> getFreeBusyForSpaces(@QueryMap Map<String, Object> options) throws IOException;
100+
101+
// Async
102+
@GET("/free-busy/spaces")
103+
void getFreeBusyForSpaces(@QueryMap Map<String, Object> options, Callback<ApiResponse<List<FreeBusySpace>>> callback);
104+
95105

96106
/**
97107
* For users

0 commit comments

Comments
 (0)