mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2025-12-23 22:18:39 -05:00
44 lines
994 B
C#
44 lines
994 B
C#
using System;
|
|
|
|
using Cleanuparr.Domain.Enums;
|
|
using Cleanuparr.Domain.Exceptions;
|
|
using Cleanuparr.Persistence.Models.Configuration;
|
|
|
|
namespace Cleanuparr.Api.Features.DownloadClient.Contracts.Requests;
|
|
|
|
public sealed record TestDownloadClientRequest
|
|
{
|
|
public DownloadClientTypeName TypeName { get; init; }
|
|
|
|
public DownloadClientType Type { get; init; }
|
|
|
|
public Uri? Host { get; init; }
|
|
|
|
public string? Username { get; init; }
|
|
|
|
public string? Password { get; init; }
|
|
|
|
public string? UrlBase { get; init; }
|
|
|
|
public void Validate()
|
|
{
|
|
if (Host is null)
|
|
{
|
|
throw new ValidationException("Host cannot be empty");
|
|
}
|
|
}
|
|
|
|
public DownloadClientConfig ToTestConfig() => new()
|
|
{
|
|
Id = Guid.NewGuid(),
|
|
Enabled = true,
|
|
Name = "Test Client",
|
|
TypeName = TypeName,
|
|
Type = Type,
|
|
Host = Host,
|
|
Username = Username,
|
|
Password = Password,
|
|
UrlBase = UrlBase,
|
|
};
|
|
}
|