@@ -32,32 +32,7 @@ namespace IBM.Watson.CompareComply.V1
32
32
public partial class CompareComplyService : BaseService
33
33
{
34
34
private const string serviceId = "compare_comply" ;
35
- private const string defaultUrl = "https://gateway.watsonplatform.net/compare-comply/api" ;
36
-
37
- #region Authenticator
38
- /// <summary>
39
- /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined.
40
- /// </summary>
41
- public Authenticator Authenticator
42
- {
43
- get { return authenticator ; }
44
- set
45
- {
46
- authenticator = value ;
47
- }
48
- }
49
- #endregion
50
-
51
- #region Url
52
- /// <summary>
53
- /// Gets and sets the endpoint URL for the service.
54
- /// </summary>
55
- public string Url
56
- {
57
- get { return url ; }
58
- set { url = value ; }
59
- }
60
- #endregion
35
+ private const string defaultServiceUrl = "https://gateway.watsonplatform.net/compare-comply/api" ;
61
36
62
37
#region VersionDate
63
38
private string versionDate ;
@@ -96,6 +71,7 @@ public CompareComplyService(string versionDate) : this(versionDate, ConfigBasedA
96
71
/// <param name="authenticator">The service authenticator.</param>
97
72
public CompareComplyService ( string versionDate , Authenticator authenticator ) : base ( versionDate , authenticator , serviceId )
98
73
{
74
+ Authenticator = authenticator ;
99
75
if ( string . IsNullOrEmpty ( versionDate ) )
100
76
{
101
77
throw new ArgumentNullException ( "A versionDate (format `yyyy-mm-dd`) is required to create an instance of CompareComplyService" ) ;
@@ -105,19 +81,10 @@ public CompareComplyService(string versionDate, Authenticator authenticator) : b
105
81
VersionDate = versionDate ;
106
82
}
107
83
108
- if ( authenticator != null )
109
- {
110
- Authenticator = authenticator ;
111
84
112
- if ( string . IsNullOrEmpty ( Url ) )
113
- {
114
- Authenticator . Url = defaultUrl ;
115
- }
116
- Authenticator . Url = Url ;
117
- }
118
- else
85
+ if ( string . IsNullOrEmpty ( GetServiceUrl ( ) ) )
119
86
{
120
- throw new IBMException ( "Please provide a username and password or authorization token to use the CompareComply service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials" ) ;
87
+ SetServiceUrl ( defaultServiceUrl ) ;
121
88
}
122
89
}
123
90
@@ -173,12 +140,11 @@ public bool ConvertToHtml(Callback<HTMLReturn> callback, System.IO.MemoryStream
173
140
174
141
req . OnResponse = OnConvertToHtmlResponse ;
175
142
176
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/html_conversion" ) ;
143
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/html_conversion" , GetServiceUrl ( ) ) ;
177
144
if ( connector == null )
178
145
{
179
146
return false ;
180
147
}
181
- Authenticator . Authenticate ( connector ) ;
182
148
183
149
return connector . Send ( req ) ;
184
150
}
@@ -259,12 +225,11 @@ public bool ClassifyElements(Callback<ClassifyReturn> callback, System.IO.Memory
259
225
260
226
req . OnResponse = OnClassifyElementsResponse ;
261
227
262
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/element_classification" ) ;
228
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/element_classification" , GetServiceUrl ( ) ) ;
263
229
if ( connector == null )
264
230
{
265
231
return false ;
266
232
}
267
- Authenticator . Authenticate ( connector ) ;
268
233
269
234
return connector . Send ( req ) ;
270
235
}
@@ -345,12 +310,11 @@ public bool ExtractTables(Callback<TableReturn> callback, System.IO.MemoryStream
345
310
346
311
req . OnResponse = OnExtractTablesResponse ;
347
312
348
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/tables" ) ;
313
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/tables" , GetServiceUrl ( ) ) ;
349
314
if ( connector == null )
350
315
{
351
316
return false ;
352
317
}
353
- Authenticator . Authenticate ( connector ) ;
354
318
355
319
return connector . Send ( req ) ;
356
320
}
@@ -449,12 +413,11 @@ public bool CompareDocuments(Callback<CompareReturn> callback, System.IO.MemoryS
449
413
450
414
req . OnResponse = OnCompareDocumentsResponse ;
451
415
452
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/comparison" ) ;
416
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/comparison" , GetServiceUrl ( ) ) ;
453
417
if ( connector == null )
454
418
{
455
419
return false ;
456
420
}
457
- Authenticator . Authenticate ( connector ) ;
458
421
459
422
return connector . Send ( req ) ;
460
423
}
@@ -537,12 +500,11 @@ public bool AddFeedback(Callback<FeedbackReturn> callback, FeedbackDataInput fee
537
500
538
501
req . OnResponse = OnAddFeedbackResponse ;
539
502
540
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/feedback" ) ;
503
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/feedback" , GetServiceUrl ( ) ) ;
541
504
if ( connector == null )
542
505
{
543
506
return false ;
544
507
}
545
- Authenticator . Authenticate ( connector ) ;
546
508
547
509
return connector . Send ( req ) ;
548
510
}
@@ -710,12 +672,11 @@ public bool ListFeedback(Callback<FeedbackList> callback, string feedbackType =
710
672
711
673
req . OnResponse = OnListFeedbackResponse ;
712
674
713
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/feedback" ) ;
675
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/feedback" , GetServiceUrl ( ) ) ;
714
676
if ( connector == null )
715
677
{
716
678
return false ;
717
679
}
718
- Authenticator . Authenticate ( connector ) ;
719
680
720
681
return connector . Send ( req ) ;
721
682
}
@@ -790,12 +751,11 @@ public bool GetFeedback(Callback<GetFeedback> callback, string feedbackId, strin
790
751
791
752
req . OnResponse = OnGetFeedbackResponse ;
792
753
793
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , string . Format ( "/v1/feedback/{0}" , feedbackId ) ) ;
754
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , string . Format ( "/v1/feedback/{0}" , feedbackId ) , GetServiceUrl ( ) ) ;
794
755
if ( connector == null )
795
756
{
796
757
return false ;
797
758
}
798
- Authenticator . Authenticate ( connector ) ;
799
759
800
760
return connector . Send ( req ) ;
801
761
}
@@ -870,12 +830,11 @@ public bool DeleteFeedback(Callback<FeedbackDeleted> callback, string feedbackId
870
830
871
831
req . OnResponse = OnDeleteFeedbackResponse ;
872
832
873
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , string . Format ( "/v1/feedback/{0}" , feedbackId ) ) ;
833
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , string . Format ( "/v1/feedback/{0}" , feedbackId ) , GetServiceUrl ( ) ) ;
874
834
if ( connector == null )
875
835
{
876
836
return false ;
877
837
}
878
- Authenticator . Authenticate ( connector ) ;
879
838
880
839
return connector . Send ( req ) ;
881
840
}
@@ -1010,12 +969,11 @@ public bool CreateBatch(Callback<BatchStatus> callback, string function, System.
1010
969
1011
970
req . OnResponse = OnCreateBatchResponse ;
1012
971
1013
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/batches" ) ;
972
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/batches" , GetServiceUrl ( ) ) ;
1014
973
if ( connector == null )
1015
974
{
1016
975
return false ;
1017
976
}
1018
- Authenticator . Authenticate ( connector ) ;
1019
977
1020
978
return connector . Send ( req ) ;
1021
979
}
@@ -1079,12 +1037,11 @@ public bool ListBatches(Callback<Batches> callback)
1079
1037
1080
1038
req . OnResponse = OnListBatchesResponse ;
1081
1039
1082
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/batches" ) ;
1040
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , "/v1/batches" , GetServiceUrl ( ) ) ;
1083
1041
if ( connector == null )
1084
1042
{
1085
1043
return false ;
1086
1044
}
1087
- Authenticator . Authenticate ( connector ) ;
1088
1045
1089
1046
return connector . Send ( req ) ;
1090
1047
}
@@ -1151,12 +1108,11 @@ public bool GetBatch(Callback<BatchStatus> callback, string batchId)
1151
1108
1152
1109
req . OnResponse = OnGetBatchResponse ;
1153
1110
1154
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , string . Format ( "/v1/batches/{0}" , batchId ) ) ;
1111
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , string . Format ( "/v1/batches/{0}" , batchId ) , GetServiceUrl ( ) ) ;
1155
1112
if ( connector == null )
1156
1113
{
1157
1114
return false ;
1158
1115
}
1159
- Authenticator . Authenticate ( connector ) ;
1160
1116
1161
1117
return connector . Send ( req ) ;
1162
1118
}
@@ -1239,12 +1195,11 @@ public bool UpdateBatch(Callback<BatchStatus> callback, string batchId, string a
1239
1195
1240
1196
req . OnResponse = OnUpdateBatchResponse ;
1241
1197
1242
- RESTConnector connector = RESTConnector . GetConnector ( Authenticator , string . Format ( "/v1/batches/{0}" , batchId ) ) ;
1198
+ RESTConnector connector = RESTConnector . GetConnector ( Authenticator , string . Format ( "/v1/batches/{0}" , batchId ) , GetServiceUrl ( ) ) ;
1243
1199
if ( connector == null )
1244
1200
{
1245
1201
return false ;
1246
1202
}
1247
- Authenticator . Authenticate ( connector ) ;
1248
1203
1249
1204
return connector . Send ( req ) ;
1250
1205
}
0 commit comments