forked from LeanKit/LeanKit.API.Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuth.cs
More file actions
51 lines (46 loc) · 1.27 KB
/
Auth.cs
File metadata and controls
51 lines (46 loc) · 1.27 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
using System;
using System.Threading.Tasks;
using LeanKit.Extensions;
using LeanKit.Models;
namespace LeanKit.API
{
public class Auth
{
private readonly Client _client;
private readonly Token _token;
public Auth(Client client)
{
_client = client;
_token = new Token(client);
}
public Token Token
{
get { return _token; }
}
}
public class Token
{
private readonly Client _client;
public Token(Client client)
{
_client = client;
}
public async Task<TokenList> List()
{
return await _client.Request<TokenList>("io/auth/token");
}
public async Task<TokenCreateResponse> Create(string description)
{
if (string.IsNullOrWhiteSpace(description))
{
throw new ArgumentException("Description is required");
}
var body = new { description };
return await _client.Request<TokenCreateResponse>("/io/auth/token", "POST", body: body.ToJSON());
}
public async Task Revoke(long id)
{
await _client.Request<string>(string.Format("/io/auth/token/{0}", id), "DELETE");
}
}
}