public override void Validate() { if (string.IsNullOrEmpty(Url)) { throw new ArgumentNullException(string.Format(ErrorMessagePropMissing, "Url")); } if (string.IsNullOrEmpty(Username)) { throw new ArgumentNullException(string.Format(ErrorMessagePropMissing, "Username")); } if (string.IsNullOrEmpty(Password)) { throw new ArgumentNullException(string.Format(ErrorMessagePropMissing, "Password")); } if (Utility.HasBadFirstOrLastCharacter(Url)) { throw new ArgumentException(string.Format(ErrorMessagePropInvalid, "Url")); } if (Utility.HasBadFirstOrLastCharacter(Username)) { throw new ArgumentException(string.Format(ErrorMessagePropInvalid, "Username")); } if (Utility.HasBadFirstOrLastCharacter(Password)) { throw new ArgumentException(string.Format(ErrorMessagePropInvalid, "Password")); } }
public override void Validate() { if (string.IsNullOrEmpty(BearerToken)) { throw new ArgumentNullException(string.Format(ErrorMessagePropMissing, "BearerToken")); } if (Utility.HasBadFirstOrLastCharacter(BearerToken)) { throw new ArgumentException(string.Format(ErrorMessagePropInvalid, "BearerToken")); } }
/// <summary> /// This function returns a RESTConnector object for the given service and function. /// </summary> /// <param name="authenticator">Authenticator used to authenticate service.</param> /// <param name="function">The name of the function.</param> /// <param name="serviceUrl">Service Url to connect to.</param> /// <returns>Returns a RESTConnector object or null on error.</returns> /// public static RESTConnector GetConnector(Authenticator authenticator, string function, string serviceUrl) { if (string.IsNullOrEmpty(serviceUrl)) { throw new ArgumentNullException("The serviceUrl must not be empty or null."); } if (Utility.HasBadFirstOrLastCharacter(serviceUrl)) { throw new ArgumentException("The serviceUrl property is invalid. Please remove any surrounding {{, }}, or \" characters."); } RESTConnector connector = new RESTConnector { URL = serviceUrl + function, Authentication = authenticator }; authenticator.Authenticate(connector); return(connector); }
public override void Validate() { if (string.IsNullOrEmpty(Apikey)) { throw new ArgumentNullException(string.Format(ErrorMessagePropMissing, "apikey")); } if (Utility.HasBadFirstOrLastCharacter(Apikey)) { throw new ArgumentException(string.Format(ErrorMessagePropInvalid, "apikey")); } if (Utility.HasBadFirstOrLastCharacter(Url)) { throw new ArgumentException(string.Format(ErrorMessagePropInvalid, "url")); } if (!string.IsNullOrEmpty(ClientSecret) && string.IsNullOrEmpty(ClientId) || string.IsNullOrEmpty(ClientSecret) && !string.IsNullOrEmpty(ClientId)) { throw new ArgumentException("Client ID and Secret must BOTH be provided."); } }