-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUser.cs
More file actions
113 lines (96 loc) · 4.86 KB
/
User.cs
File metadata and controls
113 lines (96 loc) · 4.86 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System.Threading.Tasks;
using Contentstack.Management.Core.Services.User;
namespace Contentstack.Management.Core.Models
{
/// <summary>
/// <see cref="User" /> session consists of calls that will help you to sign in and sign out of your Contentstack account.
/// </summary>
public class User
{
private readonly ContentstackClient _client;
#region Constructor
internal User(ContentstackClient contentstackClient)
{
_client = contentstackClient;
}
#endregion
#region Password
/// <summary>
/// The Forgot password call sends a request for a temporary password to log in to an account in case a user has forgotten the login password.
/// </summary>
/// <param name="email">The email for the account that user has forgotten the login password</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// User user = client.User();
/// ContentstackResponse contentstackResponse = client.ForgotPassword("<EMAIL>");
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse" />.</returns>
public ContentstackResponse ForgotPassword(string email)
{
_client.ThrowIfAlreadyLoggedIn();
var forgotPassword = new ForgotPasswordService(_client.serializer, email);
return _client.InvokeSync(forgotPassword);
}
/// <summary>
/// The Forgot password call sends a request for a temporary password to log in to an account in case a user has forgotten the login password.
/// </summary>
/// <param name="email">The email for the account that user has forgotten the login password</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// User user = client.User();
/// ContentstackResponse contentstackResponse = await client.ForgotPasswordAsync("<EMAIL>");
/// </code></pre>
/// </example>
/// <returns>The Task.</returns>
public Task<ContentstackResponse> ForgotPasswordAsync(string email)
{
_client.ThrowIfAlreadyLoggedIn();
var forgotPassword = new ForgotPasswordService(_client.serializer, email);
return _client.InvokeAsync<ForgotPasswordService, ContentstackResponse>(forgotPassword);
}
/// <summary>
/// The Reset password call sends a request for resetting the password of your Contentstack account.
/// </summary>
/// <param name="resetToken">The reset password token send to email.</param>
/// <param name="password">The password for the account.</param>
/// <param name="confirmPassword">The confirm password for the account.</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// User user = client.User();
/// ContentstackResponse contentstackResponse = client.ResetPassword("<REST_TOKEN>", "<PASSWORD>", "<CONFIRM_PASSWORD>");
/// </code></pre>
/// </example>
/// <returns>The <see cref="ContentstackResponse"/></returns>
public ContentstackResponse ResetPassword(string resetToken, string password, string confirmPassword)
{
_client.ThrowIfAlreadyLoggedIn();
var resetPassword = new ResetPasswordService(_client.serializer, resetToken, password, confirmPassword);
return _client.InvokeSync(resetPassword);
}
/// <summary>
/// The Reset password call sends a request for resetting the password of your Contentstack account.
/// </summary>
/// <param name="resetToken">The reset password token send to email.</param>
/// <param name="password">The password for the account.</param>
/// <param name="confirmPassword">The confirm password for the account.</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// User user = client.User();
/// ContentstackResponse contentstackResponse = await client.ResetPasswordAsync("<REST_TOKEN>", "<PASSWORD>", "<CONFIRM_PASSWORD>");
/// </code></pre>
/// </example>
/// <returns>The Task.</returns>
public Task<ContentstackResponse> ResetPasswordAsync(string resetToken, string password, string confirmPassword)
{
_client.ThrowIfAlreadyLoggedIn();
var resetPassword = new ResetPasswordService(_client.serializer, resetToken, password, confirmPassword);
return _client.InvokeAsync<ResetPasswordService, ContentstackResponse>(resetPassword);
}
#endregion
}
}