-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathBucketList.cs
More file actions
39 lines (33 loc) · 1.05 KB
/
BucketList.cs
File metadata and controls
39 lines (33 loc) · 1.05 KB
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
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;
namespace Appwrite.Models
{
public class BucketList
{
[JsonPropertyName("total")]
public long Total { get; private set; }
[JsonPropertyName("buckets")]
public List<Bucket> Buckets { get; private set; }
public BucketList(
long total,
List<Bucket> buckets
) {
Total = total;
Buckets = buckets;
}
public static BucketList From(Dictionary<string, object> map) => new BucketList(
total: Convert.ToInt64(map["total"]),
buckets: map["buckets"].ConvertToList<Dictionary<string, object>>().Select(it => Bucket.From(map: it)).ToList()
);
public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
{
{ "total", Total },
{ "buckets", Buckets.Select(it => it.ToMap()) }
};
}
}