1717import com .ibm .cloud .sdk .core .http .ResponseConverter ;
1818import com .ibm .cloud .sdk .core .http .ServiceCall ;
1919import com .ibm .cloud .sdk .core .security .Authenticator ;
20+ import com .ibm .cloud .sdk .core .security .ConfigBasedAuthenticatorFactory ;
2021import com .ibm .cloud .sdk .core .service .BaseService ;
2122import com .ibm .cloud .sdk .core .util .RequestUtils ;
2223import com .ibm .cloud .sdk .core .util .ResponseConverterUtils ;
4445public class ToneAnalyzer extends BaseService {
4546
4647 private static final String SERVICE_NAME = "tone_analyzer" ;
47- private static final String URL = "https://gateway.watsonplatform.net/tone-analyzer/api" ;
48+ private static final String SERVICE_URL = "https://gateway.watsonplatform.net/tone-analyzer/api" ;
4849
4950 private String versionDate ;
5051
52+ /**
53+ * Constructs a new `ToneAnalyzer` client.
54+ *
55+ * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API
56+ * calls from failing when the service introduces breaking changes.
57+ */
58+ public ToneAnalyzer (String versionDate ) {
59+ this (versionDate , ConfigBasedAuthenticatorFactory .getAuthenticator (SERVICE_NAME ));
60+ }
61+
5162 /**
5263 * Constructs a new `ToneAnalyzer` client with the specified Authenticator.
5364 *
@@ -57,8 +68,8 @@ public class ToneAnalyzer extends BaseService {
5768 */
5869 public ToneAnalyzer (String versionDate , Authenticator authenticator ) {
5970 super (SERVICE_NAME , authenticator );
60- if ((getEndPoint () == null ) || getEndPoint ().isEmpty ()) {
61- setEndPoint ( URL );
71+ if ((getServiceUrl () == null ) || getServiceUrl ().isEmpty ()) {
72+ setServiceUrl ( SERVICE_URL );
6273 }
6374 com .ibm .cloud .sdk .core .util .Validator .isTrue ((versionDate != null ) && !versionDate .isEmpty (),
6475 "version cannot be null." );
@@ -92,7 +103,7 @@ public ServiceCall<ToneAnalysis> tone(ToneOptions toneOptions) {
92103 com .ibm .cloud .sdk .core .util .Validator .notNull (toneOptions ,
93104 "toneOptions cannot be null" );
94105 String [] pathSegments = { "v3/tone" };
95- RequestBuilder builder = RequestBuilder .post (RequestBuilder .constructHttpUrl (getEndPoint (), pathSegments ));
106+ RequestBuilder builder = RequestBuilder .post (RequestBuilder .constructHttpUrl (getServiceUrl (), pathSegments ));
96107 builder .query ("version" , versionDate );
97108 Map <String , String > sdkHeaders = SdkCommon .getSdkHeaders ("tone_analyzer" , "v3" , "tone" );
98109 for (Entry <String , String > header : sdkHeaders .entrySet ()) {
@@ -145,7 +156,7 @@ public ServiceCall<UtteranceAnalyses> toneChat(ToneChatOptions toneChatOptions)
145156 com .ibm .cloud .sdk .core .util .Validator .notNull (toneChatOptions ,
146157 "toneChatOptions cannot be null" );
147158 String [] pathSegments = { "v3/tone_chat" };
148- RequestBuilder builder = RequestBuilder .post (RequestBuilder .constructHttpUrl (getEndPoint (), pathSegments ));
159+ RequestBuilder builder = RequestBuilder .post (RequestBuilder .constructHttpUrl (getServiceUrl (), pathSegments ));
149160 builder .query ("version" , versionDate );
150161 Map <String , String > sdkHeaders = SdkCommon .getSdkHeaders ("tone_analyzer" , "v3" , "toneChat" );
151162 for (Entry <String , String > header : sdkHeaders .entrySet ()) {
0 commit comments