diff --git a/src/Genesys.Internal.Authentication/Api/AuthenticationApi.cs b/src/Genesys.Internal.Authentication/Api/AuthenticationApi.cs index 265fcc8..ad4d094 100644 --- a/src/Genesys.Internal.Authentication/Api/AuthenticationApi.cs +++ b/src/Genesys.Internal.Authentication/Api/AuthenticationApi.cs @@ -450,15 +450,9 @@ public partial class AuthenticationApi : IAuthenticationApi /// public AuthenticationApi(String basePath) { - this.Configuration = new Configuration(new ApiClient(basePath)); + this.Configuration = new Configuration { BasePath = basePath }; ExceptionFactory = Genesys.Internal.Authentication.Client.Configuration.DefaultExceptionFactory; - - // ensure API client has configuration ready - if (Configuration.ApiClient.Configuration == null) - { - this.Configuration.ApiClient.Configuration = this.Configuration; - } } /// @@ -475,12 +469,6 @@ public AuthenticationApi(Configuration configuration = null) this.Configuration = configuration; ExceptionFactory = Genesys.Internal.Authentication.Client.Configuration.DefaultExceptionFactory; - - // ensure API client has configuration ready - if (Configuration.ApiClient.Configuration == null) - { - this.Configuration.ApiClient.Configuration = this.Configuration; - } } /// @@ -529,9 +517,9 @@ public Genesys.Internal.Authentication.Client.ExceptionFactory ExceptionFactory /// /// Dictionary of HTTP header [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] - public Dictionary DefaultHeader() + public IDictionary DefaultHeader() { - return this.Configuration.DefaultHeader; + return new ReadOnlyDictionary(this.Configuration.DefaultHeader); } /// @@ -587,7 +575,7 @@ public ApiResponse AuthorizeWithHttpInfo (string responseType, string re var localVarPath = "/oauth/authorize"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -607,11 +595,11 @@ public ApiResponse AuthorizeWithHttpInfo (string responseType, string re if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); - if (responseType != null) localVarQueryParams.Add("response_type", Configuration.ApiClient.ParameterToString(responseType)); // query parameter - if (scope != null) localVarQueryParams.Add("scope", Configuration.ApiClient.ParameterToString(scope)); // query parameter - if (redirectUri != null) localVarQueryParams.Add("redirect_uri", Configuration.ApiClient.ParameterToString(redirectUri)); // query parameter - if (clientId != null) localVarQueryParams.Add("client_id", Configuration.ApiClient.ParameterToString(clientId)); // query parameter - if (hideTenant != null) localVarQueryParams.Add("hideTenant", Configuration.ApiClient.ParameterToString(hideTenant)); // query parameter + if (responseType != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "response_type", responseType)); // query parameter + if (scope != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "scope", scope)); // query parameter + if (redirectUri != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "redirect_uri", redirectUri)); // query parameter + if (clientId != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "client_id", clientId)); // query parameter + if (hideTenant != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "hideTenant", hideTenant)); // query parameter if (authorization != null) localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization)); // header parameter @@ -675,7 +663,7 @@ public async System.Threading.Tasks.Task> AuthorizeAsyncWith var localVarPath = "/oauth/authorize"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -695,11 +683,11 @@ public async System.Threading.Tasks.Task> AuthorizeAsyncWith if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); - if (responseType != null) localVarQueryParams.Add("response_type", Configuration.ApiClient.ParameterToString(responseType)); // query parameter - if (scope != null) localVarQueryParams.Add("scope", Configuration.ApiClient.ParameterToString(scope)); // query parameter - if (redirectUri != null) localVarQueryParams.Add("redirect_uri", Configuration.ApiClient.ParameterToString(redirectUri)); // query parameter - if (clientId != null) localVarQueryParams.Add("client_id", Configuration.ApiClient.ParameterToString(clientId)); // query parameter - if (hideTenant != null) localVarQueryParams.Add("hideTenant", Configuration.ApiClient.ParameterToString(hideTenant)); // query parameter + if (responseType != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "response_type", responseType)); // query parameter + if (scope != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "scope", scope)); // query parameter + if (redirectUri != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "redirect_uri", redirectUri)); // query parameter + if (clientId != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "client_id", clientId)); // query parameter + if (hideTenant != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "hideTenant", hideTenant)); // query parameter if (authorization != null) localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization)); // header parameter @@ -749,7 +737,7 @@ public ApiResponse< ApiResponse > ChangePasswordWithHttpInfo (ChangePasswordOper var localVarPath = "/change-password"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -827,7 +815,7 @@ public async System.Threading.Tasks.Task> ChangePasswor var localVarPath = "/change-password"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -902,7 +890,7 @@ public ApiResponse< CloudUserDetails > GetInfoWithHttpInfo (string authorization var localVarPath = "/userinfo"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -970,7 +958,7 @@ public async System.Threading.Tasks.Task> GetInfoA var localVarPath = "/userinfo"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1051,7 +1039,7 @@ public ApiResponse< DefaultOAuth2AccessToken > RetrieveTokenWithHttpInfo (string var localVarPath = "/oauth/token"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1140,7 +1128,7 @@ public async System.Threading.Tasks.Task> var localVarPath = "/oauth/token"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1220,7 +1208,7 @@ public ApiResponse SignInWithHttpInfo (string username, string password, var localVarPath = "/sign-in"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1296,7 +1284,7 @@ public async System.Threading.Tasks.Task> SignInAsyncWithHtt var localVarPath = "/sign-in"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1367,7 +1355,7 @@ public ApiResponse< ApiResponse > SignOutWithHttpInfo (string authorization, boo var localVarPath = "/sign-out"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1387,7 +1375,7 @@ public ApiResponse< ApiResponse > SignOutWithHttpInfo (string authorization, boo if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); - if (global != null) localVarQueryParams.Add("global", Configuration.ApiClient.ParameterToString(global)); // query parameter + if (global != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "global", global)); // query parameter if (authorization != null) localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization)); // header parameter @@ -1438,7 +1426,7 @@ public async System.Threading.Tasks.Task> SignOutAsyncW var localVarPath = "/sign-out"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1458,7 +1446,7 @@ public async System.Threading.Tasks.Task> SignOutAsyncW if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); - if (global != null) localVarQueryParams.Add("global", Configuration.ApiClient.ParameterToString(global)); // query parameter + if (global != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "global", global)); // query parameter if (authorization != null) localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization)); // header parameter @@ -1510,7 +1498,7 @@ public ApiResponse< ApiResponse > SignOut1WithHttpInfo (string authorization, bo var localVarPath = "/sign-out"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1530,8 +1518,8 @@ public ApiResponse< ApiResponse > SignOut1WithHttpInfo (string authorization, bo if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); - if (global != null) localVarQueryParams.Add("global", Configuration.ApiClient.ParameterToString(global)); // query parameter - if (redirectUri != null) localVarQueryParams.Add("redirectUri", Configuration.ApiClient.ParameterToString(redirectUri)); // query parameter + if (global != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "global", global)); // query parameter + if (redirectUri != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "redirectUri", redirectUri)); // query parameter if (authorization != null) localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization)); // header parameter @@ -1584,7 +1572,7 @@ public async System.Threading.Tasks.Task> SignOut1Async var localVarPath = "/sign-out"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1604,8 +1592,8 @@ public async System.Threading.Tasks.Task> SignOut1Async if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); - if (global != null) localVarQueryParams.Add("global", Configuration.ApiClient.ParameterToString(global)); // query parameter - if (redirectUri != null) localVarQueryParams.Add("redirectUri", Configuration.ApiClient.ParameterToString(redirectUri)); // query parameter + if (global != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "global", global)); // query parameter + if (redirectUri != null) localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "redirectUri", redirectUri)); // query parameter if (authorization != null) localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization)); // header parameter @@ -1650,7 +1638,7 @@ public ApiResponse< ApiResponse > TenantInfoWithHttpInfo (AuthSchemeLookupData l var localVarPath = "/auth-scheme"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); @@ -1722,7 +1710,7 @@ public async System.Threading.Tasks.Task> TenantInfoAsy var localVarPath = "/auth-scheme"; var localVarPathParams = new Dictionary(); - var localVarQueryParams = new Dictionary(); + var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); var localVarFormParams = new Dictionary(); var localVarFileParams = new Dictionary(); diff --git a/src/Genesys.Internal.Authentication/Client/ApiClient.cs b/src/Genesys.Internal.Authentication/Client/ApiClient.cs index 0aab2ef..4f721ea 100644 --- a/src/Genesys.Internal.Authentication/Client/ApiClient.cs +++ b/src/Genesys.Internal.Authentication/Client/ApiClient.cs @@ -48,11 +48,11 @@ public partial class ApiClient /// /// Initializes a new instance of the class - /// with default configuration and base path (https://your-server.com/auth/v3). + /// with default configuration. /// public ApiClient() { - Configuration = Configuration.Default; + Configuration = Genesys.Internal.Authentication.Client.Configuration.Default; RestClient = new RestClient("https://your-server.com/auth/v3"); } @@ -61,14 +61,11 @@ public ApiClient() /// with default base path (https://your-server.com/auth/v3). /// /// An instance of Configuration. - public ApiClient(Configuration config = null) + public ApiClient(Configuration config) { - if (config == null) - Configuration = Configuration.Default; - else - Configuration = config; + Configuration = config ?? Genesys.Internal.Authentication.Client.Configuration.Default; - RestClient = new RestClient("https://your-server.com/auth/v3"); + RestClient = new RestClient(Configuration.BasePath); } /// @@ -82,7 +79,7 @@ public ApiClient(String basePath = "https://your-server.com/auth/v3") throw new ArgumentException("basePath cannot be empty"); RestClient = new RestClient(basePath); - Configuration = Configuration.Default; + Configuration = Client.Configuration.Default; } /// @@ -93,10 +90,15 @@ public ApiClient(String basePath = "https://your-server.com/auth/v3") public static ApiClient Default; /// - /// Gets or sets the Configuration. + /// Gets or sets an instance of the IReadableConfiguration. /// - /// An instance of the Configuration. - public Configuration Configuration { get; set; } + /// An instance of the IReadableConfiguration. + /// + /// helps us to avoid modifying possibly global + /// configuration values from within a given client. It does not guarantee thread-safety + /// of the instance in any way. + /// + public IReadableConfiguration Configuration { get; set; } /// /// Gets or sets the RestClient. @@ -106,7 +108,7 @@ public ApiClient(String basePath = "https://your-server.com/auth/v3") // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( - String path, RestSharp.Method method, Dictionary queryParams, Object postBody, + String path, RestSharp.Method method, List> queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, Dictionary fileParams, Dictionary pathParams, String contentType) @@ -137,14 +139,7 @@ private RestRequest PrepareRequest( if (postBody != null) // http body (model or byte[]) parameter { - if (postBody.GetType() == typeof(String)) - { - request.AddParameter("application/json", postBody, ParameterType.RequestBody); - } - else if (postBody.GetType() == typeof(byte[])) - { - request.AddParameter(contentType, postBody, ParameterType.RequestBody); - } + request.AddParameter(contentType, postBody, ParameterType.RequestBody); } return request; @@ -164,7 +159,7 @@ private RestRequest PrepareRequest( /// Content Type of the request /// Object public Object CallApi( - String path, RestSharp.Method method, Dictionary queryParams, Object postBody, + String path, RestSharp.Method method, List> queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, Dictionary fileParams, Dictionary pathParams, String contentType) @@ -174,6 +169,7 @@ public Object CallApi( pathParams, contentType); // set timeout + RestClient.Timeout = Configuration.Timeout; // set user agent RestClient.UserAgent = Configuration.UserAgent; @@ -198,7 +194,7 @@ public Object CallApi( /// Content type. /// The Task instance. public async System.Threading.Tasks.Task CallApiAsync( - String path, RestSharp.Method method, Dictionary queryParams, Object postBody, + String path, RestSharp.Method method, List> queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, Dictionary fileParams, Dictionary pathParams, String contentType) @@ -286,6 +282,7 @@ public object Deserialize(IRestResponse response, Type type) return response.RawBytes; } + // TODO: ? if (type.IsAssignableFrom(typeof(Stream))) if (type == typeof(Stream)) { if (headers != null) @@ -347,9 +344,25 @@ public String Serialize(object obj) } } + /// + ///Check if the given MIME is a JSON MIME. + ///JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public bool IsJsonMime(String mime) + { + var jsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + return mime != null && (jsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json")); + } + /// /// Select the Content-Type header's value from the given content-type array: - /// if JSON exists in the given array, use it; + /// if JSON type exists in the given array, use it; /// otherwise use the first one defined in 'consumes' /// /// The Content-Type array to select from. @@ -357,11 +370,14 @@ public String Serialize(object obj) public String SelectHeaderContentType(String[] contentTypes) { if (contentTypes.Length == 0) - return null; - - if (contentTypes.Contains("application/json", StringComparer.OrdinalIgnoreCase)) return "application/json"; + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType.ToLower())) + return contentType; + } + return contentTypes[0]; // use the first content type specified in 'consumes' } @@ -395,31 +411,29 @@ public static string Base64Encode(string text) /// /// Dynamically cast the object into target type. - /// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast /// - /// Object to be casted - /// Target type + /// Object to be casted + /// Target type /// Casted object - public static dynamic ConvertType(dynamic source, Type dest) + public static dynamic ConvertType(dynamic fromObject, Type toObject) { - return Convert.ChangeType(source, dest); + return Convert.ChangeType(fromObject, toObject); } /// /// Convert stream to byte array - /// Credit/Ref: http://stackoverflow.com/a/221941/677735 /// - /// Input stream to be converted + /// Input stream to be converted /// Byte array - public static byte[] ReadAsBytes(Stream input) + public static byte[] ReadAsBytes(Stream inputStream) { - byte[] buffer = new byte[16*1024]; + byte[] buf = new byte[16*1024]; using (MemoryStream ms = new MemoryStream()) { - int read; - while ((read = input.Read(buffer, 0, buffer.Length)) > 0) + int count; + while ((count = inputStream.Read(buf, 0, buf.Length)) > 0) { - ms.Write(buffer, 0, read); + ms.Write(buf, 0, count); } return ms.ToArray(); } @@ -478,5 +492,39 @@ public static string SanitizeFilename(string filename) return filename; } } + + /// + /// Convert params to key/value pairs. + /// Use collectionFormat to properly format lists and collections. + /// + /// Key name. + /// Value object. + /// A list of KeyValuePairs + public IEnumerable> ParameterToKeyValuePairs(string collectionFormat, string name, object value) + { + var parameters = new List>(); + + if (IsCollection(value) && collectionFormat == "multi") + { + var valueCollection = value as IEnumerable; + parameters.AddRange(from object item in valueCollection select new KeyValuePair(name, ParameterToString(item))); + } + else + { + parameters.Add(new KeyValuePair(name, ParameterToString(value))); + } + + return parameters; + } + + /// + /// Check if generic object is a collection. + /// + /// + /// True if object is a collection type + private static bool IsCollection(object value) + { + return value is IList || value is ICollection; + } } } diff --git a/src/Genesys.Internal.Authentication/Client/Configuration.cs b/src/Genesys.Internal.Authentication/Client/Configuration.cs index 5017613..f317651 100644 --- a/src/Genesys.Internal.Authentication/Client/Configuration.cs +++ b/src/Genesys.Internal.Authentication/Client/Configuration.cs @@ -10,6 +10,7 @@ using System; using System.Reflection; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; @@ -20,62 +21,9 @@ namespace Genesys.Internal.Authentication.Client /// /// Represents a set of configuration settings /// - public class Configuration + public class Configuration : IReadableConfiguration { - /// - /// Initializes a new instance of the Configuration class with different settings - /// - /// Api client - /// Dictionary of default HTTP header - /// Username - /// Password - /// accessToken - /// Dictionary of API key - /// Dictionary of API key prefix - /// Temp folder path - /// DateTime format string - /// HTTP connection timeout (in milliseconds) - /// HTTP user agent - public Configuration(ApiClient apiClient = null, - Dictionary defaultHeader = null, - string username = null, - string password = null, - string accessToken = null, - Dictionary apiKey = null, - Dictionary apiKeyPrefix = null, - string tempFolderPath = null, - string dateTimeFormat = null, - int timeout = 100000, - string userAgent = "Swagger-Codegen/1.0.0/csharp" - ) - { - setApiClientUsingDefault(apiClient); - - Username = username; - Password = password; - AccessToken = accessToken; - UserAgent = userAgent; - - if (defaultHeader != null) - DefaultHeader = defaultHeader; - if (apiKey != null) - ApiKey = apiKey; - if (apiKeyPrefix != null) - ApiKeyPrefix = apiKeyPrefix; - - TempFolderPath = tempFolderPath; - DateTimeFormat = dateTimeFormat; - Timeout = timeout; - } - - /// - /// Initializes a new instance of the Configuration class. - /// - /// Api client. - public Configuration(ApiClient apiClient) - { - setApiClientUsingDefault(apiClient); - } + #region Constants /// /// Version of the package. @@ -84,155 +32,251 @@ public Configuration(ApiClient apiClient) public const string Version = "1.0.0"; /// - /// Gets or sets the default Configuration. + /// Identifier for ISO 8601 DateTime Format /// - /// Configuration. - public static Configuration Default = new Configuration(); + /// See https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 for more information. + // ReSharper disable once InconsistentNaming + public const string ISO8601_DATETIME_FORMAT = "o"; + + #endregion Constants + + #region Static Members + + private static readonly object GlobalConfigSync = new { }; + private static Configuration _globalConfiguration; /// /// Default creation of exceptions for a given method name and response object /// public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) => { - int status = (int) response.StatusCode; - if (status >= 400) return new ApiException(status, String.Format("Error calling {0}: {1}", methodName, response.Content), response.Content); - if (status == 0) return new ApiException(status, String.Format("Error calling {0}: {1}", methodName, response.ErrorMessage), response.ErrorMessage); + var status = (int)response.StatusCode; + if (status >= 400) + { + return new ApiException(status, + string.Format("Error calling {0}: {1}", methodName, response.Content), + response.Content); + } + if (status == 0) + { + return new ApiException(status, + string.Format("Error calling {0}: {1}", methodName, response.ErrorMessage), response.ErrorMessage); + } return null; }; /// - /// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds. + /// Gets or sets the default Configuration. /// - /// Timeout. - public int Timeout + /// Configuration. + public static Configuration Default { - get { return ApiClient.RestClient.Timeout; } - + get { return _globalConfiguration; } set { - if (ApiClient != null) - ApiClient.RestClient.Timeout = value; + lock (GlobalConfigSync) + { + _globalConfiguration = value; + } } } + #endregion Static Members + + #region Private Members + /// - /// Gets or sets the default API client for making HTTP calls. + /// Gets or sets the API key based on the authentication name. /// - /// The API client. - public ApiClient ApiClient; + /// The API key. + private IDictionary _apiKey = null; /// - /// Set the ApiClient using Default or ApiClient instance. + /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. /// - /// An instance of ApiClient. - /// - public void setApiClientUsingDefault (ApiClient apiClient = null) - { - if (apiClient == null) - { - if (Default != null && Default.ApiClient == null) - Default.ApiClient = new ApiClient(); + /// The prefix of the API key. + private IDictionary _apiKeyPrefix = null; - ApiClient = Default != null ? Default.ApiClient : new ApiClient(); - } - else - { - if (Default != null && Default.ApiClient == null) - Default.ApiClient = apiClient; + private string _dateTimeFormat = ISO8601_DATETIME_FORMAT; + private string _tempFolderPath = Path.GetTempPath(); - ApiClient = apiClient; - } + #endregion Private Members + + #region Constructors + + static Configuration() + { + _globalConfiguration = new GlobalConfiguration(); } - private Dictionary _defaultHeaderMap = new Dictionary(); + /// + /// Initializes a new instance of the class + /// + public Configuration() + { + UserAgent = "Swagger-Codegen/1.0.0/csharp"; + BasePath = "https://your-server.com/auth/v3"; + DefaultHeader = new ConcurrentDictionary(); + ApiKey = new ConcurrentDictionary(); + ApiKeyPrefix = new ConcurrentDictionary(); + + // Setting Timeout has side effects (forces ApiClient creation). + Timeout = 100000; + } /// - /// Gets or sets the default header. + /// Initializes a new instance of the class /// - public Dictionary DefaultHeader + public Configuration( + IDictionary defaultHeader, + IDictionary apiKey, + IDictionary apiKeyPrefix, + string basePath = "https://your-server.com/auth/v3") : this() { - get { return _defaultHeaderMap; } + if (string.IsNullOrWhiteSpace(basePath)) + throw new ArgumentException("The provided basePath is invalid.", "basePath"); + if (defaultHeader == null) + throw new ArgumentNullException("defaultHeader"); + if (apiKey == null) + throw new ArgumentNullException("apiKey"); + if (apiKeyPrefix == null) + throw new ArgumentNullException("apiKeyPrefix"); + + BasePath = basePath; + + foreach (var keyValuePair in defaultHeader) + { + DefaultHeader.Add(keyValuePair); + } - set + foreach (var keyValuePair in apiKey) + { + ApiKey.Add(keyValuePair); + } + + foreach (var keyValuePair in apiKeyPrefix) { - _defaultHeaderMap = value; + ApiKeyPrefix.Add(keyValuePair); } } /// - /// Add default header. + /// Initializes a new instance of the class with different settings /// - /// Header field name. - /// Header field value. - /// - public void AddDefaultHeader(string key, string value) + /// Api client + /// Dictionary of default HTTP header + /// Username + /// Password + /// accessToken + /// Dictionary of API key + /// Dictionary of API key prefix + /// Temp folder path + /// DateTime format string + /// HTTP connection timeout (in milliseconds) + /// HTTP user agent + [Obsolete("Use explicit object construction and setting of properties.", true)] + public Configuration( + // ReSharper disable UnusedParameter.Local + ApiClient apiClient = null, + IDictionary defaultHeader = null, + string username = null, + string password = null, + string accessToken = null, + IDictionary apiKey = null, + IDictionary apiKeyPrefix = null, + string tempFolderPath = null, + string dateTimeFormat = null, + int timeout = 100000, + string userAgent = "Swagger-Codegen/1.0.0/csharp" + // ReSharper restore UnusedParameter.Local + ) { - _defaultHeaderMap[key] = value; + } /// - /// Add Api Key Header. + /// Initializes a new instance of the Configuration class. /// - /// Api Key name. - /// Api Key value. - /// - public void AddApiKey(string key, string value) + /// Api client. + [Obsolete("This constructor caused unexpected sharing of static data. It is no longer supported.", true)] + // ReSharper disable once UnusedParameter.Local + public Configuration(ApiClient apiClient) { - ApiKey[key] = value; + } + #endregion Constructors + + + #region Properties + + private ApiClient _apiClient = null; /// - /// Sets the API key prefix. + /// Gets an instance of an ApiClient for this configuration /// - /// Api Key name. - /// Api Key value. - public void AddApiKeyPrefix(string key, string value) + public virtual ApiClient ApiClient { - ApiKeyPrefix[key] = value; + get + { + if (_apiClient == null) _apiClient = CreateApiClient(); + return _apiClient; + } } + private String _basePath = null; /// - /// Gets or sets the HTTP user agent. + /// Gets or sets the base path for API access. /// - /// Http user agent. - public String UserAgent { get; set; } + public virtual string BasePath { + get { return _basePath; } + set { + _basePath = value; + // pass-through to ApiClient if it's set. + if(_apiClient != null) { + _apiClient.RestClient.BaseUrl = new Uri(_basePath); + } + } + } /// - /// Gets or sets the username (HTTP basic authentication). + /// Gets or sets the default header. /// - /// The username. - public String Username { get; set; } + public virtual IDictionary DefaultHeader { get; set; } /// - /// Gets or sets the password (HTTP basic authentication). + /// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds. /// - /// The password. - public String Password { get; set; } + public virtual int Timeout + { + + get { return ApiClient.RestClient.Timeout; } + set { ApiClient.RestClient.Timeout = value; } + } /// - /// Gets or sets the access token for OAuth2 authentication. + /// Gets or sets the HTTP user agent. /// - /// The access token. - public String AccessToken { get; set; } + /// Http user agent. + public virtual string UserAgent { get; set; } /// - /// Gets or sets the API key based on the authentication name. + /// Gets or sets the username (HTTP basic authentication). /// - /// The API key. - public Dictionary ApiKey = new Dictionary(); + /// The username. + public virtual string Username { get; set; } /// - /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. + /// Gets or sets the password (HTTP basic authentication). /// - /// The prefix of the API key. - public Dictionary ApiKeyPrefix = new Dictionary(); + /// The password. + public virtual string Password { get; set; } /// - /// Get the API key with prefix. + /// Gets the API key with prefix. /// /// API key identifier (authentication scheme). /// API key with prefix. - public string GetApiKeyWithPrefix (string apiKeyIdentifier) + public string GetApiKeyWithPrefix(string apiKeyIdentifier) { var apiKeyValue = ""; ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); @@ -243,48 +287,47 @@ public string GetApiKeyWithPrefix (string apiKeyIdentifier) return apiKeyValue; } - private string _tempFolderPath; + /// + /// Gets or sets the access token for OAuth2 authentication. + /// + /// The access token. + public virtual string AccessToken { get; set; } /// /// Gets or sets the temporary folder path to store the files downloaded from the server. /// /// Folder path. - public String TempFolderPath + public virtual string TempFolderPath { - get - { - // default to Path.GetTempPath() if _tempFolderPath is not set - if (String.IsNullOrEmpty(_tempFolderPath)) - { - _tempFolderPath = Path.GetTempPath(); - } - return _tempFolderPath; - } + get { return _tempFolderPath; } set { - if (String.IsNullOrEmpty(value)) + if (string.IsNullOrEmpty(value)) { - _tempFolderPath = value; + // Possible breaking change since swagger-codegen 2.2.1, enforce a valid temporary path on set. + _tempFolderPath = Path.GetTempPath(); return; } // create the directory if it does not exist if (!Directory.Exists(value)) + { Directory.CreateDirectory(value); + } // check if the path contains directory separator at the end if (value[value.Length - 1] == Path.DirectorySeparatorChar) + { _tempFolderPath = value; + } else - _tempFolderPath = value + Path.DirectorySeparatorChar; + { + _tempFolderPath = value + Path.DirectorySeparatorChar; + } } } - private const string ISO8601_DATETIME_FORMAT = "o"; - - private string _dateTimeFormat = ISO8601_DATETIME_FORMAT; - /// /// Gets or sets the the date time format used when serializing in the ApiClient /// By default, it's set to ISO 8601 - "o", for others see: @@ -293,12 +336,9 @@ public String TempFolderPath /// No validation is done to ensure that the string you're providing is valid /// /// The DateTimeFormat string - public String DateTimeFormat + public virtual string DateTimeFormat { - get - { - return _dateTimeFormat; - } + get { return _dateTimeFormat; } set { if (string.IsNullOrEmpty(value)) @@ -314,21 +354,100 @@ public String DateTimeFormat } } + /// + /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. + /// + /// The prefix of the API key. + public virtual IDictionary ApiKeyPrefix + { + get { return _apiKeyPrefix; } + set + { + if (value == null) + { + throw new InvalidOperationException("ApiKeyPrefix collection may not be null."); + } + _apiKeyPrefix = value; + } + } + + /// + /// Gets or sets the API key based on the authentication name. + /// + /// The API key. + public virtual IDictionary ApiKey + { + get { return _apiKey; } + set + { + if (value == null) + { + throw new InvalidOperationException("ApiKey collection may not be null."); + } + _apiKey = value; + } + } + + #endregion Properties + + #region Methods + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + DefaultHeader[key] = value; + } + + /// + /// Creates a new based on this instance. + /// + /// + public ApiClient CreateApiClient() + { + return new ApiClient(BasePath) { Configuration = this }; + } + + /// /// Returns a string with essential information for debugging. /// public static String ToDebugReport() { String report = "C# SDK (Genesys.Internal.Authentication) Debug Report:\n"; - report += " OS: " + Environment.OSVersion + "\n"; - report += " .NET Framework Version: " + Assembly - .GetExecutingAssembly() - .GetReferencedAssemblies() - .Where(x => x.Name == "System.Core").First().Version.ToString() + "\n"; + report += " OS: " + System.Environment.OSVersion + "\n"; + report += " .NET Framework Version: " + System.Environment.Version + "\n"; report += " Version of the API: 9.0.000.16.1235\n"; report += " SDK Package Version: 1.0.0\n"; return report; } + + /// + /// Add Api Key Header. + /// + /// Api Key name. + /// Api Key value. + /// + public void AddApiKey(string key, string value) + { + ApiKey[key] = value; + } + + /// + /// Sets the API key prefix. + /// + /// Api Key name. + /// Api Key value. + public void AddApiKeyPrefix(string key, string value) + { + ApiKeyPrefix[key] = value; + } + + #endregion Methods } } diff --git a/src/Genesys.Internal.Authentication/Client/GlobalConfiguration.cs b/src/Genesys.Internal.Authentication/Client/GlobalConfiguration.cs new file mode 100644 index 0000000..e156919 --- /dev/null +++ b/src/Genesys.Internal.Authentication/Client/GlobalConfiguration.cs @@ -0,0 +1,34 @@ +/* + * Authentication API + * + * Authentication API + * + * OpenAPI spec version: 9.0.000.16.1235 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using System; +using System.Reflection; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; + +namespace Genesys.Internal.Authentication.Client +{ + /// + /// provides a compile-time extension point for globally configuring + /// API Clients. + /// + /// + /// A customized implementation via partial class may reside in another file and may + /// be excluded from automatic generation via a .swagger-codegen-ignore file. + /// + public partial class GlobalConfiguration : Configuration + { + + } +} \ No newline at end of file diff --git a/src/Genesys.Internal.Authentication/Client/IReadableConfiguration.cs b/src/Genesys.Internal.Authentication/Client/IReadableConfiguration.cs new file mode 100644 index 0000000..a31e6d4 --- /dev/null +++ b/src/Genesys.Internal.Authentication/Client/IReadableConfiguration.cs @@ -0,0 +1,94 @@ +/* + * Authentication API + * + * Authentication API + * + * OpenAPI spec version: 9.0.000.16.1235 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + + +using System.Collections.Generic; + +namespace Genesys.Internal.Authentication.Client +{ + /// + /// Represents a readable-only configuration contract. + /// + public interface IReadableConfiguration + { + /// + /// Gets the access token. + /// + /// Access token. + string AccessToken { get; } + + /// + /// Gets the API key. + /// + /// API key. + IDictionary ApiKey { get; } + + /// + /// Gets the API key prefix. + /// + /// API key prefix. + IDictionary ApiKeyPrefix { get; } + + /// + /// Gets the base path. + /// + /// Base path. + string BasePath { get; } + + /// + /// Gets the date time format. + /// + /// Date time foramt. + string DateTimeFormat { get; } + + /// + /// Gets the default header. + /// + /// Default header. + IDictionary DefaultHeader { get; } + + /// + /// Gets the temp folder path. + /// + /// Temp folder path. + string TempFolderPath { get; } + + /// + /// Gets the HTTP connection timeout (in milliseconds) + /// + /// HTTP connection timeout. + int Timeout { get; } + + /// + /// Gets the user agent. + /// + /// User agent. + string UserAgent { get; } + + /// + /// Gets the username. + /// + /// Username. + string Username { get; } + + /// + /// Gets the password. + /// + /// Password. + string Password { get; } + + /// + /// Gets the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. + string GetApiKeyWithPrefix(string apiKeyIdentifier); + } +} diff --git a/src/Genesys.Internal.Authentication/Genesys.Internal.Authentication.csproj b/src/Genesys.Internal.Authentication/Genesys.Internal.Authentication.csproj index b3e536b..f1a73b2 100644 --- a/src/Genesys.Internal.Authentication/Genesys.Internal.Authentication.csproj +++ b/src/Genesys.Internal.Authentication/Genesys.Internal.Authentication.csproj @@ -12,7 +12,7 @@ OpenAPI spec version: 9.0.000.16.1235 Debug AnyCPU - {150DE342-6AAD-430B-8DD1-24DFC4E40B74} + {47D77E17-DAA1-496A-A54F-9AF20C8C3B08} Library Properties Genesys.Internal.Authentication @@ -53,6 +53,12 @@ OpenAPI spec version: 9.0.000.16.1235 ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll ..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + $(SolutionDir)\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll + ..\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll + ..\..\packages\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll + ..\..\vendor\JsonSubTypes.1.2.0\lib\net45\JsonSubTypes.dll + $(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll ..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll diff --git a/src/Genesys.Internal.Authentication/Genesys.Internal.Authentication.nuspec b/src/Genesys.Internal.Authentication/Genesys.Internal.Authentication.nuspec index 154b80a..93f28ce 100644 --- a/src/Genesys.Internal.Authentication/Genesys.Internal.Authentication.nuspec +++ b/src/Genesys.Internal.Authentication/Genesys.Internal.Authentication.nuspec @@ -25,6 +25,7 @@ + diff --git a/src/Genesys.Internal.Authentication/Model/ApiResponse.cs b/src/Genesys.Internal.Authentication/Model/ApiResponse.cs index 3260e76..e99ecc9 100644 --- a/src/Genesys.Internal.Authentication/Model/ApiResponse.cs +++ b/src/Genesys.Internal.Authentication/Model/ApiResponse.cs @@ -110,45 +110,43 @@ public string ToJson() /// /// Returns true if objects are equal /// - /// Object to be compared + /// Object to be compared /// Boolean - public override bool Equals(object obj) + public override bool Equals(object input) { - // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as ApiResponse); + return this.Equals(input as ApiResponse); } /// /// Returns true if ApiResponse instances are equal /// - /// Instance of ApiResponse to be compared + /// Instance of ApiResponse to be compared /// Boolean - public bool Equals(ApiResponse other) + public bool Equals(ApiResponse input) { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) + if (input == null) return false; return ( - this.Data == other.Data || - this.Data != null && - this.Data.Equals(other.Data) + this.Data == input.Data || + (this.Data != null && + this.Data.Equals(input.Data)) ) && ( - this.Errors == other.Errors || - this.Errors != null && - this.Errors.Equals(other.Errors) + this.Errors == input.Errors || + (this.Errors != null && + this.Errors.Equals(input.Errors)) ) && ( - this.Path == other.Path || - this.Path != null && - this.Path.Equals(other.Path) + this.Path == input.Path || + (this.Path != null && + this.Path.Equals(input.Path)) ) && ( - this.Status == other.Status || - this.Status != null && - this.Status.Equals(other.Status) + this.Status == input.Status || + (this.Status != null && + this.Status.Equals(input.Status)) ); } @@ -158,20 +156,18 @@ public bool Equals(ApiResponse other) /// Hash code public override int GetHashCode() { - // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { - int hash = 41; - // Suitable nullity checks etc, of course :) + int hashCode = 41; if (this.Data != null) - hash = hash * 59 + this.Data.GetHashCode(); + hashCode = hashCode * 59 + this.Data.GetHashCode(); if (this.Errors != null) - hash = hash * 59 + this.Errors.GetHashCode(); + hashCode = hashCode * 59 + this.Errors.GetHashCode(); if (this.Path != null) - hash = hash * 59 + this.Path.GetHashCode(); + hashCode = hashCode * 59 + this.Path.GetHashCode(); if (this.Status != null) - hash = hash * 59 + this.Status.GetHashCode(); - return hash; + hashCode = hashCode * 59 + this.Status.GetHashCode(); + return hashCode; } } diff --git a/src/Genesys.Internal.Authentication/Model/AuthSchemeLookupData.cs b/src/Genesys.Internal.Authentication/Model/AuthSchemeLookupData.cs index 06fef6c..950377c 100644 --- a/src/Genesys.Internal.Authentication/Model/AuthSchemeLookupData.cs +++ b/src/Genesys.Internal.Authentication/Model/AuthSchemeLookupData.cs @@ -100,35 +100,33 @@ public string ToJson() /// /// Returns true if objects are equal /// - /// Object to be compared + /// Object to be compared /// Boolean - public override bool Equals(object obj) + public override bool Equals(object input) { - // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as AuthSchemeLookupData); + return this.Equals(input as AuthSchemeLookupData); } /// /// Returns true if AuthSchemeLookupData instances are equal /// - /// Instance of AuthSchemeLookupData to be compared + /// Instance of AuthSchemeLookupData to be compared /// Boolean - public bool Equals(AuthSchemeLookupData other) + public bool Equals(AuthSchemeLookupData input) { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) + if (input == null) return false; return ( - this.UserName == other.UserName || - this.UserName != null && - this.UserName.Equals(other.UserName) + this.UserName == input.UserName || + (this.UserName != null && + this.UserName.Equals(input.UserName)) ) && ( - this.Tenant == other.Tenant || - this.Tenant != null && - this.Tenant.Equals(other.Tenant) + this.Tenant == input.Tenant || + (this.Tenant != null && + this.Tenant.Equals(input.Tenant)) ); } @@ -138,16 +136,14 @@ public bool Equals(AuthSchemeLookupData other) /// Hash code public override int GetHashCode() { - // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { - int hash = 41; - // Suitable nullity checks etc, of course :) + int hashCode = 41; if (this.UserName != null) - hash = hash * 59 + this.UserName.GetHashCode(); + hashCode = hashCode * 59 + this.UserName.GetHashCode(); if (this.Tenant != null) - hash = hash * 59 + this.Tenant.GetHashCode(); - return hash; + hashCode = hashCode * 59 + this.Tenant.GetHashCode(); + return hashCode; } } diff --git a/src/Genesys.Internal.Authentication/Model/ChangePasswordOperation.cs b/src/Genesys.Internal.Authentication/Model/ChangePasswordOperation.cs index 70d36ab..1272072 100644 --- a/src/Genesys.Internal.Authentication/Model/ChangePasswordOperation.cs +++ b/src/Genesys.Internal.Authentication/Model/ChangePasswordOperation.cs @@ -117,40 +117,38 @@ public string ToJson() /// /// Returns true if objects are equal /// - /// Object to be compared + /// Object to be compared /// Boolean - public override bool Equals(object obj) + public override bool Equals(object input) { - // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as ChangePasswordOperation); + return this.Equals(input as ChangePasswordOperation); } /// /// Returns true if ChangePasswordOperation instances are equal /// - /// Instance of ChangePasswordOperation to be compared + /// Instance of ChangePasswordOperation to be compared /// Boolean - public bool Equals(ChangePasswordOperation other) + public bool Equals(ChangePasswordOperation input) { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) + if (input == null) return false; return ( - this.UserName == other.UserName || - this.UserName != null && - this.UserName.Equals(other.UserName) + this.UserName == input.UserName || + (this.UserName != null && + this.UserName.Equals(input.UserName)) ) && ( - this.OldPassword == other.OldPassword || - this.OldPassword != null && - this.OldPassword.Equals(other.OldPassword) + this.OldPassword == input.OldPassword || + (this.OldPassword != null && + this.OldPassword.Equals(input.OldPassword)) ) && ( - this.NewPassword == other.NewPassword || - this.NewPassword != null && - this.NewPassword.Equals(other.NewPassword) + this.NewPassword == input.NewPassword || + (this.NewPassword != null && + this.NewPassword.Equals(input.NewPassword)) ); } @@ -160,18 +158,16 @@ public bool Equals(ChangePasswordOperation other) /// Hash code public override int GetHashCode() { - // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { - int hash = 41; - // Suitable nullity checks etc, of course :) + int hashCode = 41; if (this.UserName != null) - hash = hash * 59 + this.UserName.GetHashCode(); + hashCode = hashCode * 59 + this.UserName.GetHashCode(); if (this.OldPassword != null) - hash = hash * 59 + this.OldPassword.GetHashCode(); + hashCode = hashCode * 59 + this.OldPassword.GetHashCode(); if (this.NewPassword != null) - hash = hash * 59 + this.NewPassword.GetHashCode(); - return hash; + hashCode = hashCode * 59 + this.NewPassword.GetHashCode(); + return hashCode; } } diff --git a/src/Genesys.Internal.Authentication/Model/CloudUserDetails.cs b/src/Genesys.Internal.Authentication/Model/CloudUserDetails.cs index 48f8aad..a9d4db7 100644 --- a/src/Genesys.Internal.Authentication/Model/CloudUserDetails.cs +++ b/src/Genesys.Internal.Authentication/Model/CloudUserDetails.cs @@ -152,60 +152,58 @@ public string ToJson() /// /// Returns true if objects are equal /// - /// Object to be compared + /// Object to be compared /// Boolean - public override bool Equals(object obj) + public override bool Equals(object input) { - // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as CloudUserDetails); + return this.Equals(input as CloudUserDetails); } /// /// Returns true if CloudUserDetails instances are equal /// - /// Instance of CloudUserDetails to be compared + /// Instance of CloudUserDetails to be compared /// Boolean - public bool Equals(CloudUserDetails other) + public bool Equals(CloudUserDetails input) { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) + if (input == null) return false; return ( - this.Authorities == other.Authorities || - this.Authorities != null && - this.Authorities.Equals(other.Authorities) + this.Authorities == input.Authorities || + (this.Authorities != null && + this.Authorities.Equals(input.Authorities)) ) && ( - this.CmeUserName == other.CmeUserName || - this.CmeUserName != null && - this.CmeUserName.Equals(other.CmeUserName) + this.CmeUserName == input.CmeUserName || + (this.CmeUserName != null && + this.CmeUserName.Equals(input.CmeUserName)) ) && ( - this.ContactCenterId == other.ContactCenterId || - this.ContactCenterId != null && - this.ContactCenterId.Equals(other.ContactCenterId) + this.ContactCenterId == input.ContactCenterId || + (this.ContactCenterId != null && + this.ContactCenterId.Equals(input.ContactCenterId)) ) && ( - this.Dbid == other.Dbid || - this.Dbid != null && - this.Dbid.Equals(other.Dbid) + this.Dbid == input.Dbid || + (this.Dbid != null && + this.Dbid.Equals(input.Dbid)) ) && ( - this.EnvironmentId == other.EnvironmentId || - this.EnvironmentId != null && - this.EnvironmentId.Equals(other.EnvironmentId) + this.EnvironmentId == input.EnvironmentId || + (this.EnvironmentId != null && + this.EnvironmentId.Equals(input.EnvironmentId)) ) && ( - this.LoginName == other.LoginName || - this.LoginName != null && - this.LoginName.Equals(other.LoginName) + this.LoginName == input.LoginName || + (this.LoginName != null && + this.LoginName.Equals(input.LoginName)) ) && ( - this.Username == other.Username || - this.Username != null && - this.Username.Equals(other.Username) + this.Username == input.Username || + (this.Username != null && + this.Username.Equals(input.Username)) ); } @@ -215,26 +213,24 @@ public bool Equals(CloudUserDetails other) /// Hash code public override int GetHashCode() { - // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { - int hash = 41; - // Suitable nullity checks etc, of course :) + int hashCode = 41; if (this.Authorities != null) - hash = hash * 59 + this.Authorities.GetHashCode(); + hashCode = hashCode * 59 + this.Authorities.GetHashCode(); if (this.CmeUserName != null) - hash = hash * 59 + this.CmeUserName.GetHashCode(); + hashCode = hashCode * 59 + this.CmeUserName.GetHashCode(); if (this.ContactCenterId != null) - hash = hash * 59 + this.ContactCenterId.GetHashCode(); + hashCode = hashCode * 59 + this.ContactCenterId.GetHashCode(); if (this.Dbid != null) - hash = hash * 59 + this.Dbid.GetHashCode(); + hashCode = hashCode * 59 + this.Dbid.GetHashCode(); if (this.EnvironmentId != null) - hash = hash * 59 + this.EnvironmentId.GetHashCode(); + hashCode = hashCode * 59 + this.EnvironmentId.GetHashCode(); if (this.LoginName != null) - hash = hash * 59 + this.LoginName.GetHashCode(); + hashCode = hashCode * 59 + this.LoginName.GetHashCode(); if (this.Username != null) - hash = hash * 59 + this.Username.GetHashCode(); - return hash; + hashCode = hashCode * 59 + this.Username.GetHashCode(); + return hashCode; } } diff --git a/src/Genesys.Internal.Authentication/Model/DefaultOAuth2AccessToken.cs b/src/Genesys.Internal.Authentication/Model/DefaultOAuth2AccessToken.cs index e383410..8d44487 100644 --- a/src/Genesys.Internal.Authentication/Model/DefaultOAuth2AccessToken.cs +++ b/src/Genesys.Internal.Authentication/Model/DefaultOAuth2AccessToken.cs @@ -111,50 +111,48 @@ public string ToJson() /// /// Returns true if objects are equal /// - /// Object to be compared + /// Object to be compared /// Boolean - public override bool Equals(object obj) + public override bool Equals(object input) { - // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as DefaultOAuth2AccessToken); + return this.Equals(input as DefaultOAuth2AccessToken); } /// /// Returns true if DefaultOAuth2AccessToken instances are equal /// - /// Instance of DefaultOAuth2AccessToken to be compared + /// Instance of DefaultOAuth2AccessToken to be compared /// Boolean - public bool Equals(DefaultOAuth2AccessToken other) + public bool Equals(DefaultOAuth2AccessToken input) { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) + if (input == null) return false; return ( - this.AccessToken == other.AccessToken || - this.AccessToken != null && - this.AccessToken.Equals(other.AccessToken) + this.AccessToken == input.AccessToken || + (this.AccessToken != null && + this.AccessToken.Equals(input.AccessToken)) ) && ( - this.ExpiresIn == other.ExpiresIn || - this.ExpiresIn != null && - this.ExpiresIn.Equals(other.ExpiresIn) + this.ExpiresIn == input.ExpiresIn || + (this.ExpiresIn != null && + this.ExpiresIn.Equals(input.ExpiresIn)) ) && ( - this.RefreshToken == other.RefreshToken || - this.RefreshToken != null && - this.RefreshToken.Equals(other.RefreshToken) + this.RefreshToken == input.RefreshToken || + (this.RefreshToken != null && + this.RefreshToken.Equals(input.RefreshToken)) ) && ( - this.Scope == other.Scope || - this.Scope != null && - this.Scope.Equals(other.Scope) + this.Scope == input.Scope || + (this.Scope != null && + this.Scope.Equals(input.Scope)) ) && ( - this.TokenType == other.TokenType || - this.TokenType != null && - this.TokenType.Equals(other.TokenType) + this.TokenType == input.TokenType || + (this.TokenType != null && + this.TokenType.Equals(input.TokenType)) ); } @@ -164,22 +162,20 @@ public bool Equals(DefaultOAuth2AccessToken other) /// Hash code public override int GetHashCode() { - // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { - int hash = 41; - // Suitable nullity checks etc, of course :) + int hashCode = 41; if (this.AccessToken != null) - hash = hash * 59 + this.AccessToken.GetHashCode(); + hashCode = hashCode * 59 + this.AccessToken.GetHashCode(); if (this.ExpiresIn != null) - hash = hash * 59 + this.ExpiresIn.GetHashCode(); + hashCode = hashCode * 59 + this.ExpiresIn.GetHashCode(); if (this.RefreshToken != null) - hash = hash * 59 + this.RefreshToken.GetHashCode(); + hashCode = hashCode * 59 + this.RefreshToken.GetHashCode(); if (this.Scope != null) - hash = hash * 59 + this.Scope.GetHashCode(); + hashCode = hashCode * 59 + this.Scope.GetHashCode(); if (this.TokenType != null) - hash = hash * 59 + this.TokenType.GetHashCode(); - return hash; + hashCode = hashCode * 59 + this.TokenType.GetHashCode(); + return hashCode; } } diff --git a/src/Genesys.Internal.Authentication/Model/ErrorResponse.cs b/src/Genesys.Internal.Authentication/Model/ErrorResponse.cs index 66791b5..fea664c 100644 --- a/src/Genesys.Internal.Authentication/Model/ErrorResponse.cs +++ b/src/Genesys.Internal.Authentication/Model/ErrorResponse.cs @@ -79,35 +79,33 @@ public string ToJson() /// /// Returns true if objects are equal /// - /// Object to be compared + /// Object to be compared /// Boolean - public override bool Equals(object obj) + public override bool Equals(object input) { - // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as ErrorResponse); + return this.Equals(input as ErrorResponse); } /// /// Returns true if ErrorResponse instances are equal /// - /// Instance of ErrorResponse to be compared + /// Instance of ErrorResponse to be compared /// Boolean - public bool Equals(ErrorResponse other) + public bool Equals(ErrorResponse input) { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) + if (input == null) return false; return ( - this.Error == other.Error || - this.Error != null && - this.Error.Equals(other.Error) + this.Error == input.Error || + (this.Error != null && + this.Error.Equals(input.Error)) ) && ( - this.ErrorDescription == other.ErrorDescription || - this.ErrorDescription != null && - this.ErrorDescription.Equals(other.ErrorDescription) + this.ErrorDescription == input.ErrorDescription || + (this.ErrorDescription != null && + this.ErrorDescription.Equals(input.ErrorDescription)) ); } @@ -117,16 +115,14 @@ public bool Equals(ErrorResponse other) /// Hash code public override int GetHashCode() { - // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { - int hash = 41; - // Suitable nullity checks etc, of course :) + int hashCode = 41; if (this.Error != null) - hash = hash * 59 + this.Error.GetHashCode(); + hashCode = hashCode * 59 + this.Error.GetHashCode(); if (this.ErrorDescription != null) - hash = hash * 59 + this.ErrorDescription.GetHashCode(); - return hash; + hashCode = hashCode * 59 + this.ErrorDescription.GetHashCode(); + return hashCode; } } diff --git a/src/Genesys.Internal.Authentication/Model/ResponseStatus.cs b/src/Genesys.Internal.Authentication/Model/ResponseStatus.cs index db3715e..b5d1370 100644 --- a/src/Genesys.Internal.Authentication/Model/ResponseStatus.cs +++ b/src/Genesys.Internal.Authentication/Model/ResponseStatus.cs @@ -88,40 +88,38 @@ public string ToJson() /// /// Returns true if objects are equal /// - /// Object to be compared + /// Object to be compared /// Boolean - public override bool Equals(object obj) + public override bool Equals(object input) { - // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as ResponseStatus); + return this.Equals(input as ResponseStatus); } /// /// Returns true if ResponseStatus instances are equal /// - /// Instance of ResponseStatus to be compared + /// Instance of ResponseStatus to be compared /// Boolean - public bool Equals(ResponseStatus other) + public bool Equals(ResponseStatus input) { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) + if (input == null) return false; return ( - this.Code == other.Code || - this.Code != null && - this.Code.Equals(other.Code) + this.Code == input.Code || + (this.Code != null && + this.Code.Equals(input.Code)) ) && ( - this.Detail == other.Detail || - this.Detail != null && - this.Detail.Equals(other.Detail) + this.Detail == input.Detail || + (this.Detail != null && + this.Detail.Equals(input.Detail)) ) && ( - this.Message == other.Message || - this.Message != null && - this.Message.Equals(other.Message) + this.Message == input.Message || + (this.Message != null && + this.Message.Equals(input.Message)) ); } @@ -131,18 +129,16 @@ public bool Equals(ResponseStatus other) /// Hash code public override int GetHashCode() { - // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { - int hash = 41; - // Suitable nullity checks etc, of course :) + int hashCode = 41; if (this.Code != null) - hash = hash * 59 + this.Code.GetHashCode(); + hashCode = hashCode * 59 + this.Code.GetHashCode(); if (this.Detail != null) - hash = hash * 59 + this.Detail.GetHashCode(); + hashCode = hashCode * 59 + this.Detail.GetHashCode(); if (this.Message != null) - hash = hash * 59 + this.Message.GetHashCode(); - return hash; + hashCode = hashCode * 59 + this.Message.GetHashCode(); + return hashCode; } } diff --git a/src/Genesys.Internal.Authentication/Model/UserRole.cs b/src/Genesys.Internal.Authentication/Model/UserRole.cs index 573ba42..257986c 100644 --- a/src/Genesys.Internal.Authentication/Model/UserRole.cs +++ b/src/Genesys.Internal.Authentication/Model/UserRole.cs @@ -70,30 +70,28 @@ public string ToJson() /// /// Returns true if objects are equal /// - /// Object to be compared + /// Object to be compared /// Boolean - public override bool Equals(object obj) + public override bool Equals(object input) { - // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as UserRole); + return this.Equals(input as UserRole); } /// /// Returns true if UserRole instances are equal /// - /// Instance of UserRole to be compared + /// Instance of UserRole to be compared /// Boolean - public bool Equals(UserRole other) + public bool Equals(UserRole input) { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) + if (input == null) return false; return ( - this.Name == other.Name || - this.Name != null && - this.Name.Equals(other.Name) + this.Name == input.Name || + (this.Name != null && + this.Name.Equals(input.Name)) ); } @@ -103,14 +101,12 @@ public bool Equals(UserRole other) /// Hash code public override int GetHashCode() { - // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { - int hash = 41; - // Suitable nullity checks etc, of course :) + int hashCode = 41; if (this.Name != null) - hash = hash * 59 + this.Name.GetHashCode(); - return hash; + hashCode = hashCode * 59 + this.Name.GetHashCode(); + return hashCode; } } diff --git a/src/Genesys.Internal.Authentication/packages.config b/src/Genesys.Internal.Authentication/packages.config index 351ef13..3caf34e 100644 --- a/src/Genesys.Internal.Authentication/packages.config +++ b/src/Genesys.Internal.Authentication/packages.config @@ -2,4 +2,5 @@ +