/*
* Service Collaborateur API
*
* Api du service Collaborateur, utilisée pour récupérer les données des collaborateurs d'Apside
*
* OpenAPI spec version: 1.1.2
* Contact: lilian.gayet@apside-groupe.com
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.Reflection;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace IO.Swagger.ClientCollaborateur
{
///
/// Represents a set of configuration settings
///
public class Configuration : IReadableConfiguration
{
#region Constants
///
/// Version of the package.
///
/// Version of the package.
public const string Version = "1.0.0";
///
/// Identifier for ISO 8601 DateTime Format
///
/// 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) =>
{
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 default Configuration.
///
/// Configuration.
public static Configuration Default
{
get { return _globalConfiguration; }
set
{
lock (GlobalConfigSync)
{
_globalConfiguration = value;
}
}
}
#endregion Static Members
#region Private Members
///
/// Gets or sets the API key based on the authentication name.
///
/// The API key.
private IDictionary _apiKey = null;
///
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
///
/// The prefix of the API key.
private IDictionary _apiKeyPrefix = null;
private string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
private string _tempFolderPath = Path.GetTempPath();
#endregion Private Members
#region Constructors
static Configuration()
{
_globalConfiguration = new GlobalConfiguration();
}
///
/// Initializes a new instance of the class
///
public Configuration()
{
UserAgent = "Swagger-Codegen/1.0.0/csharp";
BasePath = "https://localhost:3000";
DefaultHeader = new ConcurrentDictionary();
ApiKey = new ConcurrentDictionary();
ApiKeyPrefix = new ConcurrentDictionary();
Timeout = 100000;
}
///
/// Initializes a new instance of the class
///
public Configuration(
IDictionary defaultHeader,
IDictionary apiKey,
IDictionary apiKeyPrefix,
string basePath = "https://virtserver.swaggerhub.com/LilianG/Service-Collaborateur/1.1.1") : this()
{
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);
}
foreach (var keyValuePair in apiKey)
{
ApiKey.Add(keyValuePair);
}
foreach (var keyValuePair in apiKeyPrefix)
{
ApiKeyPrefix.Add(keyValuePair);
}
}
///
/// Initializes a new instance of the 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
[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
)
{
}
///
/// Initializes a new instance of the Configuration class.
///
/// 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)
{
}
#endregion Constructors
#region Properties
private ApiClient _apiClient = null;
///
/// Gets an instance of an ApiClient for this configuration
///
public virtual ApiClient ApiClient
{
get
{
if (_apiClient == null) _apiClient = CreateApiClient();
return _apiClient;
}
}
private String _basePath = null;
///
/// Gets or sets the base path for API access.
///
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 default header.
///
public virtual IDictionary DefaultHeader { get; set; }
private int _timeout = 100000;
///
/// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds.
///
public virtual int Timeout
{
get
{
if (_apiClient == null)
{
return _timeout;
}
else
{
return ApiClient.RestClient.Timeout;
}
}
set
{
_timeout = value;
if (_apiClient != null)
{
ApiClient.RestClient.Timeout = _timeout;
}
}
}
///
/// Gets or sets the HTTP user agent.
///
/// Http user agent.
public virtual string UserAgent { get; set; }
///
/// Gets or sets the username (HTTP basic authentication).
///
/// The username.
public virtual string Username { get; set; }
///
/// Gets or sets the password (HTTP basic authentication).
///
/// The password.
public virtual string Password { get; set; }
///
/// Gets the API key with prefix.
///
/// API key identifier (authentication scheme).
/// API key with prefix.
public string GetApiKeyWithPrefix(string apiKeyIdentifier)
{
var apiKeyValue = "";
ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
var apiKeyPrefix = "";
if (ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
return apiKeyPrefix + " " + apiKeyValue;
else
return apiKeyValue;
}
///
/// 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 virtual string TempFolderPath
{
get { return _tempFolderPath; }
set
{
if (string.IsNullOrEmpty(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;
}
}
}
///
/// 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:
/// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx
/// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
/// No validation is done to ensure that the string you're providing is valid
///
/// The DateTimeFormat string
public virtual string DateTimeFormat
{
get { return _dateTimeFormat; }
set
{
if (string.IsNullOrEmpty(value))
{
// Never allow a blank or null string, go back to the default
_dateTimeFormat = ISO8601_DATETIME_FORMAT;
return;
}
// Caution, no validation when you choose date time format other than ISO 8601
// Take a look at the above links
_dateTimeFormat = value;
}
}
///
/// 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 (IO.Swagger) Debug Report:\n";
report += " OS: " + System.Environment.OSVersion + "\n";
report += " .NET Framework Version: " + System.Environment.Version + "\n";
report += " Version of the API: 1.1.2\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
}
}