Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: updated client endpoints to support 0.0.4 and 0.0.5 version of browser extension #4883

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public class ClientIntegrationAPI extends ApiImplementor {
private static final String ACTION_REPORT_OBJECT = "reportObject";
private static final String ACTION_REPORT_EVENT = "reportEvent";
private static final String ACTION_REPORT_ZEST_STATEMENT = "reportZestStatement";
private static final String ACTION_REPORT_ZEST_SCRIPT = "reportZestScript";

private static final String PARAM_OBJECT_JSON = "objectJson";
private static final String PARAM_EVENT_JSON = "eventJson";
private static final String PARAM_STATEMENT_JSON = "statementJson";
private static final String PARAM_SCRIPT_JSON = "scriptJson";

private static final Logger LOGGER = LogManager.getLogger(ClientIntegrationAPI.class);

Expand All @@ -59,6 +61,8 @@ public ClientIntegrationAPI(ExtensionClientIntegration extension) {
this.addApiAction(new ApiAction(ACTION_REPORT_EVENT, new String[] {PARAM_EVENT_JSON}));
this.addApiAction(
new ApiAction(ACTION_REPORT_ZEST_STATEMENT, new String[] {PARAM_STATEMENT_JSON}));
this.addApiAction(
new ApiAction(ACTION_REPORT_ZEST_SCRIPT, new String[] {PARAM_SCRIPT_JSON}));

callbackUrl =
API.getInstance().getCallBackUrl(this, HttpHeader.SCHEME_HTTPS + API.API_DOMAIN);
Expand Down Expand Up @@ -132,7 +136,16 @@ public ApiResponse handleApiAction(String name, JSONObject params) throws ApiExc
break;

case ACTION_REPORT_ZEST_STATEMENT:
String scriptJson = this.getParam(params, PARAM_STATEMENT_JSON, "");
String statementJson = this.getParam(params, PARAM_STATEMENT_JSON, "");
LOGGER.debug("Got script: {}", statementJson);
try {
this.extension.addZestStatement(statementJson);
} catch (Exception e) {
LOGGER.debug(e);
}
break;
case ACTION_REPORT_ZEST_SCRIPT:
String scriptJson = this.getParam(params, PARAM_SCRIPT_JSON, "");
LOGGER.debug("Got script: {}", scriptJson);
try {
this.extension.addZestStatement(scriptJson);
Expand Down Expand Up @@ -181,6 +194,12 @@ public String handleCallBack(HttpMessage msg) throws ApiException {
} catch (Exception e) {
LOGGER.debug(e);
}
} else if (body.startsWith(PARAM_SCRIPT_JSON)) {
try {
this.extension.addZestStatement(decodeParamString(body, PARAM_SCRIPT_JSON));
} catch (Exception e) {
LOGGER.debug(e);
}
}

} else {
Expand Down