Skip to content

Commit c4587af

Browse files
committed
refactor: provide getServiceUrl method and refactor connectors
1 parent 88b47b8 commit c4587af

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

BaseService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public void SetServiceUrl(string url)
5858
serviceUrl = url;
5959
}
6060

61+
public string GetServiceUrl()
62+
{
63+
return serviceUrl;
64+
}
65+
6166
/// <summary>
6267
/// Returns the authenticator for the service.
6368
/// </summary>

Connection/RESTConnector.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,23 +260,24 @@ public bool? DisableSslVerification
260260
/// </summary>
261261
/// <param name="authenticator">Authenticator used to authenticate service.</param>
262262
/// <param name="function">The name of the function.</param>
263+
/// <param name="serviceUrl">Service Url to connect to.</param>
263264
/// <returns>Returns a RESTConnector object or null on error.</returns>
264265
///
265-
public static RESTConnector GetConnector(Authenticator authenticator, string function, string url)
266+
public static RESTConnector GetConnector(Authenticator authenticator, string function, string serviceUrl)
266267
{
267-
if (string.IsNullOrEmpty(url))
268+
if (string.IsNullOrEmpty(serviceUrl))
268269
{
269-
throw new ArgumentNullException("The Url must not be empty or null.");
270+
throw new ArgumentNullException("The serviceUrl must not be empty or null.");
270271
}
271272

272-
if (Utility.HasBadFirstOrLastCharacter(url))
273+
if (Utility.HasBadFirstOrLastCharacter(serviceUrl))
273274
{
274-
throw new ArgumentException("The Url property is invalid. Please remove any surrounding {{, }}, or \" characters.");
275+
throw new ArgumentException("The serviceUrl property is invalid. Please remove any surrounding {{, }}, or \" characters.");
275276
}
276277

277278
RESTConnector connector = new RESTConnector
278279
{
279-
URL = url + function,
280+
URL = serviceUrl + function,
280281
Authentication = authenticator
281282
};
282283

Connection/WSConnector.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,28 +322,29 @@ public static string FixupURL(string URL)
322322
}
323323

324324
/// <summary>
325-
/// Create a WSConnector for the given service and function.
325+
/// Create a WSConnector for the given service and function.
326326
/// </summary>
327327
/// <param name="authenticator">The authenticator for the service.</param>
328328
/// <param name="function">The name of the function to connect.</param>
329329
/// <param name="args">Additional function arguments.</param>
330+
/// <param name="serviceUrl">Service Url to connect to.</param>
330331
/// <returns>The WSConnector object or null or error.</returns>
331-
public static WSConnector CreateConnector(Authenticator authenticator, string function, string args, string url)
332+
public static WSConnector CreateConnector(Authenticator authenticator, string function, string args, string serviceUrl)
332333
{
333-
if (string.IsNullOrEmpty(url))
334+
if (string.IsNullOrEmpty(serviceUrl))
334335
{
335-
throw new ArgumentNullException("The Url must not be empty or null.");
336+
throw new ArgumentNullException("The serviceUrl must not be empty or null.");
336337
}
337338

338-
if (Utility.HasBadFirstOrLastCharacter(url))
339+
if (Utility.HasBadFirstOrLastCharacter(serviceUrl))
339340
{
340-
throw new ArgumentException("The Url property is invalid. Please remove any surrounding {{, }}, or \" characters.");
341+
throw new ArgumentException("The serviceUrl property is invalid. Please remove any surrounding {{, }}, or \" characters.");
341342
}
342343

343344
WSConnector connector = new WSConnector();
344345
connector.Authentication = authenticator;
345346

346-
connector.URL = FixupURL(url) + function + args;
347+
connector.URL = FixupURL(serviceUrl) + function + args;
347348
authenticator.Authenticate(connector);
348349

349350
return connector;

0 commit comments

Comments
 (0)