Skip to content

Commit

Permalink
Fix status check and return
Browse files Browse the repository at this point in the history
  • Loading branch information
hailiang-wang committed May 24, 2023
1 parent dcfd46c commit 712820b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.chatopera.bot</groupId>
<artifactId>sdk</artifactId>
<version>3.5.3</version>
<version>3.5.4</version>

<name>sdk</name>
<description>Java SDK for Chatopera Bot Service. Get Java API Docs at https://chatopera.github.io/chatopera-sample-java/apidocs/</description>
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/com/chatopera/bot/sdk/Chatbot.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public Response command(final String method, String path, final JSONObject paylo
}
break;
case "DELETE":
if(payload != null){
if (payload != null) {
result = RestAPI.delete(url.toString(), auth(method, fullPath.toString()), payload);
} else {
result = RestAPI.delete(url.toString(), auth(method, fullPath.toString()));
Expand Down Expand Up @@ -232,8 +232,8 @@ public Response command(final String method, String path, final JSONObject paylo
}
}

if (result.has("msg")){
if(result.isNull("msg")){
if (result.has("msg")) {
if (result.isNull("msg")) {
resp.setMsg("");
} else {
resp.setMsg(result.getString("msg"));
Expand All @@ -253,8 +253,11 @@ public Response command(final String method, String path, final JSONObject paylo
if (result.has("total_page"))
resp.setTotal_page(result.getInt("total_page"));

resp.setStatus(result.optJSONObject("status", new JSONObject()));

if (result.has("status")) {
resp.setStatus(result.optJSONObject("status", new JSONObject()));
} else {
resp.setStatus(null);
}
return resp;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/chatopera/bot/sdk/TrainMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public TrainMgr(final String clientId, final String clientSecret) throws Malform
*/
public Status getStatus() throws ChatbotException, ResourceInvalidException {
Response resp = this.chatbot.command("GET", "/clause/devver/build");
if (resp.getRc() == 0) {
if (resp.getStatus() != null && resp.getStatus().has("retrain")) {
Status status = new Status(resp.getStatus());
return status;
} else {
Expand Down

0 comments on commit 712820b

Please sign in to comment.