init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
42
Kreta.Client/ClientBase/RestResult.cs
Normal file
42
Kreta.Client/ClientBase/RestResult.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using Kreta.Client.ClientBase.Interface;
|
||||
using RestSharp;
|
||||
|
||||
namespace Kreta.Client.ClientBase
|
||||
{
|
||||
internal class RestResult : IRestResult
|
||||
{
|
||||
public string Result { get; set; }
|
||||
public HttpStatusCode StatusCode { get; set; }
|
||||
public string StatusDescription { get; set; }
|
||||
public Exception Exception { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
public byte[] RawBytes { get; set; }
|
||||
|
||||
public static IRestResult Convert(IRestResponse restResponse) => new RestResult
|
||||
{
|
||||
Result = restResponse.Content,
|
||||
StatusCode = restResponse.StatusCode,
|
||||
StatusDescription = restResponse.StatusDescription,
|
||||
Exception = restResponse.ErrorException,
|
||||
ErrorMessage = restResponse.ErrorMessage,
|
||||
RawBytes = restResponse.RawBytes
|
||||
};
|
||||
}
|
||||
|
||||
internal class RestResult<TResponse> : RestResult, IRestResult<TResponse>
|
||||
{
|
||||
public TResponse Result { get; set; }
|
||||
|
||||
public static IRestResult<TResponse> Convert(IRestResponse<TResponse> restResponse) => new RestResult<TResponse>
|
||||
{
|
||||
Result = restResponse.Data,
|
||||
StatusCode = restResponse.StatusCode,
|
||||
StatusDescription = restResponse.StatusDescription,
|
||||
Exception = restResponse.ErrorException,
|
||||
ErrorMessage = restResponse.ErrorMessage,
|
||||
RawBytes = restResponse.RawBytes
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue