/
Account.cs
208 lines (184 loc) · 7.71 KB
/
Account.cs
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// <auto-generated>
// Auto-generated by StoneAPI, do not modify.
// </auto-generated>
namespace Dropbox.Api.Users
{
using sys = System;
using col = System.Collections.Generic;
using re = System.Text.RegularExpressions;
using enc = Dropbox.Api.Stone;
/// <summary>
/// <para>The amount of detail revealed about an account depends on the user being queried
/// and the user making the query.</para>
/// </summary>
/// <seealso cref="BasicAccount" />
/// <seealso cref="FullAccount" />
public class Account
{
#pragma warning disable 108
/// <summary>
/// <para>The encoder instance.</para>
/// </summary>
internal static enc.StructEncoder<Account> Encoder = new AccountEncoder();
/// <summary>
/// <para>The decoder instance.</para>
/// </summary>
internal static enc.StructDecoder<Account> Decoder = new AccountDecoder();
/// <summary>
/// <para>Initializes a new instance of the <see cref="Account" /> class.</para>
/// </summary>
/// <param name="accountId">The user's unique Dropbox ID.</param>
/// <param name="name">Details of a user's name.</param>
/// <param name="email">The user's email address. Do not rely on this without checking
/// the <paramref name="emailVerified" /> field. Even then, it's possible that the user
/// has since lost access to their email.</param>
/// <param name="emailVerified">Whether the user has verified their email
/// address.</param>
/// <param name="disabled">Whether the user has been disabled.</param>
/// <param name="profilePhotoUrl">URL for the photo representing the user, if one is
/// set.</param>
public Account(string accountId,
Name name,
string email,
bool emailVerified,
bool disabled,
string profilePhotoUrl = null)
{
if (accountId == null)
{
throw new sys.ArgumentNullException("accountId");
}
if (accountId.Length < 40)
{
throw new sys.ArgumentOutOfRangeException("accountId", "Length should be at least 40");
}
if (accountId.Length > 40)
{
throw new sys.ArgumentOutOfRangeException("accountId", "Length should be at most 40");
}
if (name == null)
{
throw new sys.ArgumentNullException("name");
}
if (email == null)
{
throw new sys.ArgumentNullException("email");
}
this.AccountId = accountId;
this.Name = name;
this.Email = email;
this.EmailVerified = emailVerified;
this.Disabled = disabled;
this.ProfilePhotoUrl = profilePhotoUrl;
}
/// <summary>
/// <para>Initializes a new instance of the <see cref="Account" /> class.</para>
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
[sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)]
public Account()
{
}
/// <summary>
/// <para>The user's unique Dropbox ID.</para>
/// </summary>
public string AccountId { get; protected set; }
/// <summary>
/// <para>Details of a user's name.</para>
/// </summary>
public Name Name { get; protected set; }
/// <summary>
/// <para>The user's email address. Do not rely on this without checking the <see
/// cref="EmailVerified" /> field. Even then, it's possible that the user has since
/// lost access to their email.</para>
/// </summary>
public string Email { get; protected set; }
/// <summary>
/// <para>Whether the user has verified their email address.</para>
/// </summary>
public bool EmailVerified { get; protected set; }
/// <summary>
/// <para>Whether the user has been disabled.</para>
/// </summary>
public bool Disabled { get; protected set; }
/// <summary>
/// <para>URL for the photo representing the user, if one is set.</para>
/// </summary>
public string ProfilePhotoUrl { get; protected set; }
#region Encoder class
/// <summary>
/// <para>Encoder for <see cref="Account" />.</para>
/// </summary>
private class AccountEncoder : enc.StructEncoder<Account>
{
/// <summary>
/// <para>Encode fields of given value.</para>
/// </summary>
/// <param name="value">The value.</param>
/// <param name="writer">The writer.</param>
public override void EncodeFields(Account value, enc.IJsonWriter writer)
{
WriteProperty("account_id", value.AccountId, writer, enc.StringEncoder.Instance);
WriteProperty("name", value.Name, writer, global::Dropbox.Api.Users.Name.Encoder);
WriteProperty("email", value.Email, writer, enc.StringEncoder.Instance);
WriteProperty("email_verified", value.EmailVerified, writer, enc.BooleanEncoder.Instance);
WriteProperty("disabled", value.Disabled, writer, enc.BooleanEncoder.Instance);
if (value.ProfilePhotoUrl != null)
{
WriteProperty("profile_photo_url", value.ProfilePhotoUrl, writer, enc.StringEncoder.Instance);
}
}
}
#endregion
#region Decoder class
/// <summary>
/// <para>Decoder for <see cref="Account" />.</para>
/// </summary>
private class AccountDecoder : enc.StructDecoder<Account>
{
/// <summary>
/// <para>Create a new instance of type <see cref="Account" />.</para>
/// </summary>
/// <returns>The struct instance.</returns>
protected override Account Create()
{
return new Account();
}
/// <summary>
/// <para>Set given field.</para>
/// </summary>
/// <param name="value">The field value.</param>
/// <param name="fieldName">The field name.</param>
/// <param name="reader">The json reader.</param>
protected override void SetField(Account value, string fieldName, enc.IJsonReader reader)
{
switch (fieldName)
{
case "account_id":
value.AccountId = enc.StringDecoder.Instance.Decode(reader);
break;
case "name":
value.Name = global::Dropbox.Api.Users.Name.Decoder.Decode(reader);
break;
case "email":
value.Email = enc.StringDecoder.Instance.Decode(reader);
break;
case "email_verified":
value.EmailVerified = enc.BooleanDecoder.Instance.Decode(reader);
break;
case "disabled":
value.Disabled = enc.BooleanDecoder.Instance.Decode(reader);
break;
case "profile_photo_url":
value.ProfilePhotoUrl = enc.StringDecoder.Instance.Decode(reader);
break;
default:
reader.Skip();
break;
}
}
}
#endregion
}
}