Skip to content

Commit 81642a7

Browse files
UserAccess property of Organization model is now moved into a separate extended class: UserOrganization.
1 parent 3c1e1cd commit 81642a7

File tree

4 files changed

+68
-21
lines changed

4 files changed

+68
-21
lines changed

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

Lines changed: 2 additions & 16 deletions
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
*/
@@ -16,22 +16,12 @@ public class Organization extends Account implements IdentifiableApiResponseMode
1616
public static final String MIME_TYPE = "vnd.robinpowered.organization.v1";
1717

1818

19-
/**
20-
* Properties
21-
*/
22-
23-
private UserAccess userAccess;
24-
25-
2619
/**
2720
* Methods
2821
*/
2922

30-
public Organization(int id, String slug, boolean isOrganization, DateTime createdAt, DateTime updatedAt,
31-
UserAccess userAccess) {
23+
public Organization(int id, String slug, boolean isOrganization, DateTime createdAt, DateTime updatedAt) {
3224
super(id, slug, isOrganization, createdAt, updatedAt);
33-
34-
this.userAccess = userAccess;
3525
}
3626

3727
@Override
@@ -44,10 +34,6 @@ public String toString() {
4434
return "Organization{} " + super.toString();
4535
}
4636

47-
public UserAccess getUserAccess() {
48-
return userAccess;
49-
}
50-
5137
public static final class Reference extends Account.Reference {
5238
public Reference(String slug) {
5339
super(slug);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@ public int getManagementLevel() {
1717
public Boolean getOwner() {
1818
return isOwner;
1919
}
20+
21+
@Override
22+
public String toString() {
23+
return "UserAccess{" +
24+
"managementLevel=" + managementLevel +
25+
", isOwner=" + isOwner +
26+
"}";
27+
}
2028
}
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 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+
29+
public UserOrganization(int id, String slug, boolean isOrganization, DateTime createdAt, DateTime updatedAt,
30+
UserAccess userAccess) {
31+
super(id, slug, isOrganization, createdAt, updatedAt);
32+
33+
this.userAccess = userAccess;
34+
}
35+
36+
@Override
37+
public String getMimeType() {
38+
return MIME_TYPE;
39+
}
40+
41+
@Override
42+
public String toString() {
43+
return super.toString() + " " + userAccess.toString();
44+
}
45+
46+
public UserAccess getUserAccess() {
47+
return userAccess;
48+
}
49+
}

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)