feat: add available providers list
This commit is contained in:
27
Endpoint/Common/MapperDto/AvailableProvidersConverter.cs
Normal file
27
Endpoint/Common/MapperDto/AvailableProvidersConverter.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Mirea.Api.Dto.Responses;
|
||||
using Mirea.Api.Security.Common.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Common.MapperDto;
|
||||
|
||||
public static class AvailableProvidersConverter
|
||||
{
|
||||
public static Dto.Common.OAuthProvider ConvertToDto(this OAuthProvider provider) =>
|
||||
provider switch
|
||||
{
|
||||
OAuthProvider.Google => Dto.Common.OAuthProvider.Google,
|
||||
OAuthProvider.Yandex => Dto.Common.OAuthProvider.Yandex,
|
||||
OAuthProvider.MailRu => Dto.Common.OAuthProvider.MailRu,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(provider), provider, null)
|
||||
};
|
||||
|
||||
public static List<AvailableProvidersResponse> ConvertToDto(this (OAuthProvider Provider, Uri Redirect)[] data) =>
|
||||
data.Select(x => new AvailableProvidersResponse()
|
||||
{
|
||||
ProviderName = Enum.GetName(x.Provider)!,
|
||||
Provider = x.Provider.ConvertToDto(),
|
||||
Redirect = x.Redirect
|
||||
}).ToList();
|
||||
}
|
Reference in New Issue
Block a user