Skip to content

Commit ef61794

Browse files
added snake case for parameters in the params map
1 parent a4ca38f commit ef61794

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed

src/main/java/com/ibm/watson/developer_cloud/dialog/v1/DialogService.java

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import java.lang.reflect.Type;
2121
import java.text.SimpleDateFormat;
2222
import java.util.Date;
23+
import java.util.HashMap;
2324
import java.util.List;
25+
import java.util.Map;
2426
import java.util.logging.Logger;
2527

2628
import org.apache.http.HttpResponse;
@@ -61,6 +63,14 @@ public class DialogService extends WatsonService {
6163
private static final Logger log = Logger.getLogger(DialogService.class
6264
.getName());
6365

66+
public static final String DIALOG_ID = "dialog_id";
67+
68+
public static final String CLIENT_ID = "client_id";
69+
70+
public static final String CONVERSATION_ID = "conversation_id";
71+
72+
public static final String INPUT = "input";
73+
6474
/** The url. */
6575
private static String URL = "https://gateway.watsonplatform.net/dialog-experimental/api";
6676

@@ -91,23 +101,6 @@ public DialogService() {
91101
setEndPoint(URL);
92102
}
93103

94-
/**
95-
* Starts or continue conversations.
96-
*
97-
* @param dialogId
98-
* the dialog id
99-
* @param conversation
100-
* the conversation
101-
* @param input
102-
* the user input message
103-
* @return the conversation
104-
*/
105-
public Conversation converse(String dialogId, Conversation conversation,
106-
String input) {
107-
return converse(dialogId, conversation.getClientId(),
108-
conversation.getId(), input);
109-
}
110-
111104
/**
112105
* Starts or continue conversations.
113106
*
@@ -123,15 +116,17 @@ public Conversation converse(String dialogId, Conversation conversation,
123116
* the user input message
124117
* @return the conversation with the response
125118
*/
126-
public Conversation converse(final String dialogId, final Integer clientId,
127-
final Integer conversationId, final String input) {
128-
if (dialogId == null || dialogId.isEmpty())
129-
throw new IllegalArgumentException(
130-
"dialogId can not be null or empty");
131-
132-
if (conversationId == null) {
119+
public Conversation converse(Map<String, Object> params) {
120+
final String dialogId = (String) params.get("dialog_id");
121+
final String input = (String) params.get("input");
122+
final Integer clientId = (Integer) params.get("client_id");
123+
final Integer conversationId = (Integer) params.get("conversation_id");
124+
125+
if (dialogId == null)
126+
throw new IllegalArgumentException("dialog_id can not be null");
127+
128+
if (conversationId == null)
133129
log.info("Creating a new conversation with for dialog: " + dialogId);
134-
}
135130

136131
if (clientId == null) {
137132
log.info("Creating a new client id with for dialog: " + dialogId);
@@ -147,8 +142,7 @@ public Conversation converse(final String dialogId, final Integer clientId,
147142
try {
148143
HttpResponse response = execute(request);
149144
String conversationAsJson = ResponseUtil.getString(response);
150-
Conversation conversation = getGson().fromJson(conversationAsJson,
151-
Conversation.class);
145+
Conversation conversation = getGson().fromJson(conversationAsJson, Conversation.class);
152146
return conversation;
153147
} catch (IOException e) {
154148
throw new RuntimeException(e);
@@ -163,7 +157,9 @@ public Conversation converse(final String dialogId, final Integer clientId,
163157
* @return a new conversation
164158
*/
165159
public Conversation createConversation(final String dialogId) {
166-
return converse(dialogId, null, null, null);
160+
Map<String, Object> params = new HashMap<String,Object>();
161+
params.put(DIALOG_ID, dialogId);
162+
return converse(params);
167163
}
168164

169165
/**

src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsights.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ else if (params.containsKey("text") && params.containsKey("content"))
8282
request.withContent(contentJson, MediaType.APPLICATION_JSON);
8383
}
8484

85-
if (params.containsKey("includeRaw"))
86-
request.withQuery("include_raw", params.get("includeRaw"));
85+
if (params.containsKey("include_raw"))
86+
request.withQuery("include_raw", params.get("include_raw"));
8787

8888
if (params.containsKey("language"))
8989
request.withHeader("Content-Language", params.get("language"));
9090

91-
if (params.containsKey("acceptLanguage"))
92-
request.withHeader("Accept-Language", params.get("acceptLanguage"));
91+
if (params.containsKey("accept_language"))
92+
request.withHeader("Accept-Language", params.get("accept_language"));
9393

9494
HttpResponse response = execute(request.build());
9595

0 commit comments

Comments
 (0)