< Summary

Information
Class: /home/wethinkcode/student_work/csharp/GroupProject/super-cool-group/weshare-qa/GeneratedApiCode/src/Applications.WeShare.Swagger/Client/ApiClient.cs
Assembly: Default
File(s): /home/wethinkcode/student_work/csharp/GroupProject/super-cool-group/weshare-qa/GeneratedApiCode/src/Applications.WeShare.Swagger/Client/ApiClient.cs
Line coverage
42%
Covered lines: 196
Uncovered lines: 264
Coverable lines: 460
Total lines: 833
Line coverage: 42.6%
Branch coverage
40%
Covered branches: 73
Total branches: 180
Branch coverage: 40.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

/home/wethinkcode/student_work/csharp/GroupProject/super-cool-group/weshare-qa/GeneratedApiCode/src/Applications.WeShare.Swagger/Client/ApiClient.cs

#LineLine coverage
 1/*
 2 * WeShare API
 3 *
 4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 5 *
 6 * The version of the OpenAPI document: 1.0
 7 * Generated by: https://github.com/openapitools/openapi-generator.git
 8 */
 9
 10
 11using System;
 12using System.Collections;
 13using System.Collections.Generic;
 14using System.Globalization;
 15using System.IO;
 16using System.Linq;
 17using System.Net;
 18using System.Reflection;
 19using System.Runtime.Serialization;
 20using System.Runtime.Serialization.Formatters;
 21using System.Text;
 22using System.Threading;
 23using System.Text.RegularExpressions;
 24using System.Threading.Tasks;
 25using Newtonsoft.Json;
 26using Newtonsoft.Json.Serialization;
 27using RestSharp;
 28using RestSharp.Serializers;
 29using RestSharpMethod = RestSharp.Method;
 30using Polly;
 31
 32namespace Applications.WeShare.Swagger.Client
 33{
 34    /// <summary>
 35    /// Allows RestSharp to Serialize/Deserialize JSON using our custom logic, but only when ContentType is JSON.
 36    /// </summary>
 37    internal class CustomJsonCodec : IRestSerializer, ISerializer, IDeserializer
 38    {
 39        private readonly IReadableConfiguration _configuration;
 040        private static readonly string _contentType = "application/json";
 7541        private readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
 7542        {
 7543            // OpenAPI generated types generally hide default constructors.
 7544            ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
 7545            ContractResolver = new DefaultContractResolver
 7546            {
 7547                NamingStrategy = new CamelCaseNamingStrategy
 7548                {
 7549                    OverrideSpecifiedNames = false
 7550                }
 7551            }
 7552        };
 53
 054        public CustomJsonCodec(IReadableConfiguration configuration)
 055        {
 056            _configuration = configuration;
 057        }
 58
 7559        public CustomJsonCodec(JsonSerializerSettings serializerSettings, IReadableConfiguration configuration)
 7560        {
 7561            _serializerSettings = serializerSettings;
 7562            _configuration = configuration;
 7563        }
 64
 65        /// <summary>
 66        /// Serialize the object into a JSON string.
 67        /// </summary>
 68        /// <param name="obj">Object to be serialized.</param>
 69        /// <returns>A JSON string.</returns>
 70        public string Serialize(object obj)
 771        {
 772            if (obj != null && obj is Applications.WeShare.Swagger.Model.AbstractOpenAPISchema)
 073            {
 74                // the object to be serialized is an oneOf/anyOf schema
 075                return ((Applications.WeShare.Swagger.Model.AbstractOpenAPISchema)obj).ToJson();
 76            }
 77            else
 778            {
 779                return JsonConvert.SerializeObject(obj, _serializerSettings);
 80            }
 781        }
 82
 783        public string Serialize(Parameter bodyParameter) => Serialize(bodyParameter.Value);
 84
 85        public T Deserialize<T>(RestResponse response)
 3486        {
 3487            var result = (T)Deserialize(response, typeof(T));
 1488            return result;
 1489        }
 90
 91        /// <summary>
 92        /// Deserialize the JSON string into a proper object.
 93        /// </summary>
 94        /// <param name="response">The HTTP response.</param>
 95        /// <param name="type">Object type.</param>
 96        /// <returns>Object representation of the JSON string.</returns>
 97        internal object Deserialize(RestResponse response, Type type)
 3498        {
 3499            if (type == typeof(byte[])) // return byte array
 0100            {
 0101                return response.RawBytes;
 102            }
 103
 104            // TODO: ? if (type.IsAssignableFrom(typeof(Stream)))
 34105            if (type == typeof(Stream))
 0106            {
 0107                var bytes = response.RawBytes;
 0108                if (response.Headers != null)
 0109                {
 0110                    var filePath = string.IsNullOrEmpty(_configuration.TempFolderPath)
 0111                        ? Path.GetTempPath()
 0112                        : _configuration.TempFolderPath;
 0113                    var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$");
 0114                    foreach (var header in response.Headers)
 0115                    {
 0116                        var match = regex.Match(header.ToString());
 0117                        if (match.Success)
 0118                        {
 0119                            string fileName = filePath + ClientUtils.SanitizeFilename(match.Groups[1].Value.Replace("\""
 0120                            File.WriteAllBytes(fileName, bytes);
 0121                            return new FileStream(fileName, FileMode.Open);
 122                        }
 0123                    }
 0124                }
 0125                var stream = new MemoryStream(bytes);
 0126                return stream;
 127            }
 128
 34129            if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
 0130            {
 0131                return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind);
 132            }
 133
 34134            if (type == typeof(string) || type.Name.StartsWith("System.Nullable")) // return primitive type
 0135            {
 0136                return Convert.ChangeType(response.Content, type);
 137            }
 138
 139            // at this point, it must be a model (json)
 140            try
 34141            {
 34142                return JsonConvert.DeserializeObject(response.Content, type, _serializerSettings);
 143            }
 20144            catch (Exception e)
 20145            {
 20146                throw new ApiException(500, e.Message);
 147            }
 14148        }
 149
 0150        public ISerializer Serializer => this;
 34151        public IDeserializer Deserializer => this;
 152
 34153        public string[] AcceptedContentTypes => RestSharp.Serializers.ContentType.JsonAccept;
 154
 34155        public SupportsContentType SupportsContentType => contentType =>
 68156            contentType.EndsWith("json", StringComparison.InvariantCultureIgnoreCase) ||
 68157            contentType.EndsWith("javascript", StringComparison.InvariantCultureIgnoreCase);
 158
 159        public string ContentType
 160        {
 0161            get { return _contentType; }
 0162            set { throw new InvalidOperationException("Not allowed to set content type."); }
 163        }
 164
 68165        public DataFormat DataFormat => DataFormat.Json;
 166    }
 167    /// <summary>
 168    /// Provides a default implementation of an Api client (both synchronous and asynchronous implementations),
 169    /// encapsulating general REST accessor use cases.
 170    /// </summary>
 171    public partial class ApiClient : ISynchronousClient, IAsynchronousClient
 172    {
 173        private readonly string _baseUrl;
 174
 175        /// <summary>
 176        /// Specifies the settings on a <see cref="JsonSerializer" /> object.
 177        /// These settings can be adjusted to accommodate custom serialization rules.
 178        /// </summary>
 89179        public JsonSerializerSettings SerializerSettings { get; set; } = new JsonSerializerSettings
 14180        {
 14181            // OpenAPI generated types generally hide default constructors.
 14182            ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
 14183            ContractResolver = new DefaultContractResolver
 14184            {
 14185                NamingStrategy = new CamelCaseNamingStrategy
 14186                {
 14187                    OverrideSpecifiedNames = false
 14188                }
 14189            }
 14190        };
 191
 192        /// <summary>
 193        /// Allows for extending request processing for <see cref="ApiClient"/> generated code.
 194        /// </summary>
 195        /// <param name="request">The RestSharp request object</param>
 196        partial void InterceptRequest(RestRequest request);
 197
 198        /// <summary>
 199        /// Allows for extending response processing for <see cref="ApiClient"/> generated code.
 200        /// </summary>
 201        /// <param name="request">The RestSharp request object</param>
 202        /// <param name="response">The RestSharp response object</param>
 203        partial void InterceptResponse(RestRequest request, RestResponse response);
 204
 205        /// <summary>
 206        /// Initializes a new instance of the <see cref="ApiClient" />, defaulting to the global configurations' base ur
 207        /// </summary>
 0208        public ApiClient()
 0209        {
 0210            _baseUrl = Applications.WeShare.Swagger.Client.GlobalConfiguration.Instance.BasePath;
 0211        }
 212
 213        /// <summary>
 214        /// Initializes a new instance of the <see cref="ApiClient" />
 215        /// </summary>
 216        /// <param name="basePath">The target service's base path in URL format.</param>
 217        /// <exception cref="ArgumentException"></exception>
 14218        public ApiClient(string basePath)
 14219        {
 14220            if (string.IsNullOrEmpty(basePath))
 0221                throw new ArgumentException("basePath cannot be empty");
 222
 14223            _baseUrl = basePath;
 14224        }
 225
 226        /// <summary>
 227        /// Constructs the RestSharp version of an http method
 228        /// </summary>
 229        /// <param name="method">Swagger Client Custom HttpMethod</param>
 230        /// <returns>RestSharp's HttpMethod instance.</returns>
 231        /// <exception cref="ArgumentOutOfRangeException"></exception>
 232        private RestSharpMethod Method(HttpMethod method)
 34233        {
 234            RestSharpMethod other;
 34235            switch (method)
 236            {
 237                case HttpMethod.Get:
 25238                    other = RestSharpMethod.Get;
 25239                    break;
 240                case HttpMethod.Post:
 7241                    other = RestSharpMethod.Post;
 7242                    break;
 243                case HttpMethod.Put:
 0244                    other = RestSharpMethod.Put;
 0245                    break;
 246                case HttpMethod.Delete:
 2247                    other = RestSharpMethod.Delete;
 2248                    break;
 249                case HttpMethod.Head:
 0250                    other = RestSharpMethod.Head;
 0251                    break;
 252                case HttpMethod.Options:
 0253                    other = RestSharpMethod.Options;
 0254                    break;
 255                case HttpMethod.Patch:
 0256                    other = RestSharpMethod.Patch;
 0257                    break;
 258                default:
 0259                    throw new ArgumentOutOfRangeException("method", method, null);
 260            }
 261
 34262            return other;
 34263        }
 264
 265        /// <summary>
 266        /// Provides all logic for constructing a new RestSharp <see cref="RestRequest"/>.
 267        /// At this point, all information for querying the service is known. Here, it is simply
 268        /// mapped into the RestSharp request.
 269        /// </summary>
 270        /// <param name="method">The http verb.</param>
 271        /// <param name="path">The target path (or resource).</param>
 272        /// <param name="options">The additional request options.</param>
 273        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 274        /// GlobalConfiguration has been done before calling this method.</param>
 275        /// <returns>[private] A new RestRequest instance.</returns>
 276        /// <exception cref="ArgumentNullException"></exception>
 277        private RestRequest NewRequest(
 278            HttpMethod method,
 279            string path,
 280            RequestOptions options,
 281            IReadableConfiguration configuration)
 34282        {
 34283            if (path == null) throw new ArgumentNullException("path");
 34284            if (options == null) throw new ArgumentNullException("options");
 34285            if (configuration == null) throw new ArgumentNullException("configuration");
 286
 34287            RestRequest request = new RestRequest(path, Method(method));
 288
 34289            if (options.PathParameters != null)
 34290            {
 150291                foreach (var pathParam in options.PathParameters)
 24292                {
 24293                    request.AddParameter(pathParam.Key, pathParam.Value, ParameterType.UrlSegment);
 24294                }
 34295            }
 296
 34297            if (options.QueryParameters != null)
 34298            {
 102299                foreach (var queryParam in options.QueryParameters)
 0300                {
 0301                    foreach (var value in queryParam.Value)
 0302                    {
 0303                        request.AddQueryParameter(queryParam.Key, value);
 0304                    }
 0305                }
 34306            }
 307
 34308            if (configuration.DefaultHeaders != null)
 34309            {
 102310                foreach (var headerParam in configuration.DefaultHeaders)
 0311                {
 0312                    request.AddHeader(headerParam.Key, headerParam.Value);
 0313                }
 34314            }
 315
 34316            if (options.HeaderParameters != null)
 34317            {
 180318                foreach (var headerParam in options.HeaderParameters)
 39319                {
 195320                    foreach (var value in headerParam.Value)
 39321                    {
 39322                        request.AddHeader(headerParam.Key, value);
 39323                    }
 39324                }
 34325            }
 326
 34327            if (options.FormParameters != null)
 34328            {
 102329                foreach (var formParam in options.FormParameters)
 0330                {
 0331                    request.AddParameter(formParam.Key, formParam.Value);
 0332                }
 34333            }
 334
 34335            if (options.Data != null)
 7336            {
 7337                if (options.Data is Stream stream)
 0338                {
 0339                    var contentType = "application/octet-stream";
 0340                    if (options.HeaderParameters != null)
 0341                    {
 0342                        var contentTypes = options.HeaderParameters["Content-Type"];
 0343                        contentType = contentTypes[0];
 0344                    }
 345
 0346                    var bytes = ClientUtils.ReadAsBytes(stream);
 0347                    request.AddParameter(contentType, bytes, ParameterType.RequestBody);
 0348                }
 349                else
 7350                {
 7351                    if (options.HeaderParameters != null)
 7352                    {
 7353                        var contentTypes = options.HeaderParameters["Content-Type"];
 14354                        if (contentTypes == null || contentTypes.Any(header => header.Contains("application/json")))
 7355                        {
 7356                            request.RequestFormat = DataFormat.Json;
 7357                        }
 358                        else
 0359                        {
 360                            // TODO: Generated client user should add additional handlers. RestSharp only supports XML a
 0361                        }
 7362                    }
 363                    else
 0364                    {
 365                        // Here, we'll assume JSON APIs are more common. XML can be forced by adding produces/consumes t
 0366                        request.RequestFormat = DataFormat.Json;
 0367                    }
 368
 7369                    request.AddJsonBody(options.Data);
 7370                }
 7371            }
 372
 34373            if (options.FileParameters != null)
 34374            {
 102375                foreach (var fileParam in options.FileParameters)
 0376                {
 0377                    foreach (var file in fileParam.Value)
 0378                    {
 0379                        var bytes = ClientUtils.ReadAsBytes(file);
 0380                        var fileStream = file as FileStream;
 0381                        if (fileStream != null)
 0382                            request.AddFile(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name));
 383                        else
 0384                            request.AddFile(fileParam.Key, bytes, "no_file_name_provided");
 0385                    }
 0386                }
 34387            }
 388
 34389            return request;
 34390        }
 391
 392        private ApiResponse<T> ToApiResponse<T>(RestResponse<T> response)
 34393        {
 34394            T result = response.Data;
 34395            string rawContent = response.Content;
 396
 34397            var transformed = new ApiResponse<T>(response.StatusCode, new Multimap<string, string>(), result, rawContent
 34398            {
 34399                ErrorText = response.ErrorMessage,
 34400                Cookies = new List<Cookie>()
 34401            };
 402
 34403            if (response.Headers != null)
 34404            {
 170405                foreach (var responseHeader in response.Headers)
 34406                {
 34407                    transformed.Headers.Add(responseHeader.Name, ClientUtils.ParameterToString(responseHeader.Value));
 34408                }
 34409            }
 410
 34411            if (response.ContentHeaders != null)
 34412            {
 238413                foreach (var responseHeader in response.ContentHeaders)
 68414                {
 68415                    transformed.Headers.Add(responseHeader.Name, ClientUtils.ParameterToString(responseHeader.Value));
 68416                }
 34417            }
 418
 34419            if (response.Cookies != null)
 34420            {
 102421                foreach (var responseCookies in response.Cookies.Cast<Cookie>())
 0422                {
 0423                    transformed.Cookies.Add(
 0424                        new Cookie(
 0425                            responseCookies.Name,
 0426                            responseCookies.Value,
 0427                            responseCookies.Path,
 0428                            responseCookies.Domain)
 0429                        );
 0430                }
 34431            }
 432
 34433            return transformed;
 34434        }
 435
 436        private ApiResponse<T> Exec<T>(RestRequest req, RequestOptions options, IReadableConfiguration configuration)
 34437        {
 34438            var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
 439
 34440            var cookies = new CookieContainer();
 441
 34442            if (options.Cookies != null && options.Cookies.Count > 0)
 0443            {
 0444                foreach (var cookie in options.Cookies)
 0445                {
 0446                    cookies.Add(new Cookie(cookie.Name, cookie.Value));
 0447                }
 0448            }
 449
 34450            var clientOptions = new RestClientOptions(baseUrl)
 34451            {
 34452                ClientCertificates = configuration.ClientCertificates,
 34453                CookieContainer = cookies,
 34454                MaxTimeout = configuration.Timeout,
 34455                Proxy = configuration.Proxy,
 34456                UserAgent = configuration.UserAgent
 34457            };
 458
 34459            RestClient client = new RestClient(clientOptions)
 109460                .UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration));
 461
 462            InterceptRequest(req);
 463
 464            RestResponse<T> response;
 34465            if (RetryConfiguration.RetryPolicy != null)
 0466            {
 0467                var policy = RetryConfiguration.RetryPolicy;
 0468                var policyResult = policy.ExecuteAndCapture(() => client.Execute(req));
 0469                response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize<T>(policyResult.Result)
 0470                {
 0471                    Request = req,
 0472                    ErrorException = policyResult.FinalException
 0473                };
 0474            }
 475            else
 34476            {
 34477                response = client.Execute<T>(req);
 34478            }
 479
 480            // if the response type is oneOf/anyOf, call FromJSON to deserialize the data
 34481            if (typeof(Applications.WeShare.Swagger.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
 0482            {
 483                try
 0484                {
 0485                    response.Data = (T) typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content });
 0486                }
 0487                catch (Exception ex)
 0488                {
 0489                    throw ex.InnerException != null ? ex.InnerException : ex;
 490                }
 0491            }
 34492            else if (typeof(T).Name == "Stream") // for binary response
 0493            {
 0494                response.Data = (T)(object)new MemoryStream(response.RawBytes);
 0495            }
 34496            else if (typeof(T).Name == "Byte[]") // for byte response
 0497            {
 0498                response.Data = (T)(object)response.RawBytes;
 0499            }
 34500            else if (typeof(T).Name == "String") // for string response
 0501            {
 0502                response.Data = (T)(object)response.Content;
 0503            }
 504
 505            InterceptResponse(req, response);
 506
 34507            var result = ToApiResponse(response);
 34508            if (response.ErrorMessage != null)
 20509            {
 20510                result.ErrorText = response.ErrorMessage;
 20511            }
 512
 34513            if (response.Cookies != null && response.Cookies.Count > 0)
 0514            {
 0515                if (result.Cookies == null) result.Cookies = new List<Cookie>();
 0516                foreach (var restResponseCookie in response.Cookies.Cast<Cookie>())
 0517                {
 0518                    var cookie = new Cookie(
 0519                        restResponseCookie.Name,
 0520                        restResponseCookie.Value,
 0521                        restResponseCookie.Path,
 0522                        restResponseCookie.Domain
 0523                    )
 0524                    {
 0525                        Comment = restResponseCookie.Comment,
 0526                        CommentUri = restResponseCookie.CommentUri,
 0527                        Discard = restResponseCookie.Discard,
 0528                        Expired = restResponseCookie.Expired,
 0529                        Expires = restResponseCookie.Expires,
 0530                        HttpOnly = restResponseCookie.HttpOnly,
 0531                        Port = restResponseCookie.Port,
 0532                        Secure = restResponseCookie.Secure,
 0533                        Version = restResponseCookie.Version
 0534                    };
 535
 0536                    result.Cookies.Add(cookie);
 0537                }
 0538            }
 34539            return result;
 34540        }
 541
 542        private async Task<ApiResponse<T>> ExecAsync<T>(RestRequest req, RequestOptions options, IReadableConfiguration 
 0543        {
 0544            var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
 545
 0546            var clientOptions = new RestClientOptions(baseUrl)
 0547            {
 0548                ClientCertificates = configuration.ClientCertificates,
 0549                MaxTimeout = configuration.Timeout,
 0550                Proxy = configuration.Proxy,
 0551                UserAgent = configuration.UserAgent
 0552            };
 553
 0554            RestClient client = new RestClient(clientOptions)
 0555                .UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration));
 556
 557            InterceptRequest(req);
 558
 559            RestResponse<T> response;
 0560            if (RetryConfiguration.AsyncRetryPolicy != null)
 0561            {
 0562                var policy = RetryConfiguration.AsyncRetryPolicy;
 0563                var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(req, ct), cancellatio
 0564                response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize<T>(policyResult.Result)
 0565                {
 0566                    Request = req,
 0567                    ErrorException = policyResult.FinalException
 0568                };
 0569            }
 570            else
 0571            {
 0572                response = await client.ExecuteAsync<T>(req, cancellationToken).ConfigureAwait(false);
 0573            }
 574
 575            // if the response type is oneOf/anyOf, call FromJSON to deserialize the data
 0576            if (typeof(Applications.WeShare.Swagger.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
 0577            {
 0578                response.Data = (T) typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content });
 0579            }
 0580            else if (typeof(T).Name == "Stream") // for binary response
 0581            {
 0582                response.Data = (T)(object)new MemoryStream(response.RawBytes);
 0583            }
 0584            else if (typeof(T).Name == "Byte[]") // for byte response
 0585            {
 0586                response.Data = (T)(object)response.RawBytes;
 0587            }
 588
 589            InterceptResponse(req, response);
 590
 0591            var result = ToApiResponse(response);
 0592            if (response.ErrorMessage != null)
 0593            {
 0594                result.ErrorText = response.ErrorMessage;
 0595            }
 596
 0597            if (response.Cookies != null && response.Cookies.Count > 0)
 0598            {
 0599                if (result.Cookies == null) result.Cookies = new List<Cookie>();
 0600                foreach (var restResponseCookie in response.Cookies.Cast<Cookie>())
 0601                {
 0602                    var cookie = new Cookie(
 0603                        restResponseCookie.Name,
 0604                        restResponseCookie.Value,
 0605                        restResponseCookie.Path,
 0606                        restResponseCookie.Domain
 0607                    )
 0608                    {
 0609                        Comment = restResponseCookie.Comment,
 0610                        CommentUri = restResponseCookie.CommentUri,
 0611                        Discard = restResponseCookie.Discard,
 0612                        Expired = restResponseCookie.Expired,
 0613                        Expires = restResponseCookie.Expires,
 0614                        HttpOnly = restResponseCookie.HttpOnly,
 0615                        Port = restResponseCookie.Port,
 0616                        Secure = restResponseCookie.Secure,
 0617                        Version = restResponseCookie.Version
 0618                    };
 619
 0620                    result.Cookies.Add(cookie);
 0621                }
 0622            }
 0623            return result;
 0624        }
 625
 626        #region IAsynchronousClient
 627        /// <summary>
 628        /// Make a HTTP GET request (async).
 629        /// </summary>
 630        /// <param name="path">The target path (or resource).</param>
 631        /// <param name="options">The additional request options.</param>
 632        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 633        /// GlobalConfiguration has been done before calling this method.</param>
 634        /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
 635        /// <returns>A Task containing ApiResponse</returns>
 636        public Task<ApiResponse<T>> GetAsync<T>(string path, RequestOptions options, IReadableConfiguration configuratio
 0637        {
 0638            var config = configuration ?? GlobalConfiguration.Instance;
 0639            return ExecAsync<T>(NewRequest(HttpMethod.Get, path, options, config), options, config, cancellationToken);
 0640        }
 641
 642        /// <summary>
 643        /// Make a HTTP POST request (async).
 644        /// </summary>
 645        /// <param name="path">The target path (or resource).</param>
 646        /// <param name="options">The additional request options.</param>
 647        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 648        /// GlobalConfiguration has been done before calling this method.</param>
 649        /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
 650        /// <returns>A Task containing ApiResponse</returns>
 651        public Task<ApiResponse<T>> PostAsync<T>(string path, RequestOptions options, IReadableConfiguration configurati
 0652        {
 0653            var config = configuration ?? GlobalConfiguration.Instance;
 0654            return ExecAsync<T>(NewRequest(HttpMethod.Post, path, options, config), options, config, cancellationToken);
 0655        }
 656
 657        /// <summary>
 658        /// Make a HTTP PUT request (async).
 659        /// </summary>
 660        /// <param name="path">The target path (or resource).</param>
 661        /// <param name="options">The additional request options.</param>
 662        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 663        /// GlobalConfiguration has been done before calling this method.</param>
 664        /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
 665        /// <returns>A Task containing ApiResponse</returns>
 666        public Task<ApiResponse<T>> PutAsync<T>(string path, RequestOptions options, IReadableConfiguration configuratio
 0667        {
 0668            var config = configuration ?? GlobalConfiguration.Instance;
 0669            return ExecAsync<T>(NewRequest(HttpMethod.Put, path, options, config), options, config, cancellationToken);
 0670        }
 671
 672        /// <summary>
 673        /// Make a HTTP DELETE request (async).
 674        /// </summary>
 675        /// <param name="path">The target path (or resource).</param>
 676        /// <param name="options">The additional request options.</param>
 677        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 678        /// GlobalConfiguration has been done before calling this method.</param>
 679        /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
 680        /// <returns>A Task containing ApiResponse</returns>
 681        public Task<ApiResponse<T>> DeleteAsync<T>(string path, RequestOptions options, IReadableConfiguration configura
 0682        {
 0683            var config = configuration ?? GlobalConfiguration.Instance;
 0684            return ExecAsync<T>(NewRequest(HttpMethod.Delete, path, options, config), options, config, cancellationToken
 0685        }
 686
 687        /// <summary>
 688        /// Make a HTTP HEAD request (async).
 689        /// </summary>
 690        /// <param name="path">The target path (or resource).</param>
 691        /// <param name="options">The additional request options.</param>
 692        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 693        /// GlobalConfiguration has been done before calling this method.</param>
 694        /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
 695        /// <returns>A Task containing ApiResponse</returns>
 696        public Task<ApiResponse<T>> HeadAsync<T>(string path, RequestOptions options, IReadableConfiguration configurati
 0697        {
 0698            var config = configuration ?? GlobalConfiguration.Instance;
 0699            return ExecAsync<T>(NewRequest(HttpMethod.Head, path, options, config), options, config, cancellationToken);
 0700        }
 701
 702        /// <summary>
 703        /// Make a HTTP OPTION request (async).
 704        /// </summary>
 705        /// <param name="path">The target path (or resource).</param>
 706        /// <param name="options">The additional request options.</param>
 707        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 708        /// GlobalConfiguration has been done before calling this method.</param>
 709        /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
 710        /// <returns>A Task containing ApiResponse</returns>
 711        public Task<ApiResponse<T>> OptionsAsync<T>(string path, RequestOptions options, IReadableConfiguration configur
 0712        {
 0713            var config = configuration ?? GlobalConfiguration.Instance;
 0714            return ExecAsync<T>(NewRequest(HttpMethod.Options, path, options, config), options, config, cancellationToke
 0715        }
 716
 717        /// <summary>
 718        /// Make a HTTP PATCH request (async).
 719        /// </summary>
 720        /// <param name="path">The target path (or resource).</param>
 721        /// <param name="options">The additional request options.</param>
 722        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 723        /// GlobalConfiguration has been done before calling this method.</param>
 724        /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
 725        /// <returns>A Task containing ApiResponse</returns>
 726        public Task<ApiResponse<T>> PatchAsync<T>(string path, RequestOptions options, IReadableConfiguration configurat
 0727        {
 0728            var config = configuration ?? GlobalConfiguration.Instance;
 0729            return ExecAsync<T>(NewRequest(HttpMethod.Patch, path, options, config), options, config, cancellationToken)
 0730        }
 731        #endregion IAsynchronousClient
 732
 733        #region ISynchronousClient
 734        /// <summary>
 735        /// Make a HTTP GET request (synchronous).
 736        /// </summary>
 737        /// <param name="path">The target path (or resource).</param>
 738        /// <param name="options">The additional request options.</param>
 739        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 740        /// GlobalConfiguration has been done before calling this method.</param>
 741        /// <returns>A Task containing ApiResponse</returns>
 742        public ApiResponse<T> Get<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
 25743        {
 25744            var config = configuration ?? GlobalConfiguration.Instance;
 25745            return Exec<T>(NewRequest(HttpMethod.Get, path, options, config), options, config);
 25746        }
 747
 748        /// <summary>
 749        /// Make a HTTP POST request (synchronous).
 750        /// </summary>
 751        /// <param name="path">The target path (or resource).</param>
 752        /// <param name="options">The additional request options.</param>
 753        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 754        /// GlobalConfiguration has been done before calling this method.</param>
 755        /// <returns>A Task containing ApiResponse</returns>
 756        public ApiResponse<T> Post<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
 7757        {
 7758            var config = configuration ?? GlobalConfiguration.Instance;
 7759            return Exec<T>(NewRequest(HttpMethod.Post, path, options, config), options, config);
 7760        }
 761
 762        /// <summary>
 763        /// Make a HTTP PUT request (synchronous).
 764        /// </summary>
 765        /// <param name="path">The target path (or resource).</param>
 766        /// <param name="options">The additional request options.</param>
 767        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 768        /// GlobalConfiguration has been done before calling this method.</param>
 769        /// <returns>A Task containing ApiResponse</returns>
 770        public ApiResponse<T> Put<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
 0771        {
 0772            var config = configuration ?? GlobalConfiguration.Instance;
 0773            return Exec<T>(NewRequest(HttpMethod.Put, path, options, config), options, config);
 0774        }
 775
 776        /// <summary>
 777        /// Make a HTTP DELETE request (synchronous).
 778        /// </summary>
 779        /// <param name="path">The target path (or resource).</param>
 780        /// <param name="options">The additional request options.</param>
 781        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 782        /// GlobalConfiguration has been done before calling this method.</param>
 783        /// <returns>A Task containing ApiResponse</returns>
 784        public ApiResponse<T> Delete<T>(string path, RequestOptions options, IReadableConfiguration configuration = null
 2785        {
 2786            var config = configuration ?? GlobalConfiguration.Instance;
 2787            return Exec<T>(NewRequest(HttpMethod.Delete, path, options, config), options, config);
 2788        }
 789
 790        /// <summary>
 791        /// Make a HTTP HEAD request (synchronous).
 792        /// </summary>
 793        /// <param name="path">The target path (or resource).</param>
 794        /// <param name="options">The additional request options.</param>
 795        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 796        /// GlobalConfiguration has been done before calling this method.</param>
 797        /// <returns>A Task containing ApiResponse</returns>
 798        public ApiResponse<T> Head<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
 0799        {
 0800            var config = configuration ?? GlobalConfiguration.Instance;
 0801            return Exec<T>(NewRequest(HttpMethod.Head, path, options, config), options, config);
 0802        }
 803
 804        /// <summary>
 805        /// Make a HTTP OPTION request (synchronous).
 806        /// </summary>
 807        /// <param name="path">The target path (or resource).</param>
 808        /// <param name="options">The additional request options.</param>
 809        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 810        /// GlobalConfiguration has been done before calling this method.</param>
 811        /// <returns>A Task containing ApiResponse</returns>
 812        public ApiResponse<T> Options<T>(string path, RequestOptions options, IReadableConfiguration configuration = nul
 0813        {
 0814            var config = configuration ?? GlobalConfiguration.Instance;
 0815            return Exec<T>(NewRequest(HttpMethod.Options, path, options, config), options, config);
 0816        }
 817
 818        /// <summary>
 819        /// Make a HTTP PATCH request (synchronous).
 820        /// </summary>
 821        /// <param name="path">The target path (or resource).</param>
 822        /// <param name="options">The additional request options.</param>
 823        /// <param name="configuration">A per-request configuration object. It is assumed that any merge with
 824        /// GlobalConfiguration has been done before calling this method.</param>
 825        /// <returns>A Task containing ApiResponse</returns>
 826        public ApiResponse<T> Patch<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
 0827        {
 0828            var config = configuration ?? GlobalConfiguration.Instance;
 0829            return Exec<T>(NewRequest(HttpMethod.Patch, path, options, config), options, config);
 0830        }
 831        #endregion ISynchronousClient
 832    }
 833}

Methods/Properties

System.Void Applications.WeShare.Swagger.Client.CustomJsonCodec::.cctor()
System.Void Applications.WeShare.Swagger.Client.CustomJsonCodec::.ctor(Applications.WeShare.Swagger.Client.IReadableConfiguration)
System.Void Applications.WeShare.Swagger.Client.CustomJsonCodec::.ctor(Newtonsoft.Json.JsonSerializerSettings,Applications.WeShare.Swagger.Client.IReadableConfiguration)
System.String Applications.WeShare.Swagger.Client.CustomJsonCodec::Serialize(System.Object)
System.String Applications.WeShare.Swagger.Client.CustomJsonCodec::Serialize(RestSharp.Parameter)
T Applications.WeShare.Swagger.Client.CustomJsonCodec::Deserialize(RestSharp.RestResponse)
System.Object Applications.WeShare.Swagger.Client.CustomJsonCodec::Deserialize(RestSharp.RestResponse,System.Type)
RestSharp.Serializers.ISerializer Applications.WeShare.Swagger.Client.CustomJsonCodec::get_Serializer()
RestSharp.Serializers.IDeserializer Applications.WeShare.Swagger.Client.CustomJsonCodec::get_Deserializer()
System.String[] Applications.WeShare.Swagger.Client.CustomJsonCodec::get_AcceptedContentTypes()
RestSharp.Serializers.SupportsContentType Applications.WeShare.Swagger.Client.CustomJsonCodec::get_SupportsContentType()
System.String Applications.WeShare.Swagger.Client.CustomJsonCodec::get_ContentType()
System.Void Applications.WeShare.Swagger.Client.CustomJsonCodec::set_ContentType(System.String)
RestSharp.DataFormat Applications.WeShare.Swagger.Client.CustomJsonCodec::get_DataFormat()
Newtonsoft.Json.JsonSerializerSettings Applications.WeShare.Swagger.Client.ApiClient::get_SerializerSettings()
System.Void Applications.WeShare.Swagger.Client.ApiClient::.ctor()
System.Void Applications.WeShare.Swagger.Client.ApiClient::.ctor(System.String)
RestSharp.Method Applications.WeShare.Swagger.Client.ApiClient::Method(Applications.WeShare.Swagger.Client.HttpMethod)
RestSharp.RestRequest Applications.WeShare.Swagger.Client.ApiClient::NewRequest(Applications.WeShare.Swagger.Client.HttpMethod,System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::ToApiResponse(RestSharp.RestResponse`1<T>)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::Exec(RestSharp.RestRequest,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)
System.Void Applications.WeShare.Swagger.Client.ApiClient/<ExecAsync>d__13`1::MoveNext()
RestSharp.Serializers.IRestSerializer Applications.WeShare.Swagger.Client.ApiClient/<>c__DisplayClass13_0`1::<ExecAsync>b__0()
System.Threading.Tasks.Task`1<RestSharp.RestResponse> Applications.WeShare.Swagger.Client.ApiClient/<>c__DisplayClass13_0`1::<ExecAsync>b__1(System.Threading.CancellationToken)
System.Threading.Tasks.Task`1<Applications.WeShare.Swagger.Client.ApiResponse`1<T>> Applications.WeShare.Swagger.Client.ApiClient::GetAsync(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration,System.Threading.CancellationToken)
System.Threading.Tasks.Task`1<Applications.WeShare.Swagger.Client.ApiResponse`1<T>> Applications.WeShare.Swagger.Client.ApiClient::PostAsync(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration,System.Threading.CancellationToken)
System.Threading.Tasks.Task`1<Applications.WeShare.Swagger.Client.ApiResponse`1<T>> Applications.WeShare.Swagger.Client.ApiClient::PutAsync(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration,System.Threading.CancellationToken)
System.Threading.Tasks.Task`1<Applications.WeShare.Swagger.Client.ApiResponse`1<T>> Applications.WeShare.Swagger.Client.ApiClient::DeleteAsync(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration,System.Threading.CancellationToken)
System.Threading.Tasks.Task`1<Applications.WeShare.Swagger.Client.ApiResponse`1<T>> Applications.WeShare.Swagger.Client.ApiClient::HeadAsync(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration,System.Threading.CancellationToken)
System.Threading.Tasks.Task`1<Applications.WeShare.Swagger.Client.ApiResponse`1<T>> Applications.WeShare.Swagger.Client.ApiClient::OptionsAsync(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration,System.Threading.CancellationToken)
System.Threading.Tasks.Task`1<Applications.WeShare.Swagger.Client.ApiResponse`1<T>> Applications.WeShare.Swagger.Client.ApiClient::PatchAsync(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration,System.Threading.CancellationToken)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::Get(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::Post(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::Put(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::Delete(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::Head(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::Options(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)
Applications.WeShare.Swagger.Client.ApiResponse`1<T> Applications.WeShare.Swagger.Client.ApiClient::Patch(System.String,Applications.WeShare.Swagger.Client.RequestOptions,Applications.WeShare.Swagger.Client.IReadableConfiguration)