@ -5,52 +5,18 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Diagnostics.Contracts ;
using Squidex.Infrastructure ;
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
namespace Squidex.Domain.Apps.Core.Apps
{
[Equals(DoNotAddEqualityOperators = true)]
public sealed class AppClient : Named
public sealed record AppClient ( string Name , string Secret )
{
public string Role { get ; }
public string Role { get ; init ; } = "Editor" ;
public string Secre t { get ; }
public long ApiCallsLimi t { get ; ini t ; }
public long ApiCalls Limit { get ; }
public long ApiTraffic Limit { get ; ini t ; }
public long ApiTrafficLimit { get ; }
public bool AllowAnonymous { get ; }
public AppClient ( string name , string secret , string role , long apiCallsLimit = 0 , long apiTrafficLimit = 0 , bool allowAnonymous = false )
: base ( name )
{
Guard . NotNullOrEmpty ( secret , nameof ( secret ) ) ;
Guard . NotNullOrEmpty ( role , nameof ( role ) ) ;
Guard . GreaterEquals ( apiCallsLimit , 0 , nameof ( apiCallsLimit ) ) ;
Guard . GreaterEquals ( apiTrafficLimit , 0 , nameof ( apiTrafficLimit ) ) ;
Secret = secret ;
Role = role ;
ApiCallsLimit = apiCallsLimit ;
ApiTrafficLimit = apiTrafficLimit ;
AllowAnonymous = allowAnonymous ;
}
[Pure]
public AppClient Update ( string? name , string? role ,
long? apiCallsLimit ,
long? apiTrafficLimit ,
bool? allowAnonymous )
{
return new AppClient ( name . Or ( Name ) , Secret , role . Or ( Role ) ,
apiCallsLimit ? ? ApiCallsLimit ,
apiTrafficLimit ? ? ApiTrafficLimit ,
allowAnonymous ? ? AllowAnonymous ) ;
}
public bool AllowAnonymous { get ; init ; }
}
}