Skip to content

Commit 7f9f79f

Browse files
committed
refactor(All services): Only use constructor with no args to load credentials
1 parent b727c0b commit 7f9f79f

File tree

24 files changed

+86
-140
lines changed

24 files changed

+86
-140
lines changed

src/IBM.WatsonDeveloperCloud.Assistant.v1/AssistantService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ public string VersionDate
3535
{
3636
get { return _versionDate; }
3737
set { _versionDate = value; }
38-
}
39-
40-
public AssistantService() : base(SERVICE_NAME) { }
38+
}
39+
40+
public AssistantService() : base(SERVICE_NAME) { }
4141

42-
public AssistantService(string userName, string password, string versionDate) : this()
42+
public AssistantService(string userName, string password, string versionDate) : base(SERVICE_NAME, URL)
4343
{
4444
if (string.IsNullOrEmpty(userName))
4545
throw new ArgumentNullException(nameof(userName));
@@ -54,7 +54,7 @@ public AssistantService(string userName, string password, string versionDate) :
5454
VersionDate = versionDate;
5555
}
5656

57-
public AssistantService(TokenOptions options, string versionDate) : this()
57+
public AssistantService(TokenOptions options, string versionDate) : base(SERVICE_NAME, URL)
5858
{
5959
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
6060
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -75,7 +75,7 @@ public AssistantService(TokenOptions options, string versionDate) : this()
7575
_tokenManager = new TokenManager(options);
7676
}
7777

78-
public AssistantService(IClient httpClient) : this()
78+
public AssistantService(IClient httpClient) : base(SERVICE_NAME, URL)
7979
{
8080
if (httpClient == null)
8181
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.Assistant.v2/AssistantService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public string VersionDate
3333
{
3434
get { return _versionDate; }
3535
set { _versionDate = value; }
36-
}
37-
36+
}
37+
3838
public AssistantService() : base(SERVICE_NAME) { }
3939

40-
public AssistantService(string userName, string password, string versionDate) : this()
40+
public AssistantService(string userName, string password, string versionDate) : base(SERVICE_NAME, URL)
4141
{
4242
if (string.IsNullOrEmpty(userName))
4343
throw new ArgumentNullException(nameof(userName));
@@ -52,7 +52,7 @@ public AssistantService(string userName, string password, string versionDate) :
5252
VersionDate = versionDate;
5353
}
5454

55-
public AssistantService(TokenOptions options, string versionDate) : this()
55+
public AssistantService(TokenOptions options, string versionDate) : base(SERVICE_NAME, URL)
5656
{
5757
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
5858
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -73,7 +73,7 @@ public AssistantService(TokenOptions options, string versionDate) : this()
7373
_tokenManager = new TokenManager(options);
7474
}
7575

76-
public AssistantService(IClient httpClient) : this()
76+
public AssistantService(IClient httpClient) : base(SERVICE_NAME, URL)
7777
{
7878
if (httpClient == null)
7979
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.CompareComply.v1/CompareComplyService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public string VersionDate
3737
{
3838
get { return _versionDate; }
3939
set { _versionDate = value; }
40-
}
41-
42-
public CompareComplyService() : base(SERVICE_NAME) { }
40+
}
41+
42+
public CompareComplyService() : base(SERVICE_NAME) { }
4343

44-
public CompareComplyService(TokenOptions options, string versionDate) : this()
44+
public CompareComplyService(TokenOptions options, string versionDate) : base(SERVICE_NAME, URL)
4545
{
4646
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
4747
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -62,7 +62,7 @@ public CompareComplyService(TokenOptions options, string versionDate) : this()
6262
_tokenManager = new TokenManager(options);
6363
}
6464

65-
public CompareComplyService(IClient httpClient) : this()
65+
public CompareComplyService(IClient httpClient) : base(SERVICE_NAME, URL)
6666
{
6767
if (httpClient == null)
6868
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.Conversation.v1/ConversationService.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@ public string VersionDate
3636
}
3737

3838
[Obsolete("Conversation V1 is deprecated and will be removed in the next major release of the SDK. Use Assistant V1 or Assistant V2.")]
39-
public ConversationService() : base(SERVICE_NAME, URL)
40-
{
41-
if(!string.IsNullOrEmpty(this.Endpoint))
42-
this.Endpoint = URL;
43-
}
39+
public ConversationService() : base(SERVICE_NAME) { }
4440

4541
[Obsolete("Conversation V1 is deprecated and will be removed in the next major release of the SDK. Use Assistant V1 or Assistant V2.")]
46-
public ConversationService(string userName, string password, string versionDate) : this()
42+
public ConversationService(string userName, string password, string versionDate) : base(SERVICE_NAME, URL)
4743
{
4844
if (string.IsNullOrEmpty(userName))
4945
throw new ArgumentNullException(nameof(userName));
@@ -59,7 +55,7 @@ public ConversationService(string userName, string password, string versionDate)
5955
}
6056

