Skip to content

Commit 0078241

Browse files
committed
Adding state model to space
1 parent d8ca115 commit 0078241

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

src/main/java/com/robinpowered/sdk/model/Space.java

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class Space implements IdentifiableApiResponseModel {
4242
private Boolean isDisabled;
4343

4444
// Submodels
45+
private State state;
4546
private Location location;
4647
private Calendar calendar;
4748
private List<Amenity> amenities;
@@ -131,6 +132,14 @@ public DateTime getCreatedAt() {
131132
return createdAt;
132133
}
133134

135+
public State getState() {
136+
return state;
137+
}
138+
139+
public void setState(State state) {
140+
this.state = state;
141+
}
142+
134143
public Location getLocation() {
135144
return location;
136145
}
@@ -162,14 +171,13 @@ public boolean equals(Object o) {
162171
Space space = (Space) o;
163172
return Objects.equal(id, space.id) &&
164173
Objects.equal(locationId, space.locationId) &&
165-
Objects.equal(isDibsed, space.isDibsed) &&
166174
Objects.equal(createdAt, space.createdAt) &&
167175
Objects.equal(updatedAt, space.updatedAt);
168176
}
169177

170178
@Override
171179
public int hashCode() {
172-
return Objects.hashCode(id, locationId, isDibsed, createdAt, updatedAt);
180+
return Objects.hashCode(id, locationId, createdAt, updatedAt);
173181
}
174182

175183
@Override
@@ -196,4 +204,69 @@ public String toString() {
196204
public String getMimeType() {
197205
return MIME_TYPE;
198206
}
207+
208+
/**
209+
* Represents the current state of the space, containing information about availability and whether there is
210+
* presence.
211+
*/
212+
public static class State implements ApiResponseModel {
213+
214+
public static final String MIME_TYPE = "vnd.robinpowered.space.state.v1";
215+
216+
public static final String AVAILABLE = "available";
217+
public static final String BOOKED = "booked";
218+
public static final String IN_USE = "in_use";
219+
public static final String DISABLED = "disabled";
220+
221+
private final String availability;
222+
private final int present;
223+
private final DateTime nextBusyChange;
224+
225+
public State(String availability, int present, DateTime nextBusyChange) {
226+
this.availability = availability;
227+
this.present = present;
228+
this.nextBusyChange = nextBusyChange;
229+
}
230+
231+
public String getAvailability() {
232+
return availability;
233+
}
234+
235+
public int getPresent() {
236+
return present;
237+
}
238+
239+
public DateTime getNextBusyChange() {
240+
return nextBusyChange;
241+
}
242+
243+
@Override
244+
public String getMimeType() {
245+
return MIME_TYPE;
246+
}
247+
248+
@Override
249+
public boolean equals(Object o) {
250+
if (this == o) return true;
251+
if (o == null || getClass() != o.getClass()) return false;
252+
State state = (State) o;
253+
return Objects.equal(present, state.present) &&
254+
Objects.equal(availability, state.availability) &&
255+
Objects.equal(nextBusyChange, state.nextBusyChange);
256+
}
257+
258+
@Override
259+
public int hashCode() {
260+
return Objects.hashCode(availability, present, nextBusyChange);
261+
}
262+
263+
@Override
264+
public String toString() {
265+
return "State{" +
266+
"availability=" + availability +
267+
", present=" + present +
268+
", nextBusyChange=" + nextBusyChange +
269+
'}';
270+
}
271+
}
199272
}

src/test/java/com/robinpowered/sdk/model/SpaceTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@ public void testEqualsAndHashcode() {
1111
.usingGetClass()
1212
.verify();
1313
}
14+
15+
@Test
16+
public void testEqualsAndHashcodeForState() {
17+
EqualsVerifier.forClass(Space.State.class)
18+
.usingGetClass()
19+
.verify();
20+
}
1421
}

0 commit comments

Comments
 (0)