Skip to content

Commit fdd81ae

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

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
namespace HttpsRichardy.Federation.Sdk.Filtering;
2+
3+
public sealed class GroupFilters
4+
{
5+
internal string? Id { get; private set; }
6+
internal string? RealmId { get; private set; }
7+
internal string? Name { get; private set; }
8+
9+
internal bool? IsDeleted { get; private set; }
10+
11+
internal DateOnly? CreatedAfter { get; private set; }
12+
internal DateOnly? CreatedBefore { get; private set; }
13+
14+
public GroupFilters WithIdentifier(string identifier)
15+
{
16+
if (!string.IsNullOrWhiteSpace(identifier))
17+
{
18+
Id = identifier.Trim();
19+
}
20+
21+
return this;
22+
}
23+
24+
public GroupFilters WithRealmId(string realmId)
25+
{
26+
if (!string.IsNullOrWhiteSpace(realmId))
27+
{
28+
RealmId = realmId.Trim();
29+
}
30+
31+
return this;
32+
}
33+
34+
public GroupFilters WithName(string name)
35+
{
36+
if (!string.IsNullOrWhiteSpace(name))
37+
{
38+
Name = name.Trim();
39+
}
40+
41+
return this;
42+
}
43+
44+
public GroupFilters WithIsDeleted(bool? isDeleted)
45+
{
46+
IsDeleted = isDeleted;
47+
return this;
48+
}
49+
50+
public GroupFilters WithCreatedAfter(DateOnly? createdAfter)
51+
{
52+
CreatedAfter = createdAfter;
53+
return this;
54+
}
55+
56+
public GroupFilters WithCreatedBefore(DateOnly? createdBefore)
57+
{
58+
CreatedBefore = createdBefore;
59+
return this;
60+
}
61+
62+
public static GroupsFetchParameters WithoutFilters => new();
63+
public static GroupFilters AsBuilder() => new();
64+
65+
public GroupsFetchParameters Build()
66+
{
67+
return new GroupsFetchParameters
68+
{
69+
Id = Id,
70+
RealmId = RealmId,
71+
Name = Name,
72+
IsDeleted = IsDeleted,
73+
CreatedAfter = CreatedAfter,
74+
CreatedBefore = CreatedBefore
75+
};
76+
}
77+
}

0 commit comments

Comments
 (0)