mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-10 05:56:42 +00:00
Add client method to get project list
This commit is contained in:
parent
24c6701b01
commit
7772195f85
@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/simon987/task_tracker/api"
|
||||
"github.com/simon987/task_tracker/storage"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@ -142,6 +143,15 @@ func (c taskTrackerClient) GetProjectSecret(projectId int) (string, error) {
|
||||
return jsonResp.Content.Secret, err
|
||||
}
|
||||
|
||||
func (c taskTrackerClient) GetProjectList() ([]storage.Project, error) {
|
||||
|
||||
httpResp := c.get("/project/list")
|
||||
var jsonResp ProjectListResponse
|
||||
err := unmarshalResponse(httpResp, &jsonResp)
|
||||
|
||||
return jsonResp.Content.Projects, err
|
||||
}
|
||||
|
||||
func (c taskTrackerClient) RequestAccess(req api.CreateWorkerAccessRequest) (api.JsonResponse, error) {
|
||||
|
||||
httpResp := c.post("/project/request_access", req)
|
||||
|
@ -52,3 +52,11 @@ type ProjectSecretResponse struct {
|
||||
Secret string `json:"secret"`
|
||||
} `json:"content"`
|
||||
}
|
||||
|
||||
type ProjectListResponse struct {
|
||||
Ok bool `json:"ok"`
|
||||
Message string `json:"message"`
|
||||
Content struct {
|
||||
Projects []storage.Project `json:"projects,omitempty"`
|
||||
} `json:"content"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user