Skip to content

Commit 9765a9c

Browse files
committed
Merge pull request #9 from ccpmark/feature/user-access-for-organzations
User access property for Organizations
2 parents 19c1a7d + 2da877e commit 9765a9c

File tree

4 files changed

+86
-6
lines changed

4 files changed

+86
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.joda.time.DateTime;
44

55
/**
6-
* A company or team. Made up of users, locations and spaces.'
6+
* A company or team. Made up of users, locations and spaces.
77
*
88
* @todo should isOrganization be exposed in this model?
99
*/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.robinpowered.sdk.model;
2+
3+
public class UserAccess {
4+
5+
private Integer managementLevel;
6+
private Boolean isOwner;
7+
8+
public UserAccess(Integer managementLevel, Boolean isOwner) {
9+
this.managementLevel = managementLevel;
10+
this.isOwner = isOwner;
11+
}
12+
13+
public int getManagementLevel() {
14+
return managementLevel;
15+
}
16+
17+
public Boolean getOwner() {
18+
return isOwner;
19+
}
20+
21+
@Override
22+
public String toString() {
23+
return "UserAccess{" +
24+
"managementLevel=" + managementLevel +
25+
", isOwner=" + isOwner +
26+
"}";
27+
}
28+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.robinpowered.sdk.model;
2+
3+
import org.joda.time.DateTime;
4+
5+
/**
6+
* An {@link Organization} containing {@link UserAccess} data.
7+
*/
8+
public class UserOrganization extends Organization {
9+
10+
/**
11+
* Constants
12+
*/
13+
14+
public static final String MIME_TYPE = "vnd.robinpowered.user-organization.v1";
15+
16+
17+
/**
18+
* Properties
19+
*/
20+
21+
private UserAccess userAccess;
22+
23+
24+
/**
25+
* Methods
26+
*/
27+
28+
public UserOrganization(int id, String slug, boolean isOrganization, DateTime createdAt, DateTime updatedAt,
29+
UserAccess userAccess) {
30+
super(id, slug, isOrganization, createdAt, updatedAt);
31+
32+
this.userAccess = userAccess;
33+
}
34+
35+
@Override
36+
public String getMimeType() {
37+
return MIME_TYPE;
38+
}
39+
40+
@Override
41+
public String toString() {
42+
return super.toString() + " " + userAccess.toString();
43+
}
44+
45+
public UserAccess getUserAccess() {
46+
return userAccess;
47+
}
48+
}

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

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

3-
import com.robinpowered.sdk.model.Amenity;
4-
import com.robinpowered.sdk.model.ApiResponse;
5-
import com.robinpowered.sdk.model.Organization;
6-
import com.robinpowered.sdk.model.Presence;
7-
import com.robinpowered.sdk.model.User;
3+
import com.robinpowered.sdk.model.*;
84
import retrofit.Callback;
95
import retrofit.http.GET;
106
import retrofit.http.Path;
@@ -58,6 +54,14 @@ public interface AccountService {
5854
@GET("/me/organizations")
5955
void getMyOrganizations(@QueryMap Map<String, Object> options, Callback<ApiResponse<List<Organization>>> callback);
6056

57+
// Sync
58+
@GET("/me/organizations")
59+
ApiResponse<List<UserOrganization>> getMyUserOrganizations(@QueryMap Map<String, Object> options) throws IOException;
60+
61+
// Async
62+
@GET("/me/organizations")
63+
void getMyUserOrganizations(@QueryMap Map<String, Object> options, Callback<ApiResponse<List<UserOrganization>>> callback);
64+
6165

6266
/**
6367
* Organizations

0 commit comments

Comments
 (0)