194 lines
6.4 KiB
C#
194 lines
6.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net.Http;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Logging;
|
|
using RestSharp;
|
|
using xCommons.Providers;
|
|
using xHttpService.Constants;
|
|
using xIdentityModels.Constants;
|
|
using xIdentityModels.Models;
|
|
using xIdentityService.Models;
|
|
|
|
namespace xIdentityService.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// an interface for Identity Provided Http Based Services ...
|
|
/// </summary>
|
|
public interface IXBaseIdentityHttpProvider
|
|
{
|
|
/// <summary>
|
|
/// Client Base Url ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
string BaseUrl { get; }
|
|
|
|
/// <summary>
|
|
/// Logger ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
ILogger Logger { get; }
|
|
|
|
/// <summary>
|
|
/// Powered Value ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
string XPoweredValue { get; }
|
|
|
|
/// <summary>
|
|
/// Default Client Timeout ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
int DefaultClientTimeout { get; }
|
|
|
|
/// <summary>
|
|
/// Default Buffering Chunk Size ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
int DefaultBufferingChunckSize { get; }
|
|
|
|
/// <summary>
|
|
/// Validation Provider ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
XValidationProvider ValidationProvider { get; }
|
|
|
|
/// <summary>
|
|
/// Get an Instance of Http Client
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
HttpClient GetHttpClient(XTokenResponse tokens = null);
|
|
HttpClient GetHttpClient(XUserClaimsInfoDto userInfo = null);
|
|
|
|
/// <summary>
|
|
/// Get an Instance of RestClient
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
RestClient GetRestClient(XTokenResponse tokens = null);
|
|
RestClient GetRestClient(XUserClaimsInfoDto userInfo = null);
|
|
|
|
/// <summary>
|
|
/// Get an Instance of RestRequest
|
|
/// </summary>
|
|
/// <param name="endpoint"></param>
|
|
/// <param name="addXPoweredValue"></param>
|
|
/// <param name=""></param>
|
|
/// <param name="headers"></param>
|
|
/// <param name="queryStrings"></param>
|
|
/// <returns></returns>
|
|
RestRequest GetRestRequet(
|
|
Enum endpoint,
|
|
bool addXPoweredValue = true,
|
|
IDictionary<string, string> @params = null,
|
|
IDictionary<string, string> headers = null,
|
|
IDictionary<string, string> queryStrings = null
|
|
);
|
|
|
|
/// <summary>
|
|
/// Handle Call Specific Request and retrieve Response
|
|
/// </summary>
|
|
/// <param name="client"></param>
|
|
/// <param name="request"></param>
|
|
/// <param name="method"></param>
|
|
/// <param name="supportRefreshingTokens"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <returns></returns>
|
|
Task<T> RunRestRequest<T>(
|
|
RestClient client,
|
|
RestRequest request,
|
|
XHttpMethod method,
|
|
bool supportRefreshingTokens = true,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Access a Get Request Stream as AsyncEnumerable ...
|
|
/// </summary>
|
|
/// <param name="endpoint"></param>
|
|
/// <param name="addXPoweredValue"></param>
|
|
/// <param name="tokens"></param>
|
|
/// <param name="@params"></param>
|
|
/// <param name="headers"></param>
|
|
/// <param name="queryStrings"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <returns></returns>
|
|
IAsyncEnumerable<T> StreamData<T>(
|
|
Enum endpoint,
|
|
bool addXPoweredValue = true,
|
|
XTokenResponse tokens = null,
|
|
IDictionary<string, string> @params = null,
|
|
IDictionary<string, string> headers = null,
|
|
IDictionary<string, string> queryStrings = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Handle Call Specified Request and Retrieve XBaseRestResponse<T> ...
|
|
/// </summary>
|
|
/// <param name="client"></param>
|
|
/// <param name="request"></param>
|
|
/// <param name="method"></param>
|
|
/// <param name="supportRefreshingTokens"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <returns>an instance of XBaseRestResponse<T></returns>
|
|
Task<XBaseRestResponse<T>> RunRestRequestByResponse<T>(
|
|
RestClient client,
|
|
RestRequest request,
|
|
XHttpMethod method,
|
|
bool supportRefreshingTokens = true,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get User SelectBy Param
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <param name="forceNotNull"></param>
|
|
/// <param name="excludes"></param>
|
|
/// <returns></returns>
|
|
string GetUserSelectByParam(
|
|
XActionRequest model,
|
|
bool forceNotNull = true,
|
|
ICollection<XUserSelectBy> excludes = null
|
|
);
|
|
|
|
/// <summary>
|
|
/// Converts UserInfo to TokenResponse model ...
|
|
/// </summary>
|
|
/// <param name="userInfo"></param>
|
|
/// <returns></returns>
|
|
XTokenResponse ToTokenResponse(XUserClaimsInfoDto userInfo = null);
|
|
|
|
/// <summary>
|
|
/// Prepare Url Address of Specified Enum by Filling Params
|
|
/// and Query Strings Attach ...
|
|
/// </summary>
|
|
/// <param name="endpoint"></param>
|
|
/// <param name="@params"></param>
|
|
/// <param name="queryStrings"></param>
|
|
/// <returns></returns>
|
|
string PrepareUrl(
|
|
Enum endpoint,
|
|
IDictionary<string, string> @params = null,
|
|
IDictionary<string, string> queryStrings = null
|
|
);
|
|
|
|
/// <summary>
|
|
/// Prepare Url Address by Filling Params
|
|
/// and Query Strings Attach ...
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <param name="@params"></param>
|
|
/// <param name="queryStrings"></param>
|
|
/// <returns></returns>
|
|
string PrepareUrl(
|
|
string url,
|
|
IDictionary<string, string> @params = null,
|
|
IDictionary<string, string> queryStrings = null
|
|
);
|
|
}
|
|
} |