using Newtonsoft.Json;

namespace DocuMed.PWA.Services.RestServices;

public class RestWrapper : IRestWrapper
{

    private static RefitSettings setting = new RefitSettings(new NewtonsoftJsonContentSerializer(new JsonSerializerSettings
    {
        Formatting = Newtonsoft.Json.Formatting.Indented,
        ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore,

    }));

    public ICrudApiRest<T, TKey> CrudApiRest<T, TKey>(string address) where T : class
    {
        return RestService.For<ICrudApiRest<T, TKey>>(address, setting);
    }
    public ICrudDtoApiRest<T, TDto, TKey> CrudDtoApiRest<T, TDto, TKey>(string address) where T : class where TDto : class
    {
        return RestService.For<ICrudDtoApiRest<T, TDto, TKey>>(address, setting);
    }
    public IAuthRestApi AuthRestApi => RestService.For<IAuthRestApi>(Address.AuthController, setting);
    public ISectionRestApi SectionRestApi => RestService.For<ISectionRestApi>(Address.SectionController, setting);
    public IUserRestApi UserRestApi => RestService.For<IUserRestApi>(Address.UserController, setting);
}