-
Notifications
You must be signed in to change notification settings - Fork 35
/
AccountTypeParameter.cs
47 lines (41 loc) · 1.42 KB
/
AccountTypeParameter.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
using System.Text;
using Microsoft.AspNetCore.Mvc;
using NJsonSchema.Annotations;
namespace Tzkt.Api
{
[ModelBinder(BinderType = typeof(AccountTypeBinder))]
[JsonSchemaExtensionData("x-tzkt-extension", "query-parameter")]
[JsonSchemaExtensionData("x-tzkt-query-parameter", "user,contract,delegate")]
public class AccountTypeParameter : INormalizable
{
/// <summary>
/// **Equal** filter mode (optional, i.e. `param.eq=123` is the same as `param=123`). \
/// Specify an account type to get items where the specified field is equal to the specified value.
///
/// Example: `?type=delegate`.
/// </summary>
[JsonSchemaType(typeof(string))]
public int? Eq { get; set; }
/// <summary>
/// **Not equal** filter mode. \
/// Specify an account type to get items where the specified field is not equal to the specified value.
///
/// Example: `?type.ne=contract`.
/// </summary>
[JsonSchemaType(typeof(string))]
public int? Ne { 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}&");
}
return sb.ToString();
}
}
}