6157
[Obsolete("Conversation V1 is deprecated and will be removed in the next major release of the SDK. Use Assistant V1 or Assistant V2.")]
62-
public ConversationService(TokenOptions options, string versionDate) : this()
58+
public ConversationService(TokenOptions options, string versionDate) : base(SERVICE_NAME, URL)
6359
{
6460
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
6561
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -81,7 +77,7 @@ public ConversationService(TokenOptions options, string versionDate) : this()
8177
}
8278

8379
[Obsolete("Conversation V1 is deprecated and will be removed in the next major release of the SDK. Use Assistant V1 or Assistant V2.")]
84-
public ConversationService(IClient httpClient) : this()
80+
public ConversationService(IClient httpClient) : base(SERVICE_NAME, URL)
8581
{
8682
if (httpClient == null)
8783
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.Discovery.v1/DiscoveryService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public string VersionDate
4242

4343
public DiscoveryService() : base(SERVICE_NAME) { }
4444

45-
public DiscoveryService(string userName, string password, string versionDate) : this()
45+
public DiscoveryService(string userName, string password, string versionDate) : base(SERVICE_NAME, URL)
4646
{
4747
if (string.IsNullOrEmpty(userName))
4848
throw new ArgumentNullException(nameof(userName));
@@ -57,7 +57,7 @@ public DiscoveryService(string userName, string password, string versionDate) :
5757
VersionDate = versionDate;
5858
}
5959

60-
public DiscoveryService(TokenOptions options, string versionDate) : this()
60+
public DiscoveryService(TokenOptions options, string versionDate) : base(SERVICE_NAME, URL)
6161
{
6262
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
6363
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -78,7 +78,7 @@ public DiscoveryService(TokenOptions options, string versionDate) : this()
7878
_tokenManager = new TokenManager(options);
7979
}
8080

81-
public DiscoveryService(IClient httpClient) : this()
81+
public DiscoveryService(IClient httpClient) : base(SERVICE_NAME, URL)
8282
{
8383
if (httpClient == null)
8484
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/LanguageTranslatorService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public string VersionDate
4141

4242
public LanguageTranslatorService() : base(SERVICE_NAME) { }
4343

44-
public LanguageTranslatorService(string userName, string password, string versionDate) : this()
44+
public LanguageTranslatorService(string userName, string password, string versionDate) : base(SERVICE_NAME, URL)
4545
{
4646
if (string.IsNullOrEmpty(userName))
4747
throw new ArgumentNullException(nameof(userName));
@@ -56,7 +56,7 @@ public LanguageTranslatorService(string userName, string password, string versio
5656
VersionDate = versionDate;
5757
}
5858

59-
public LanguageTranslatorService(TokenOptions options, string versionDate) : this()
59+
public LanguageTranslatorService(TokenOptions options, string versionDate) : base(SERVICE_NAME, URL)
6060
{
6161
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
6262
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -77,7 +77,7 @@ public LanguageTranslatorService(TokenOptions options, string versionDate) : thi
7777
_tokenManager = new TokenManager(options);
7878
}
7979

80-
public LanguageTranslatorService(IClient httpClient) : this()
80+
public LanguageTranslatorService(IClient httpClient) : base(SERVICE_NAME, URL)
8181
{
8282
if (httpClient == null)
8383
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/NaturalLanguageClassifierService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ namespace IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1
3030
public partial class NaturalLanguageClassifierService : WatsonService, INaturalLanguageClassifierService
3131
{
3232
const string SERVICE_NAME = "natural_language_classifier";
33-
const string URL = "https://gateway.watsonplatform.net/natural-language-classifier/api";
33+
const string URL = "https://gateway.watsonplatform.net/natural-language-classifier/api";
34+
3435
public NaturalLanguageClassifierService() : base(SERVICE_NAME) { }
3536

36-
public NaturalLanguageClassifierService(string userName, string password) : this()
37+
public NaturalLanguageClassifierService(string userName, string password) : base(SERVICE_NAME, URL)
3738
{
3839
if (string.IsNullOrEmpty(userName))
3940
throw new ArgumentNullException(nameof(userName));
@@ -44,7 +45,7 @@ public NaturalLanguageClassifierService(string userName, string password) : this
4445
this.SetCredential(userName, password);
4546
}
4647

47-
public NaturalLanguageClassifierService(TokenOptions options) : this()
48+
public NaturalLanguageClassifierService(TokenOptions options) : base(SERVICE_NAME, URL)
4849
{
4950
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
5051
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -60,7 +61,7 @@ public NaturalLanguageClassifierService(TokenOptions options) : this()
6061
_tokenManager = new TokenManager(options);
6162
}
6263

63-
public NaturalLanguageClassifierService(IClient httpClient) : this()
64+
public NaturalLanguageClassifierService(IClient httpClient) : base(SERVICE_NAME, URL)
6465
{
6566
if (httpClient == null)
6667
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/NaturalLanguageUnderstandingService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public string VersionDate
3737

3838
public NaturalLanguageUnderstandingService() : base(SERVICE_NAME) { }
3939

40-
public NaturalLanguageUnderstandingService(string userName, string password, string versionDate) : this()
40+
public NaturalLanguageUnderstandingService(string userName, string password, string versionDate) : base(SERVICE_NAME, URL)
4141
{
4242
if (string.IsNullOrEmpty(userName))
4343
throw new ArgumentNullException(nameof(userName));
@@ -52,7 +52,7 @@ public NaturalLanguageUnderstandingService(string userName, string password, str
5252
VersionDate = versionDate;
5353
}
5454

55-
public NaturalLanguageUnderstandingService(TokenOptions options, string versionDate) : this()
55+
public NaturalLanguageUnderstandingService(TokenOptions options, string versionDate) : base(SERVICE_NAME, URL)
5656
{
5757
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
5858
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -73,7 +73,7 @@ public NaturalLanguageUnderstandingService(TokenOptions options, string versionD
7373
_tokenManager = new TokenManager(options);
7474
}
7575

76-
public NaturalLanguageUnderstandingService(IClient httpClient) : this()
76+
public NaturalLanguageUnderstandingService(IClient httpClient) : base(SERVICE_NAME, URL)
7777
{
7878
if (httpClient == null)
7979
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/PersonalityInsightsService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public string VersionDate
3737

3838
public PersonalityInsightsService() : base(SERVICE_NAME) { }
3939

40-
public PersonalityInsightsService(string userName, string password, string versionDate) : this()
40+
public PersonalityInsightsService(string userName, string password, string versionDate) : base(SERVICE_NAME, URL)
4141
{
4242
if (string.IsNullOrEmpty(userName))
4343
throw new ArgumentNullException(nameof(userName));
@@ -52,7 +52,7 @@ public PersonalityInsightsService(string userName, string password, string versi
5252
VersionDate = versionDate;
5353
}
5454

55-
public PersonalityInsightsService(TokenOptions options, string versionDate) : this()
55+
public PersonalityInsightsService(TokenOptions options, string versionDate) : base(SERVICE_NAME, URL)
5656
{
5757
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
5858
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -73,7 +73,7 @@ public PersonalityInsightsService(TokenOptions options, string versionDate) : th
7373
_tokenManager = new TokenManager(options);
7474
}
7575

76-
public PersonalityInsightsService(IClient httpClient) : this()
76+
public PersonalityInsightsService(IClient httpClient) : base(SERVICE_NAME, URL)
7777
{
7878
if (httpClient == null)
7979
throw new ArgumentNullException(nameof(httpClient));

src/IBM.WatsonDeveloperCloud.SpeechToText.v1/SpeechToTextService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ public partial class SpeechToTextService : WatsonService, ISpeechToTextService
3232
{
3333
const string SERVICE_NAME = "speech_to_text";
3434
const string URL = "https://stream.watsonplatform.net/speech-to-text/api";
35+
3536
public SpeechToTextService() : base(SERVICE_NAME) { }
3637

37-
public SpeechToTextService(string userName, string password) : this()
38+
public SpeechToTextService(string userName, string password) : base(SERVICE_NAME, URL)
3839
{
3940
if (string.IsNullOrEmpty(userName))
4041
throw new ArgumentNullException(nameof(userName));
@@ -45,7 +46,7 @@ public SpeechToTextService(string userName, string password) : this()
4546
this.SetCredential(userName, password);
4647
}
4748

48-
public SpeechToTextService(TokenOptions options) : this()
49+
public SpeechToTextService(TokenOptions options) : base(SERVICE_NAME, URL)
4950
{
5051
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
5152
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
@@ -61,7 +62,7 @@ public SpeechToTextService(TokenOptions options) : this()
6162
_tokenManager = new TokenManager(options);
6263
}
6364

64-
public SpeechToTextService(IClient httpClient) : this()
65+
public SpeechToTextService(IClient httpClient) : base(SERVICE_NAME, URL)
6566
{
6667
if (httpClient == null)
6768
throw new ArgumentNullException(nameof(httpClient));

0 commit comments

Comments
 (0)