private async Task <Validation <BaseError, Parameters> > Validate(SaveJellyfinSecrets request) { Either <BaseError, JellyfinServerInformation> maybeServerInformation = await _jellyfinApiClient .GetServerInformation(request.Secrets.Address, request.Secrets.ApiKey); return(maybeServerInformation.Match( info => Validation <BaseError, Parameters> .Success(new Parameters(request.Secrets, info)), error => error)); }
public Task <Either <BaseError, Unit> > Handle(SaveJellyfinSecrets request, CancellationToken cancellationToken) => Validate(request) .MapT(PerformSave) .Bind(v => v.ToEitherAsync());