-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPagination.cs
More file actions
30 lines (27 loc) · 797 Bytes
/
Pagination.cs
File metadata and controls
30 lines (27 loc) · 797 Bytes
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
namespace RentmanSharp
{
public readonly struct Pagination
{
public readonly int Limit;
public readonly int? Offset;
public Pagination(in int limit=300,in int? offset=0)
{
this.Limit = limit;
this.Offset = offset;
}
public Pagination Next()
{
return new Pagination(this.Limit, this.Offset + this.Limit);
}
public override string ToString()
{
if(this.Offset.HasValue)
return $"?limit={this.Limit}&offset={this.Offset}";
return $"?limit={this.Limit}";
}
public static implicit operator Pagination?(Response response)
{
return new Pagination(response.Limit, response.Offset);
}
}
}