-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathClockifyClient.Workspaces.cs
More file actions
52 lines (47 loc) · 2.02 KB
/
Copy pathClockifyClient.Workspaces.cs
File metadata and controls
52 lines (47 loc) · 2.02 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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Clockify.Net.Models;
using Clockify.Net.Models.Workspaces;
using RestSharp;
namespace Clockify.Net
{
public partial class ClockifyClient
{
/// <summary>
/// Find workspaces for currently logged in user
/// </summary>
public async Task<Response<List<WorkspaceDto>>> GetWorkspacesAsync()
{
var request = new RestRequest("workspaces");
return Response<List<WorkspaceDto>>.FromRestResponse(await _client.ExecuteGetAsync<List<WorkspaceDto>>(request).ConfigureAwait(false));
}
/// <summary>
/// Creates new workspace.
/// </summary>
public async Task<Response<WorkspaceDto>> CreateWorkspaceAsync(WorkspaceRequest workspaceRequest)
{
var request = new RestRequest("workspaces", Method.Post);
request.AddJsonBody(workspaceRequest);
return Response<WorkspaceDto>.FromRestResponse(await _client.ExecutePostAsync<WorkspaceDto>(request).ConfigureAwait(false));
}
/// <summary>
/// Delete workspace with Id.
/// </summary>
[Obsolete("Changing active workplace was removed from the experimental API")]
public async Task<Response> DeleteWorkspaceAsync(string id)
{
var request = new RestRequest($"workspaces/{id}");
return Response.FromRestResponse(await _client.ExecuteAsync(request, Method.Delete).ConfigureAwait(false));
}
/// <summary>
/// Adds a user to workspace.
/// </summary>
public async Task<Response<List<WorkspaceDto>>> AddWorkspaceUser(string workspaceId, WorkspaceAddUserRequest requestBody)
{
var request = new RestRequest($"/workspaces/{workspaceId}/users");
request.AddJsonBody(requestBody);
return Response<List<WorkspaceDto>>.FromRestResponse(await _client.ExecuteAsync<List<WorkspaceDto>>(request, Method.Post).ConfigureAwait(false));
}
}
}