-
Notifications
You must be signed in to change notification settings - Fork 34
/
BoolParameter.cs
44 lines (38 loc) 路 1.27 KB
/
BoolParameter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
锘縰sing System.Text;
using Microsoft.AspNetCore.Mvc;
using NJsonSchema.Annotations;
namespace Tzkt.Api
{
[ModelBinder(BinderType = typeof(BoolBinder))]
[JsonSchemaExtensionData("x-tzkt-extension", "query-parameter")]
public class BoolParameter : INormalizable
{
/// <summary>
/// **Equal** filter mode (optional, i.e. `param.eq=true` is the same as `param=true`). \
/// Specify a bool flag to get items where the specified field is equal to the specified value.
///
/// Example: `?active=true` or `?active=1` or `?active`.
/// </summary>
public bool? Eq { get; set; }
/// <summary>
/// **Is null** filter mode. \
/// Use this mode to get items where the specified field is null or not.
///
/// Example: `?active.null` or `?active.null=false`.
/// </summary>
public bool? Null { get; set; }
public string Normalize(string name)
{
var sb = new StringBuilder();
if (Eq != null)
{
sb.Append($"{name}.eq={Eq}&");
}
if (Null != null)
{
sb.Append($"{name}.null={Null}&");
}
return sb.ToString();
}
}
}