Skip to content

Commit 743af28

Browse files
committed
feat(Tone Analyzer): Add generated code from newest version of service
1 parent 5e94308 commit 743af28

File tree

5 files changed

+58
-48
lines changed

5 files changed

+58
-48
lines changed

tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzer.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
import com.ibm.cloud.sdk.core.util.GsonSingleton;
2121
import com.ibm.cloud.sdk.core.util.RequestUtils;
2222
import com.ibm.cloud.sdk.core.util.ResponseConverterUtils;
23+
import com.ibm.cloud.sdk.core.util.Validator;
24+
import com.ibm.watson.common.SdkCommon;
2325
import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis;
2426
import com.ibm.watson.tone_analyzer.v3.model.ToneChatOptions;
2527
import com.ibm.watson.tone_analyzer.v3.model.ToneOptions;
2628
import com.ibm.watson.tone_analyzer.v3.model.UtteranceAnalyses;
27-
import com.ibm.cloud.sdk.core.util.Validator;
29+
import java.util.Map;
30+
import java.util.Map.Entry;
2831

2932
/**
3033
* The IBM Watson™ Tone Analyzer service uses linguistic analysis to detect emotional and language tones in
@@ -120,16 +123,20 @@ public ServiceCall<ToneAnalysis> tone(ToneOptions toneOptions) {
120123
String[] pathSegments = { "v3/tone" };
121124
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
122125
builder.query("version", versionDate);
123-
builder.header("X-IBMCloud-SDK-Analytics", "service_name=tone_analyzer;service_version=v3;operation_id=tone");
124-
if (toneOptions.contentType() != null) {
125-
builder.header("Content-Type", toneOptions.contentType());
126+
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("tone_analyzer", "v3", "tone");
127+
for (Entry<String, String> header : sdkHeaders.entrySet()) {
128+
builder.header(header.getKey(), header.getValue());
126129
}
130+
builder.header("Accept", "application/json");
127131
if (toneOptions.contentLanguage() != null) {
128132
builder.header("Content-Language", toneOptions.contentLanguage());
129133
}
130134
if (toneOptions.acceptLanguage() != null) {
131135
builder.header("Accept-Language", toneOptions.acceptLanguage());
132136
}
137+
if (toneOptions.contentType() != null) {
138+
builder.header("Content-Type", toneOptions.contentType());
139+
}
133140
if (toneOptions.sentences() != null) {
134141
builder.query("sentences", String.valueOf(toneOptions.sentences()));
135142
}
@@ -154,8 +161,7 @@ public ServiceCall<ToneAnalysis> tone(ToneOptions toneOptions) {
154161
* UTF-8.
155162
*
156163
* **See also:** [Using the customer-engagement
157-
* endpoint](https://cloud.ibm.com/docs/services/tone-analyzer/using-tone-chat
158-
* .html#using-the-customer-engagement-endpoint).
164+
* endpoint](https://cloud.ibm.com/docs/services/tone-analyzer/using-tone-chat.html#using-the-customer-engagement-endpoint).
159165
*
160166
* @param toneChatOptions the {@link ToneChatOptions} containing the options for the call
161167
* @return a {@link ServiceCall} with a response type of {@link UtteranceAnalyses}
@@ -165,7 +171,11 @@ public ServiceCall<UtteranceAnalyses> toneChat(ToneChatOptions toneChatOptions)
165171
String[] pathSegments = { "v3/tone_chat" };
166172
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
167173
builder.query("version", versionDate);
168-
builder.header("X-IBMCloud-SDK-Analytics", "service_name=tone_analyzer;service_version=v3;operation_id=toneChat");
174+
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("tone_analyzer", "v3", "toneChat");
175+
for (Entry<String, String> header : sdkHeaders.entrySet()) {
176+
builder.header(header.getKey(), header.getValue());
177+
}
178+
builder.header("Accept", "application/json");
169179
if (toneChatOptions.contentLanguage() != null) {
170180
builder.header("Content-Language", toneChatOptions.contentLanguage());
171181
}

tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public static class Builder {
8181
private String acceptLanguage;
8282

8383
private Builder(ToneChatOptions toneChatOptions) {
84-
utterances = toneChatOptions.utterances;
85-
contentLanguage = toneChatOptions.contentLanguage;
86-
acceptLanguage = toneChatOptions.acceptLanguage;
84+
this.utterances = toneChatOptions.utterances;
85+
this.contentLanguage = toneChatOptions.contentLanguage;
86+
this.acceptLanguage = toneChatOptions.acceptLanguage;
8787
}
8888

8989
/**

tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static class Builder {
2929
private String text;
3030

3131
private Builder(ToneInput toneInput) {
32-
text = toneInput.text;
32+
this.text = toneInput.text;
3333
}
3434

3535
/**

tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptions.java

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@
2323
*/
2424
public class ToneOptions extends GenericModel {
2525

26-
/**
27-
* The type of the input. A character encoding can be specified by including a `charset` parameter. For example,
28-
* 'text/plain;charset=utf-8'.
29-
*/
30-
public interface ContentType {
31-
/** application/json. */
32-
String APPLICATION_JSON = "application/json";
33-
/** text/plain. */
34-
String TEXT_PLAIN = "text/plain";
35-
/** text/html. */
36-
String TEXT_HTML = "text/html";
37-
}
38-
3926
public interface Tone {
4027
/** emotion. */
4128
String EMOTION = "emotion";
@@ -90,34 +77,47 @@ public interface AcceptLanguage {
9077
String ZH_TW = "zh-tw";
9178
}
9279

80+
/**
81+
* The type of the input. A character encoding can be specified by including a `charset` parameter. For example,
82+
* 'text/plain;charset=utf-8'.
83+
*/
84+
public interface ContentType {
85+
/** application/json. */
86+
String APPLICATION_JSON = "application/json";
87+
/** text/plain. */
88+
String TEXT_PLAIN = "text/plain";
89+
/** text/html. */
90+
String TEXT_HTML = "text/html";
91+
}
92+
9393
private ToneInput toneInput;
9494
private String body;
95-
private String contentType;
9695
private Boolean sentences;
9796
private List<String> tones;
9897
private String contentLanguage;
9998
private String acceptLanguage;
99+
private String contentType;
100100

101101
/**
102102
* Builder.
103103
*/
104104
public static class Builder {
105105
private ToneInput toneInput;
106106
private String body;
107-
private String contentType;
108107
private Boolean sentences;
109108
private List<String> tones;
110109
private String contentLanguage;
111110
private String acceptLanguage;
111+
private String contentType;
112112

113113
private Builder(ToneOptions toneOptions) {
114-
toneInput = toneOptions.toneInput;
115-
body = toneOptions.body;
116-
contentType = toneOptions.contentType;
117-
sentences = toneOptions.sentences;
118-
tones = toneOptions.tones;
119-
contentLanguage = toneOptions.contentLanguage;
120-
acceptLanguage = toneOptions.acceptLanguage;
114+
this.toneInput = toneOptions.toneInput;
115+
this.body = toneOptions.body;
116+
this.sentences = toneOptions.sentences;
117+
this.tones = toneOptions.tones;
118+
this.contentLanguage = toneOptions.contentLanguage;
119+
this.acceptLanguage = toneOptions.acceptLanguage;
120+
this.contentType = toneOptions.contentType;
121121
}
122122

123123
/**
@@ -235,11 +235,11 @@ public Builder html(String html) {
235235
private ToneOptions(Builder builder) {
236236
toneInput = builder.toneInput;
237237
body = builder.body;
238-
contentType = builder.contentType;
239238
sentences = builder.sentences;
240239
tones = builder.tones;
241240
contentLanguage = builder.contentLanguage;
242241
acceptLanguage = builder.acceptLanguage;
242+
contentType = builder.contentType;
243243
}
244244

245245
/**
@@ -275,18 +275,6 @@ public String body() {
275275
return body;
276276
}
277277

278-
/**
279-
* Gets the contentType.
280-
*
281-
* The type of the input. A character encoding can be specified by including a `charset` parameter. For example,
282-
* 'text/plain;charset=utf-8'.
283-
*
284-
* @return the contentType
285-
*/
286-
public String contentType() {
287-
return contentType;
288-
}
289-
290278
/**
291279
* Gets the sentences.
292280
*
@@ -343,4 +331,16 @@ public String contentLanguage() {
343331
public String acceptLanguage() {
344332
return acceptLanguage;
345333
}
334+
335+
/**
336+
* Gets the contentType.
337+
*
338+
* The type of the input. A character encoding can be specified by including a `charset` parameter. For example,
339+
* 'text/plain;charset=utf-8'.
340+
*
341+
* @return the contentType
342+
*/
343+
public String contentType() {
344+
return contentType;
345+
}
346346
}

tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/Utterance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public static class Builder {
3131
private String user;
3232

3333
private Builder(Utterance utterance) {
34-
text = utterance.text;
35-
user = utterance.user;
34+
this.text = utterance.text;
35+
this.user = utterance.user;
3636
}
3737

3838
/**

0 commit comments

Comments
 (0)