Skip to content

Commit 0474b52

Browse files
committed
chore: Updated sevices and tests
1 parent e8f473e commit 0474b52

File tree

20 files changed

+824
-884
lines changed

20 files changed

+824
-884
lines changed

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

Lines changed: 183 additions & 187 deletions
Large diffs are not rendered by default.

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ public string VersionDate
3535
set { _versionDate = value; }
3636
}
3737

38-
public AssistantService() : base(SERVICE_NAME, URL)
39-
{
40-
if(!string.IsNullOrEmpty(this.Endpoint))
41-
this.Endpoint = URL;
42-
}
38+
public AssistantService() : base(SERVICE_NAME) { }
4339

4440
public AssistantService(string userName, string password, string versionDate) : this()
4541
{
@@ -50,7 +46,7 @@ public AssistantService(string userName, string password, string versionDate) :
5046
throw new ArgumentNullException(nameof(password));
5147

5248
this.SetCredential(userName, password);
53-
if(string.IsNullOrEmpty(versionDate))
49+
if (string.IsNullOrEmpty(versionDate))
5450
throw new ArgumentNullException("versionDate cannot be null.");
5551

5652
VersionDate = versionDate;
@@ -60,7 +56,7 @@ public AssistantService(TokenOptions options, string versionDate) : this()
6056
{
6157
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
6258
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
63-
if(string.IsNullOrEmpty(versionDate))
59+
if (string.IsNullOrEmpty(versionDate))
6460
throw new ArgumentNullException("versionDate cannot be null.");
6561

6662
VersionDate = versionDate;
@@ -111,7 +107,7 @@ public SessionResponse CreateSession(string assistantId, Dictionary<string, obje
111107
try
112108
{
113109
IClient client;
114-
if(_tokenManager == null)
110+
if (_tokenManager == null)
115111
{
116112
client = this.Client.WithAuthentication(this.UserName, this.Password);
117113
}
@@ -124,14 +120,14 @@ public SessionResponse CreateSession(string assistantId, Dictionary<string, obje
124120
restRequest.WithArgument("version", VersionDate);
125121
if (customData != null)
126122
restRequest.WithCustomData(customData);
127-
123+
128124
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=conversation;service_version=v2;operation_id=CreateSession");
129125
result = restRequest.As<SessionResponse>().Result;
130-
if(result == null)
126+
if (result == null)
131127
result = new SessionResponse();
132128
result.CustomData = restRequest.CustomData;
133129
}
134-
catch(AggregateException ae)
130+
catch (AggregateException ae)
135131
{
136132
throw ae.Flatten();
137133
}
@@ -167,7 +163,7 @@ public BaseModel DeleteSession(string assistantId, string sessionId, Dictionary<
167163
try
168164
{
169165
IClient client;
170-
if(_tokenManager == null)
166+
if (_tokenManager == null)
171167
{
172168
client = this.Client.WithAuthentication(this.UserName, this.Password);
173169
}
@@ -180,14 +176,14 @@ public BaseModel DeleteSession(string assistantId, string sessionId, Dictionary<
180176
restRequest.WithArgument("version", VersionDate);
181177
if (customData != null)
182178
restRequest.WithCustomData(customData);
183-
179+
184180
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=conversation;service_version=v2;operation_id=DeleteSession");
185181
result = restRequest.As<BaseModel>().Result;
186-
if(result == null)
182+
if (result == null)
187183
result = new BaseModel();
188184
result.CustomData = restRequest.CustomData;
189185
}
190-
catch(AggregateException ae)
186+
catch (AggregateException ae)
191187
{
192188
throw ae.Flatten();
193189
}
@@ -226,7 +222,7 @@ public MessageResponse Message(string assistantId, string sessionId, MessageRequ
226222
try
227223
{
228224
IClient client;
229-
if(_tokenManager == null)
225+
if (_tokenManager == null)
230226
{
231227
client = this.Client.WithAuthentication(this.UserName, this.Password);
232228
}
@@ -240,14 +236,14 @@ public MessageResponse Message(string assistantId, string sessionId, MessageRequ
240236
restRequest.WithBody<MessageRequest>(request);
241237
if (customData != null)
242238
restRequest.WithCustomData(customData);
243-
239+
244240
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=conversation;service_version=v2;operation_id=Message");
245241
result = restRequest.As<MessageResponse>().Result;
246-
if(result == null)
242+
if (result == null)
247243
result = new MessageResponse();
248244
result.CustomData = restRequest.CustomData;
249245
}
250-
catch(AggregateException ae)
246+
catch (AggregateException ae)
251247
{
252248
throw ae.Flatten();
253249
}

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

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,13 @@ public string VersionDate
3939
set { _versionDate = value; }
4040
}
4141

42-
public CompareComplyService() : base(SERVICE_NAME, URL)
43-
{
44-
if(!string.IsNullOrEmpty(this.Endpoint))
45-
this.Endpoint = URL;
46-
}
42+
public CompareComplyService() : base(SERVICE_NAME) { }
4743

4844
public CompareComplyService(TokenOptions options, string versionDate) : this()
4945
{
5046
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
5147
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
52-
if(string.IsNullOrEmpty(versionDate))
48+
if (string.IsNullOrEmpty(versionDate))
5349
throw new ArgumentNullException("versionDate cannot be null.");
5450

5551
VersionDate = versionDate;
@@ -119,14 +115,14 @@ public HTMLReturn ConvertToHtml(System.IO.FileStream file, string modelId = null
119115
restRequest.WithBodyContent(formData);
120116
if (customData != null)
121117
restRequest.WithCustomData(customData);
122-
118+
123119
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=ConvertToHtml");
124120
result = restRequest.As<HTMLReturn>().Result;
125-
if(result == null)
121+
if (result == null)
126122
result = new HTMLReturn();
127123
result.CustomData = restRequest.CustomData;
128124
}
129-
catch(AggregateException ae)
125+
catch (AggregateException ae)
130126
{
131127
throw ae.Flatten();
132128
}
@@ -178,14 +174,14 @@ public ClassifyReturn ClassifyElements(System.IO.FileStream file, string modelId
178174
restRequest.WithBodyContent(formData);
179175
if (customData != null)
180176
restRequest.WithCustomData(customData);
181-
177+
182178
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=ClassifyElements");
183179
result = restRequest.As<ClassifyReturn>().Result;
184-
if(result == null)
180+
if (result == null)
185181
result = new ClassifyReturn();
186182
result.CustomData = restRequest.CustomData;
187183
}
188-
catch(AggregateException ae)
184+
catch (AggregateException ae)
189185
{
190186
throw ae.Flatten();
191187
}
@@ -237,14 +233,14 @@ public TableReturn ExtractTables(System.IO.FileStream file, string modelId = nul
237233
restRequest.WithBodyContent(formData);
238234
if (customData != null)
239235
restRequest.WithCustomData(customData);
240-
236+
241237
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=ExtractTables");
242238
result = restRequest.As<TableReturn>().Result;
243-
if(result == null)
239+
if (result == null)
244240
result = new TableReturn();
245241
result.CustomData = restRequest.CustomData;
246242
}
247-
catch(AggregateException ae)
243+
catch (AggregateException ae)
248244
{
249245
throw ae.Flatten();
250246
}
@@ -316,14 +312,14 @@ public CompareReturn CompareDocuments(System.IO.FileStream file1, System.IO.File
316312
restRequest.WithBodyContent(formData);
317313
if (customData != null)
318314
restRequest.WithCustomData(customData);
319-
315+
320316
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=CompareDocuments");
321317
result = restRequest.As<CompareReturn>().Result;
322-
if(result == null)
318+
if (result == null)
323319
result = new CompareReturn();
324320
result.CustomData = restRequest.CustomData;
325321
}
326-
catch(AggregateException ae)
322+
catch (AggregateException ae)
327323
{
328324
throw ae.Flatten();
329325
}
@@ -360,14 +356,14 @@ public FeedbackReturn AddFeedback(FeedbackInput feedbackData, Dictionary<string,
360356
restRequest.WithBody<FeedbackInput>(feedbackData);
361357
if (customData != null)
362358
restRequest.WithCustomData(customData);
363-
359+
364360
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=AddFeedback");
365361
result = restRequest.As<FeedbackReturn>().Result;
366-
if(result == null)
362+
if (result == null)
367363
result = new FeedbackReturn();
368364
result.CustomData = restRequest.CustomData;
369365
}
370-
catch(AggregateException ae)
366+
catch (AggregateException ae)
371367
{
372368
throw ae.Flatten();
373369
}
@@ -406,14 +402,14 @@ public FeedbackDeleted DeleteFeedback(string feedbackId, string modelId = null,
406402
restRequest.WithArgument("model_id", modelId);
407403
if (customData != null)
408404
restRequest.WithCustomData(customData);
409-
405+
410406
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=DeleteFeedback");
411407
result = restRequest.As<FeedbackDeleted>().Result;
412-
if(result == null)
408+
if (result == null)
413409
result = new FeedbackDeleted();
414410
result.CustomData = restRequest.CustomData;
415411
}
416-
catch(AggregateException ae)
412+
catch (AggregateException ae)
417413
{
418414
throw ae.Flatten();
419415
}
@@ -451,14 +447,14 @@ public GetFeedback GetFeedback(string feedbackId, string modelId = null, Diction
451447
restRequest.WithArgument("model_id", modelId);
452448
if (customData != null)
453449
restRequest.WithCustomData(customData);
454-
450+
455451
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=GetFeedback");
456452
result = restRequest.As<GetFeedback>().Result;
457-
if(result == null)
453+
if (result == null)
458454
result = new GetFeedback();
459455
result.CustomData = restRequest.CustomData;
460456
}
461-
catch(AggregateException ae)
457+
catch (AggregateException ae)
462458
{
463459
throw ae.Flatten();
464460
}
@@ -559,14 +555,14 @@ public FeedbackList ListFeedback(string feedbackType = null, DateTime? before =
559555
restRequest.WithArgument("include_total", includeTotal);
560556
if (customData != null)
561557
restRequest.WithCustomData(customData);
562-
558+
563559
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=ListFeedback");
564560
result = restRequest.As<FeedbackList>().Result;
565-
if(result == null)
561+
if (result == null)
566562
result = new FeedbackList();
567563
result.CustomData = restRequest.CustomData;
568564
}
569-
catch(AggregateException ae)
565+
catch (AggregateException ae)
570566
{
571567
throw ae.Flatten();
572568
}
@@ -686,14 +682,14 @@ public BatchStatus CreateBatch(string function, System.IO.FileStream inputCreden
686682
restRequest.WithBodyContent(formData);
687683
if (customData != null)
688684
restRequest.WithCustomData(customData);
689-
685+
690686
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=CreateBatch");
691687
result = restRequest.As<BatchStatus>().Result;
692-
if(result == null)
688+
if (result == null)
693689
result = new BatchStatus();
694690
result.CustomData = restRequest.CustomData;
695691
}
696-
catch(AggregateException ae)
692+
catch (AggregateException ae)
697693
{
698694
throw ae.Flatten();
699695
}
@@ -727,14 +723,14 @@ public BatchStatus GetBatch(string batchId, Dictionary<string, object> customDat
727723
restRequest.WithArgument("version", VersionDate);
728724
if (customData != null)
729725
restRequest.WithCustomData(customData);
730-
726+
731727
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=GetBatch");
732728
result = restRequest.As<BatchStatus>().Result;
733-
if(result == null)
729+
if (result == null)
734730
result = new BatchStatus();
735731
result.CustomData = restRequest.CustomData;
736732
}
737-
catch(AggregateException ae)
733+
catch (AggregateException ae)
738734
{
739735
throw ae.Flatten();
740736
}
@@ -765,14 +761,14 @@ public Batches ListBatches(Dictionary<string, object> customData = null)
765761
restRequest.WithArgument("version", VersionDate);
766762
if (customData != null)
767763
restRequest.WithCustomData(customData);
768-
764+
769765
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=ListBatches");
770766
result = restRequest.As<Batches>().Result;
771-
if(result == null)
767+
if (result == null)
772768
result = new Batches();
773769
result.CustomData = restRequest.CustomData;
774770
}
775-
catch(AggregateException ae)
771+
catch (AggregateException ae)
776772
{
777773
throw ae.Flatten();
778774
}
@@ -818,14 +814,14 @@ public BatchStatus UpdateBatch(string batchId, string action, string modelId = n
818814
restRequest.WithArgument("model_id", modelId);
819815
if (customData != null)
820816
restRequest.WithCustomData(customData);
821-
817+
822818
restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=compare-comply;service_version=v1;operation_id=UpdateBatch");
823819
result = restRequest.As<BatchStatus>().Result;
824-
if(result == null)
820+
if (result == null)
825821
result = new BatchStatus();
826822
result.CustomData = restRequest.CustomData;
827823
}
828-
catch(AggregateException ae)
824+
catch (AggregateException ae)
829825
{
830826
throw ae.Flatten();
831827
}

0 commit comments

Comments
 (0)