-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUserActions.cs
33 lines (30 loc) · 1.17 KB
/
UserActions.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
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MondayApi.Schema;
//https://developer.monday.com/api-reference/docs/users
namespace MondayApi.Users {
public class UserActions : IUserActions {
private readonly IMondayApiClient client;
public UserActions(IMondayApiClient client) {
this.client = client;
}
public async Task<IEnumerable<User>> Get(int? pageNumber = null, int? numPerPage = null) {
var query = new QueryQueryBuilder().WithUsers(
new UserQueryBuilder().WithAllScalarFields().ExceptEncryptApiToken(),
page: pageNumber,
limit: numPerPage
);
var response = await client.RunQuery(query);
return response.Users;
}
public async Task<User> GetOne(string id) {
var query = new QueryQueryBuilder().WithUsers(
new UserQueryBuilder().WithAllScalarFields().ExceptEncryptApiToken(),
ids: new string[] { id }
);
var response = await client.RunQuery(query);
return response.Users?.FirstOrDefault();
}
}
}