Commit 6d13a6be by NGUYEN HOANG SON

implement agreeTerms API

parent 4ce1d42a
......@@ -15,6 +15,7 @@ import java.util.Observer;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsBooleanResultJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AgreeTermsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ApertureMasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AppLatestVersionJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ArchiveDetailJSON;
......@@ -55,6 +56,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.AbstractAcmsLoginParameter
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AddMemberGroupParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AgreeTermsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AppStoreNewLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ArchiveDetailRequestParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ArchiveRequestParameters;
......@@ -1114,12 +1116,17 @@ public class AcmsClient implements AcmsClientResponseListener {
return new TermsOfUseJson(response.httpResponseBody);
}
//terms
//agreement to terms
public RequireTermsJSON requireTerms(RequireTermsParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiUrlRequireTerms, param);
return new RequireTermsJSON(response.httpResponseBody);
}
public AgreeTermsJSON agreeTerms(AgreeTermsParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiUrlAgreeTerms, param);
return new AgreeTermsJSON(response.httpResponseBody);
}
/**********************************************************************************************/
/** 以下、共用メソッド---------------------------------------------------------------------- **/
/**********************************************************************************************/
......
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONException;
import org.json.adf.JSONObject;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
public class AgreeTermsJSON extends AcmsCommonJSON {
public AgreeTermsJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException, JSONException {
super.parse(json);
}
}
......@@ -8,6 +8,14 @@ import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
public class RequireTermsJSON extends AcmsCommonJSON {
private static final String TERMS_ID = "terms_id";
private static final String TERMS_VERSION = "terms_version";
private static final String AGREEMENT = "agreement";
public int termsId;
public String termsVersion;
public String agreement;
public RequireTermsJSON(String jsonString) throws AcmsException {
super(jsonString);
}
......@@ -15,5 +23,10 @@ public class RequireTermsJSON extends AcmsCommonJSON {
@Override
protected void parse(JSONObject json) throws JSONValidationException, JSONException {
super.parse(json);
if (json.has(TERMS_ID)) {
termsId = getInt(json, TERMS_ID);
termsVersion = getString(json, TERMS_VERSION);
agreement = getString(json, AGREEMENT);
}
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
import jp.agentec.adf.util.StringUtil;
public class AgreeTermsParameters extends HttpParameterObject {
private String sid;
private int deviceTypeId;
private String deviceId;
private int termsId;
private String termsVersion;
public AgreeTermsParameters(String sid, int deviceTypeId, String deviceId, int termsId, String termsVersion) {
if (StringUtil.isNullOrWhiteSpace(sid)) {
throw new IllegalArgumentException("argument sid not allowed null or white space.");
}
if (StringUtil.isNullOrWhiteSpace(deviceId)) {
throw new IllegalArgumentException("argument deviceId not allowed null or white space.");
}
if (StringUtil.isNullOrWhiteSpace(termsVersion)) {
throw new IllegalArgumentException("argument termsVersion not allowed null or white space.");
}
this.sid = sid;
this.deviceTypeId = deviceTypeId;
this.deviceId = deviceId;
this.termsId = termsId;
this.termsVersion = termsVersion;
}
public String getSid() {
return sid;
}
public int getDeviceTypeId() {
return deviceTypeId;
}
public String getDeviceId() {
return deviceId;
}
public int getTermsId() {
return termsId;
}
public String getTermsVersion() {
return termsVersion;
}
}
......@@ -19,4 +19,16 @@ public class RequireTermsParameters extends HttpParameterObject {
this.deviceTypeId = deviceTypeId;
this.deviceId = deviceId;
}
public String getSid() {
return sid;
}
public int getDeviceTypeId() {
return deviceTypeId;
}
public String getDeviceId() {
return deviceId;
}
}
package jp.agentec.abook.abv.bl.logic;
import java.io.IOException;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.AgreeTermsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RequireTermsJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AgreeTermsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.RequireTermsParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
public class AgreementToTermsLogic extends AbstractLogic{
private static final String TAG = "AgreementToTermsLogic";
public boolean isTermsEnabled() {
return false;
}
public RequireTermsJSON requireTerms() throws IOException, AcmsException, NetworkDisconnectedException {
String sid = cache.getMemberInfo().sid;
String deviceId = ABVEnvironment.getInstance().deviceId;
RequireTermsParameters parameters = new RequireTermsParameters(sid, ABVEnvironment.DeviceTypeId, deviceId);
RequireTermsJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).requireTerms(parameters);
return json;
}
public AgreeTermsJSON agreeTerms(int termsId, String termsVersion) throws IOException, AcmsException, NetworkDisconnectedException {
String sid = cache.getMemberInfo().sid;
String deviceId = ABVEnvironment.getInstance().deviceId;
AgreeTermsParameters parameters = new AgreeTermsParameters(sid, ABVEnvironment.DeviceTypeId, deviceId, termsId, termsVersion);
AgreeTermsJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).agreeTerms(parameters);
return json;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment