Skip to content

Commit dd73e6d

Browse files
committed
refactor(All services): Refactored out unnecessary variable names
1 parent b56bacb commit dd73e6d

File tree

13 files changed

+40
-183
lines changed

13 files changed

+40
-183
lines changed

Scripts/Services/Assistant/v1/Assistant.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ public Assistant()
105105
var credentialsPaths = Utility.GetCredentialsPaths();
106106
if (credentialsPaths.Count > 0)
107107
{
108-
string ApiKey = "";
109-
string Endpoint = "";
110-
string Username = "";
111-
string Password = "";
112-
113108
foreach (string path in credentialsPaths)
114109
{
115110
if (Utility.LoadEnvFile(path))
@@ -118,15 +113,9 @@ public Assistant()
118113
}
119114
}
120115

121-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
122-
if (!string.IsNullOrEmpty(apiKey))
123-
ApiKey = apiKey;
124-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
125-
if (!string.IsNullOrEmpty(un))
126-
Username = un;
127-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
128-
if (!string.IsNullOrEmpty(pw))
129-
Password = pw;
116+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
117+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
118+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
130119
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
131120

132121
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

Scripts/Services/Assistant/v2/Assistant.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ public Assistant()
8888
var credentialsPaths = Utility.GetCredentialsPaths();
8989
if (credentialsPaths.Count > 0)
9090
{
91-
string ApiKey = "";
92-
string Endpoint = "";
93-
string Username = "";
94-
string Password = "";
95-
9691
foreach (string path in credentialsPaths)
9792
{
9893
if (Utility.LoadEnvFile(path))
@@ -101,15 +96,9 @@ public Assistant()
10196
}
10297
}
10398

104-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
105-
if (!string.IsNullOrEmpty(apiKey))
106-
ApiKey = apiKey;
107-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
108-
if (!string.IsNullOrEmpty(un))
109-
Username = un;
110-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
111-
if (!string.IsNullOrEmpty(pw))
112-
Password = pw;
99+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
100+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
101+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
113102
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
114103

115104
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))
@@ -124,7 +113,7 @@ public Assistant()
124113
IamApiKey = ApiKey
125114
};
126115

127-
Credentials = new Credentials(tokenOptions, Endpoint);
116+
Credentials = new Credentials(tokenOptions, ServiceUrl);
128117

129118
if (string.IsNullOrEmpty(Credentials.Url))
130119
{

Scripts/Services/CompareComply/v1/CompareComply.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ public CompareComply()
8787
var credentialsPaths = Utility.GetCredentialsPaths();
8888
if (credentialsPaths.Count > 0)
8989
{
90-
string ApiKey = "";
91-
string Endpoint = "";
92-
string Username = "";
93-
string Password = "";
94-
9590
foreach (string path in credentialsPaths)
9691
{
9792
if (Utility.LoadEnvFile(path))
@@ -100,15 +95,9 @@ public CompareComply()
10095
}
10196
}
10297

103-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
104-
if (!string.IsNullOrEmpty(apiKey))
105-
ApiKey = apiKey;
106-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
107-
if (!string.IsNullOrEmpty(un))
108-
Username = un;
109-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
110-
if (!string.IsNullOrEmpty(pw))
111-
Password = pw;
98+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
99+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
100+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
112101
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
113102

114103
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

Scripts/Services/Conversation/v1/Conversation.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ public Conversation()
107107
var credentialsPaths = Utility.GetCredentialsPaths();
108108
if (credentialsPaths.Count > 0)
109109
{
110-
string ApiKey = "";
111-
string Endpoint = "";
112-
string Username = "";
113-
string Password = "";
114-
115110
foreach (string path in credentialsPaths)
116111
{
117112
if (Utility.LoadEnvFile(path))
@@ -120,15 +115,9 @@ public Conversation()
120115
}
121116
}
122117

123-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
124-
if (!string.IsNullOrEmpty(apiKey))
125-
ApiKey = apiKey;
126-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
127-
if (!string.IsNullOrEmpty(un))
128-
Username = un;
129-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
130-
if (!string.IsNullOrEmpty(pw))
131-
Password = pw;
118+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
119+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
120+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
132121
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
133122

134123
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

Scripts/Services/Discovery/v1/Discovery.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ public Discovery()
118118
var credentialsPaths = Utility.GetCredentialsPaths();
119119
if (credentialsPaths.Count > 0)
120120
{
121-
string ApiKey = "";
122-
string Endpoint = "";
123-
string Username = "";
124-
string Password = "";
125-
126121
foreach (string path in credentialsPaths)
127122
{
128123
if (Utility.LoadEnvFile(path))
@@ -131,15 +126,9 @@ public Discovery()
131126
}
132127
}
133128

134-
string apiKey = System.Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
135-
if (!string.IsNullOrEmpty(apiKey))
136-
ApiKey = apiKey;
137-
string un = System.Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
138-
if (!string.IsNullOrEmpty(un))
139-
Username = un;
140-
string pw = System.Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
141-
if (!string.IsNullOrEmpty(pw))
142-
Password = pw;
129+
string ApiKey = System.Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
130+
string Username = System.Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
131+
string Password = System.Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
143132
string ServiceUrl = System.Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
144133

145134
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

Scripts/Services/LanguageTranslator/v3/LanguageTranslator.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ public LanguageTranslator()
101101
var credentialsPaths = Utility.GetCredentialsPaths();
102102
if (credentialsPaths.Count > 0)
103103
{
104-
string ApiKey = "";
105-
string Endpoint = "";
106-
string Username = "";
107-
string Password = "";
108-
109104
foreach (string path in credentialsPaths)
110105
{
111106
if (Utility.LoadEnvFile(path))
@@ -114,15 +109,9 @@ public LanguageTranslator()
114109
}
115110
}
116111

117-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
118-
if (!string.IsNullOrEmpty(apiKey))
119-
ApiKey = apiKey;
120-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
121-
if (!string.IsNullOrEmpty(un))
122-
Username = un;
123-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
124-
if (!string.IsNullOrEmpty(pw))
125-
Password = pw;
112+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
113+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
114+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
126115
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
127116

128117
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

Scripts/Services/NaturalLanguageClassifier/v2/NaturalLanguageClassifier.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public NaturalLanguageClassifier()
4646
var credentialsPaths = Utility.GetCredentialsPaths();
4747
if (credentialsPaths.Count > 0)
4848
{
49-
string ApiKey = "";
50-
string Endpoint = "";
51-
string Username = "";
52-
string Password = "";
53-
5449
foreach (string path in credentialsPaths)
5550
{
5651
if (Utility.LoadEnvFile(path))
@@ -59,15 +54,9 @@ public NaturalLanguageClassifier()
5954
}
6055
}
6156

62-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
63-
if (!string.IsNullOrEmpty(apiKey))
64-
ApiKey = apiKey;
65-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
66-
if (!string.IsNullOrEmpty(un))
67-
Username = un;
68-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
69-
if (!string.IsNullOrEmpty(pw))
70-
Password = pw;
57+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
58+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
59+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
7160
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
7261

7362
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

Scripts/Services/NaturalLanguageUnderstanding/v1/NaturalLanguageUnderstanding.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ public NaturalLanguageUnderstanding()
102102
var credentialsPaths = Utility.GetCredentialsPaths();
103103
if (credentialsPaths.Count > 0)
104104
{
105-
string ApiKey = "";
106-
string Endpoint = "";
107-
string Username = "";
108-
string Password = "";
109-
110105
foreach (string path in credentialsPaths)
111106
{
112107
if (Utility.LoadEnvFile(path))
@@ -115,15 +110,9 @@ public NaturalLanguageUnderstanding()
115110
}
116111
}
117112

118-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
119-
if (!string.IsNullOrEmpty(apiKey))
120-
ApiKey = apiKey;
121-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
122-
if (!string.IsNullOrEmpty(un))
123-
Username = un;
124-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
125-
if (!string.IsNullOrEmpty(pw))
126-
Password = pw;
113+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
114+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
115+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
127116
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
128117

129118
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

Scripts/Services/PersonalityInsights/v3/PersonalityInsights.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ public PersonalityInsights()
104104
var credentialsPaths = Utility.GetCredentialsPaths();
105105
if (credentialsPaths.Count > 0)
106106
{
107-
string ApiKey = "";
108-
string Endpoint = "";
109-
string Username = "";
110-
string Password = "";
111-
112107
foreach (string path in credentialsPaths)
113108
{
114109
if (Utility.LoadEnvFile(path))
@@ -117,15 +112,9 @@ public PersonalityInsights()
117112
}
118113
}
119114

120-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
121-
if (!string.IsNullOrEmpty(apiKey))
122-
ApiKey = apiKey;
123-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
124-
if (!string.IsNullOrEmpty(un))
125-
Username = un;
126-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
127-
if (!string.IsNullOrEmpty(pw))
128-
Password = pw;
115+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
116+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
117+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
129118
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
130119

131120
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

Scripts/Services/SpeechToText/v1/SpeechToText.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,6 @@ public SpeechToText()
293293
var credentialsPaths = Utility.GetCredentialsPaths();
294294
if (credentialsPaths.Count > 0)
295295
{
296-
string ApiKey = "";
297-
string Endpoint = "";
298-
string Username = "";
299-
string Password = "";
300-
301296
foreach (string path in credentialsPaths)
302297
{
303298
if (Utility.LoadEnvFile(path))
@@ -306,15 +301,9 @@ public SpeechToText()
306301
}
307302
}
308303

309-
string apiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
310-
if (!string.IsNullOrEmpty(apiKey))
311-
ApiKey = apiKey;
312-
string un = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
313-
if (!string.IsNullOrEmpty(un))
314-
Username = un;
315-
string pw = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
316-
if (!string.IsNullOrEmpty(pw))
317-
Password = pw;
304+
string ApiKey = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_APIKEY");
305+
string Username = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_USERNAME");
306+
string Password = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_PASSWORD");
318307
string ServiceUrl = Environment.GetEnvironmentVariable(ServiceId.ToUpper() + "_URL");
319308

320309
if (string.IsNullOrEmpty(ApiKey) && (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)))

0 commit comments

Comments
 (0)