com.jelastic.api.users.response.CollaborationResponse Maven / Gradle / Ivy
The newest version!
/*Server class MD5: 559299a4a62d7a648f85f93d77b8b82e*/
package com.jelastic.api.users.response;
import com.jelastic.api.Response;
import com.jelastic.api.core.persistence.entity.Collaboration;
import com.jelastic.api.core.persistence.entity.CollaborationType;
import org.json.JSONException;
import org.json.JSONObject;
/**
* @name Jelastic API Client
* @version 8.11.2
* @copyright Jelastic, Inc.
*/
public class CollaborationResponse extends Response {
private static final String MEMBER_KEY = "member";
private static final String TEAM_KEY = "team";
private Collaboration collaboration;
private Boolean isOwner;
private boolean includeChildren = false;
public CollaborationResponse() {
super(Response.OK());
}
public CollaborationResponse(Collaboration collaboration, boolean isOwner) {
this();
this.collaboration = collaboration;
this.isOwner = isOwner;
}
public CollaborationResponse(Collaboration collaboration, boolean isOwner, boolean includeChildren) {
this(collaboration, isOwner);
this.includeChildren = includeChildren;
}
public Collaboration getCollaboration() {
return collaboration;
}
public void setCollaboration(Collaboration collaboration) {
this.collaboration = collaboration;
}
public CollaborationResponse(int result, String error) {
super(result, error);
}
@Override
public JSONObject _toJSON() throws JSONException {
JSONObject json = super._toJSON();
if (collaboration != null) {
if (collaboration.getType() == CollaborationType.ACCOUNT) {
json.put(MEMBER_KEY, collaboration.toJSON(isOwner, includeChildren));
} else {
json.put(TEAM_KEY, collaboration.toJSON(isOwner, includeChildren));
}
}
return json;
}
@Override
public CollaborationResponse _fromJSON(JSONObject jsonObject) throws JSONException {
super._fromJSON(jsonObject);
if (jsonObject.has(MEMBER_KEY)) {
this.setCollaboration(new Collaboration().fromJSON(jsonObject.getJSONObject(MEMBER_KEY)));
}
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy