using CloudBuilder.Core.DependencyInjection.Request;
using CloudBuilder.Core.Request;
using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.Security.Service;
            using CloudBuilder.Core.DatabaseAccessor.Entity;
            using Microsoft.AspNetCore.Http;
            using CloudBuilder.Core.Policy;
            using CloudBuilder.Core.DependencyInjection.Request;
            using CloudBuilder.Security.Data;
            using CloudBuilder.Core.Authorization;
            
namespace CloudBuilder.Request.Security
{

public class AuthRequest : IRequest
{

private readonly IServiceRequest serviceRequest;
public AuthRequest(IServiceRequest serviceRequest)
{
this.serviceRequest = serviceRequest;
}

        public  LoginProfile Login(LoginData data)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<LoginData,LoginProfile>("/Auth/Login" , data)).GetAwaiter().GetResult();                }

                        public  LoginProfile LoginAgent(LoginData data)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<LoginData,LoginProfile>("/Auth/LoginAgent" , data)).GetAwaiter().GetResult();                }

                        public  string Register(RegisterData data)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<RegisterData,string>("/Auth/Register" , data)).GetAwaiter().GetResult();                }

                        public  LoginProfile AmendPassword(LoginData data)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<LoginData,LoginProfile>("/Auth/AmendPassword" , data)).GetAwaiter().GetResult();                }

                        public   string GetRsaPublicKey()
                {
return Task.Run(() => serviceRequest.GetAsync<string>("/Auth/GetRsaPublicKey")).GetAwaiter().GetResult();                }

                        public  JwtInfo RefreshToken(JwtInfo jwtInfo)       
                {
return Task.Run(() =>   serviceRequest.PostAsJsonAsync<JwtInfo,JwtInfo>("/Auth/RefreshToken" , jwtInfo)).GetAwaiter().GetResult();                }

                        public  void Logout()
                {
 Task.Run(() =>  serviceRequest.PostAsync("/Auth/Logout")).GetAwaiter().GetResult();                }

                
}
}