Skip to content

Commit e5f2222

Browse files
author
Chris Mark
committed
Merge pull request #7 from brianmuse/feature/space-amenities
Feature: Getting amenities
2 parents 49f7312 + cb077ff commit e5f2222

5 files changed

Lines changed: 135 additions & 1 deletion

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package com.robinpowered.sdk.model;
2+
3+
import com.google.common.base.Objects;
4+
import org.joda.time.DateTime;
5+
6+
/**
7+
* An amenity that may be associated with a {@link Space}.
8+
*
9+
* <p>
10+
* Amenities may be created or removed within an organization, though a default set of amenities is always present.
11+
* Each amenity may then be associated or disassociated from any spaces within that organization.
12+
*/
13+
public class Amenity implements ApiResponseModel {
14+
15+
/**
16+
* Constants
17+
*/
18+
19+
public static final String MIME_TYPE = "vnd.robinpowered.amenity.v1";
20+
21+
22+
/**
23+
* Properties
24+
*/
25+
26+
// Immutable
27+
private final int id;
28+
private final Integer accountId;
29+
private final DateTime createdAt;
30+
private final DateTime updatedAt;
31+
32+
// Mutable
33+
private String name;
34+
35+
36+
/**
37+
* Methods
38+
*/
39+
40+
public Amenity(int id, Integer accountId, DateTime createdAt, DateTime updatedAt) {
41+
this.id = id;
42+
this.accountId = accountId;
43+
this.createdAt = createdAt;
44+
this.updatedAt = updatedAt;
45+
}
46+
47+
public int getId() {
48+
return id;
49+
}
50+
51+
public Integer getAccountId() {
52+
return accountId;
53+
}
54+
55+
public DateTime getCreatedAt() {
56+
return createdAt;
57+
}
58+
59+
public DateTime getUpdatedAt() {
60+
return updatedAt;
61+
}
62+
63+
public String getName() {
64+
return name;
65+
}
66+
67+
public void setName(String name) {
68+
this.name = name;
69+
}
70+
71+
@Override
72+
public boolean equals(Object o) {
73+
if (this == o) return true;
74+
if (o == null || getClass() != o.getClass()) return false;
75+
Amenity amenity = (Amenity) o;
76+
return Objects.equal(id, amenity.id) &&
77+
Objects.equal(accountId, amenity.accountId) &&
78+
Objects.equal(createdAt, amenity.createdAt) &&
79+
Objects.equal(updatedAt, amenity.updatedAt);
80+
}
81+
82+
@Override
83+
public int hashCode() {
84+
return Objects.hashCode(id, accountId, createdAt, updatedAt);
85+
}
86+
87+
@Override
88+
public String toString() {
89+
return "Amenity{" +
90+
"id=" + id +
91+
", accountId=" + accountId +
92+
", createdAt=" + createdAt +
93+
", updatedAt=" + updatedAt +
94+
", name='" + name + '\'' +
95+
'}';
96+
}
97+
98+
@Override
99+
public String getMimeType() {
100+
return MIME_TYPE;
101+
}
102+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* automatically be synced to the space.
1313
*
1414
* <p>
15-
* Spaces without calendars are considered "breakout" spaces are not able to be reserved.
15+
* Spaces without calendars are considered "on-demand" spaces are not able to be reserved.
1616
*/
1717
public class Calendar implements ApiResponseModel {
1818

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.robinpowered.sdk.service;
22

3+
import com.robinpowered.sdk.model.Amenity;
34
import com.robinpowered.sdk.model.ApiResponse;
45
import com.robinpowered.sdk.model.Organization;
56
import com.robinpowered.sdk.model.Presence;
@@ -77,4 +78,12 @@ public interface AccountService {
7778
// Async
7879
@GET("/organizations/{id}/users")
7980
void getOrganizationUsers(@Path("id") Organization.Reference id, @QueryMap Map<String, Object> options, Callback<ApiResponse<List<User>>> callback);
81+
82+
// Sync
83+
@GET("/organizations/{id}/amenities")
84+
ApiResponse<List<Amenity>> getAmenities(@Path("id") Organization.Reference id, @QueryMap Map<String, Object> options) throws IOException;
85+
86+
// Async
87+
@GET("/organizations/{id}/amenities")
88+
void getAmenities(@Path("id") Organization.Reference id, @QueryMap Map<String, Object> options, Callback<ApiResponse<List<Amenity>>> callback);
8089
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.robinpowered.sdk.service;
22

33
import com.robinpowered.sdk.http.DELETE;
4+
import com.robinpowered.sdk.model.Amenity;
45
import com.robinpowered.sdk.model.ApiResponse;
56
import com.robinpowered.sdk.model.Calendar;
67
import com.robinpowered.sdk.model.Dibs;
@@ -118,6 +119,14 @@ public interface PlacesService {
118119
@DELETE("/spaces/{id}/presence")
119120
void deletePresence(@Path("id") int id, @Body Presence.Occurrence presenceOccurrence, Callback<ApiResponse<Void>> callback);
120121

122+
// Sync
123+
@GET("/spaces/{id}/amenities")
124+
ApiResponse<List<Amenity>> getAmenities(@Path("id") int id, @QueryMap Map<String, Object> options) throws IOException;
125+
126+
// Async
127+
@GET("/spaces/{id}/amenities")
128+
void getAmenities(@Path("id") int id, @QueryMap Map<String, Object> options, Callback<ApiResponse<List<Amenity>>> callback);
129+
121130

122131
/**
123132
* Dibs
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.robinpowered.sdk.model;
2+
3+
import nl.jqno.equalsverifier.EqualsVerifier;
4+
import org.junit.Test;
5+
6+
public class AmenityTest {
7+
8+
@Test
9+
public void testEqualsAndHashcode() {
10+
EqualsVerifier.forClass(Amenity.class)
11+
.usingGetClass()
12+
.verify();
13+
}
14+
}

0 commit comments

Comments
 (0)