-
Notifications
You must be signed in to change notification settings - Fork 35
/
SrBondStatusParameter.cs
75 lines (65 loc) · 2.48 KB
/
SrBondStatusParameter.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System.Text;
using Microsoft.AspNetCore.Mvc;
using NJsonSchema.Annotations;
namespace Tzkt.Api
{
[ModelBinder(BinderType = typeof(SrBondStatusBinder))]
[JsonSchemaExtensionData("x-tzkt-extension", "query-parameter")]
[JsonSchemaExtensionData("x-tzkt-query-parameter", "active,returned,lost")]
public class SrBondStatusParameter : INormalizable
{
/// <summary>
/// **Equal** filter mode (`.eq` suffix can be omitted, i.e. `?param=...` is the same as `?param.eq=...`). \
/// Specify an sr bond status to get items where the specified field is equal to the specified value.
///
/// Example: `?status=active`.
/// </summary>
[JsonSchemaType(typeof(string))]
public int? Eq { get; set; }
/// <summary>
/// **Not equal** filter mode. \
/// Specify an sr bond status to get items where the specified field is not equal to the specified value.
///
/// Example: `?status.ne=active`.
/// </summary>
[JsonSchemaType(typeof(string))]
public int? Ne { get; set; }
/// <summary>
/// **In list** (any of) filter mode. \
/// Specify a comma-separated list of sr bond statuses to get items where the specified field is equal to one of the specified values.
///
/// Example: `?status.in=returned,lost`.
/// </summary>
[JsonSchemaType(typeof(List<string>))]
public List<int> In { get; set; }
/// <summary>
/// **Not in list** (none of) filter mode. \
/// Specify a comma-separated list of sr bond statuses to get items where the specified field is not equal to all the specified values.
///
/// Example: `?status.ni=returned,lost`.
/// </summary>
[JsonSchemaType(typeof(List<string>))]
public List<int> Ni { get; set; }
public string Normalize(string name)
{
var sb = new StringBuilder();
if (Eq != null)
{
sb.Append($"{name}.eq={Eq}&");
}
if (Ne != null)
{
sb.Append($"{name}.ne={Ne}&");
}
if (In?.Count > 0)
{
sb.Append($"{name}.in={string.Join(",", In.OrderBy(x => x))}&");
}
if (Ni?.Count > 0)
{
sb.Append($"{name}.ni={string.Join(",", Ni.OrderBy(x => x))}&");
}
return sb.ToString();
}
}
}