forked from desertbit/wego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_swimlanes.go
116 lines (94 loc) · 2.79 KB
/
client_swimlanes.go
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
/**
* Copyright (c) 2023 Sebastian Borchers
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
package wego
import (
"context"
"errors"
"io"
)
// GetAllSwimlanes performs a get_all_swimlanes request against the Wekan server.
// See https://wekan.github.io/api/v5.13/#get_all_swimlanes
func (c *Client) GetAllSwimlanes(ctx context.Context, boardID string) (swimlanes []GetAllSwimlane, err error) {
endpoint := c.endpoint("boards", boardID, "swimlanes")
req, err := c.newAuthenticatedGETRequest(ctx, endpoint)
if err != nil {
return
}
err = c.doSimpleRequest(req, &swimlanes)
if err != nil {
return
}
return
}
// NewSwimlane performs a new_swimlane request against the Wekan server.
// See https://wekan.github.io/api/v5.13/#new_swimlane
func (c *Client) NewSwimlane(ctx context.Context, boardID, title string) (r NewSwimlaneResponse, err error) {
endpoint := c.endpoint("boards", boardID, "swimlanes")
req, err := c.newAuthenticatedPOSTRequest(ctx, endpoint, newSwimlaneRequest{Title: title})
if err != nil {
return
}
err = c.doSimpleRequest(req, &r)
if err != nil {
return
}
return
}
// GetSwimlane performs a get_swimlane request against the Wekan server.
// See https://wekan.github.io/api/v5.13/#get_swimlane
//
// Returns ErrNotFound, if the swimlane could not be found.
func (c *Client) GetSwimlane(ctx context.Context, boardID, swimlaneID string) (swimlane GetSwimlane, err error) {
endpoint := c.endpoint("boards", boardID, "swimlanes", swimlaneID)
req, err := c.newAuthenticatedGETRequest(ctx, endpoint)
if err != nil {
return
}
err = c.doSimpleRequest(req, &swimlane)
if err != nil {
if errors.Is(err, io.EOF) {
err = ErrNotFound
}
return
}
return
}
// DeleteSwimlane performs a delete_swimlane request against the Wekan server.
// See https://wekan.github.io/api/v5.13/#delete_swimlane
func (c *Client) DeleteSwimlane(ctx context.Context, boardID, swimlaneID string) (err error) {
endpoint := c.endpoint("boards", boardID, "swimlanes", swimlaneID)
req, err := c.newAuthenticatedDELETERequest(ctx, endpoint)
if err != nil {
return
}
return c.doSimpleRequest(req, nil)
}
//#############//
//### Types ###//
//#############//
type GetAllSwimlane struct {
ID string `json:"_id"`
Title string `json:"title"`
}
type newSwimlaneRequest struct {
Title string `json:"title"`
}
type NewSwimlaneResponse struct {
ID string `json:"_id"`
}
type GetSwimlane struct {
Title string `json:"title"`
Archived bool `json:"archived"`
ArchivedAt string `json:"archivedAt"`
BoardID string `json:"boardId"`
CreatedAt string `json:"createdAt"`
Sort int `json:"sort"`
Color string `json:"color"`
UpdatedAt string `json:"updatedAt"`
ModifiedAt string `json:"modifiedAt"`
Type string `json:"type"`
}