Skip to content

Commit ef5035a

Browse files
feature(#17): this commit introduces a fluent class for building query parameters, improving the SDK's usability
1 parent fdd81ae commit ef5035a

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
namespace HttpsRichardy.Federation.Sdk.Filtering;
2+
3+
public sealed class PermissionFilters
4+
{
5+
internal string? Name { get; private set; }
6+
internal bool IncludeDeleted { get; private set; } = false;
7+
8+
internal int PageNumber { get; private set; } = 1;
9+
internal int PageSize { get; private set; } = 20;
10+
11+
public PermissionFilters WithName(string name)
12+
{
13+
if (!string.IsNullOrWhiteSpace(name))
14+
{
15+
Name = name.Trim();
16+
}
17+
18+
return this;
19+
}
20+
21+
public PermissionFilters WithIncludeDeleted(bool includeDeleted)
22+
{
23+
IncludeDeleted = includeDeleted;
24+
return this;
25+
}
26+
27+
public PermissionFilters WithPageNumber(int pageNumber)
28+
{
29+
if (pageNumber > 0)
30+
{
31+
PageNumber = pageNumber;
32+
}
33+
34+
return this;
35+
}
36+
37+
public PermissionFilters WithPageSize(int pageSize)
38+
{
39+
if (pageSize > 0)
40+
{
41+
PageSize = pageSize;
42+
}
43+
44+
return this;
45+
}
46+
47+
public static PermissionsFetchParameters WithoutFilters => new();
48+
public static PermissionFilters AsBuilder() => new();
49+
50+
public PermissionsFetchParameters Build()
51+
{
52+
return new PermissionsFetchParameters
53+
{
54+
Name = Name,
55+
IncludeDeleted = IncludeDeleted,
56+
PageNumber = PageNumber,
57+
PageSize = PageSize
58+
};
59+
}
60+
}

0 commit comments

Comments
 (0)