-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathAttributeIp.cs
More file actions
95 lines (81 loc) · 2.8 KB
/
AttributeIp.cs
File metadata and controls
95 lines (81 loc) · 2.8 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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 AttributeIp
{
[JsonPropertyName("key")]
public string Key { get; private set; }
[JsonPropertyName("type")]
public string Type { get; private set; }
[JsonPropertyName("status")]
public AttributeStatus Status { get; private set; }
[JsonPropertyName("error")]
public string Error { get; private set; }
[JsonPropertyName("required")]
public bool Required { get; private set; }
[JsonPropertyName("array")]
public bool? Array { get; private set; }
[JsonPropertyName("$createdAt")]
public string CreatedAt { get; private set; }
[JsonPropertyName("$updatedAt")]
public string UpdatedAt { get; private set; }
[JsonPropertyName("format")]
public string Format { get; private set; }
[JsonPropertyName("default")]
public string? Default { get; private set; }
public AttributeIp(
string key,
string type,
AttributeStatus status,
string error,
bool required,
bool? array,
string createdAt,
string updatedAt,
string format,
string? xdefault
) {
Key = key;
Type = type;
Status = status;
Error = error;
Required = required;
Array = array;
CreatedAt = createdAt;
UpdatedAt = updatedAt;
Format = format;
Default = xdefault;
}
public static AttributeIp From(Dictionary<string, object> map) => new AttributeIp(
key: map["key"].ToString(),
type: map["type"].ToString(),
status: new AttributeStatus(map["status"].ToString()!),
error: map["error"].ToString(),
required: (bool)map["required"],
array: (bool?)map["array"],
createdAt: map["$createdAt"].ToString(),
updatedAt: map["$updatedAt"].ToString(),
format: map["format"].ToString(),
xdefault: map.TryGetValue("default", out var xdefault) ? xdefault?.ToString() : null
);
public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
{
{ "key", Key },
{ "type", Type },
{ "status", Status.Value },
{ "error", Error },
{ "required", Required },
{ "array", Array },
{ "$createdAt", CreatedAt },
{ "$updatedAt", UpdatedAt },
{ "format", Format },
{ "default", Default }
};
}
}