mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-18 01:46:45 +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"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/simon987/task_tracker/api"
|
"github.com/simon987/task_tracker/api"
|
||||||
|
"github.com/simon987/task_tracker/storage"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -142,6 +143,15 @@ func (c taskTrackerClient) GetProjectSecret(projectId int) (string, error) {
|
|||||||
return jsonResp.Content.Secret, err
|
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) {
|
func (c taskTrackerClient) RequestAccess(req api.CreateWorkerAccessRequest) (api.JsonResponse, error) {
|
||||||
|
|
||||||
httpResp := c.post("/project/request_access", req)
|
httpResp := c.post("/project/request_access", req)
|
||||||
|
@ -52,3 +52,11 @@ type ProjectSecretResponse struct {
|
|||||||
Secret string `json:"secret"`
|
Secret string `json:"secret"`
|
||||||
} `json:"content"`
|
} `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