Parameter cleanup
This commit is contained in:
@@ -21,17 +21,15 @@ type sectionAddTaskRequest struct {
|
|||||||
Data *sectionAddTaskData `json:"data"`
|
Data *sectionAddTaskData `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WorkspaceClient) GetSections(project *Project) ([]*Section, error) {
|
func (wc *WorkspaceClient) GetSections(project *Project) (ret []*Section, err error) {
|
||||||
path := fmt.Sprintf("projects/%s/sections", project.GID)
|
path := fmt.Sprintf("projects/%s/sections", project.GID)
|
||||||
values := &url.Values{}
|
values := &url.Values{}
|
||||||
|
|
||||||
ret := []*Section{}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
resp := §ionsResponse{}
|
resp := §ionsResponse{}
|
||||||
err := wc.client.get(path, values, resp)
|
err = wc.client.get(path, values, resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = append(ret, resp.Data...)
|
ret = append(ret, resp.Data...)
|
||||||
@@ -43,7 +41,7 @@ func (wc *WorkspaceClient) GetSections(project *Project) ([]*Section, error) {
|
|||||||
values.Set("offset", resp.NextPage.Offset)
|
values.Set("offset", resp.NextPage.Offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WorkspaceClient) GetSectionsByName(project *Project) (map[string]*Section, error) {
|
func (wc *WorkspaceClient) GetSectionsByName(project *Project) (map[string]*Section, error) {
|
||||||
@@ -92,15 +90,27 @@ func (wc *WorkspaceClient) AddTaskToSection(task *Task, section *Section) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WorkspaceClient) GetTasksFromSection(section *Section) ([]*Task, error) {
|
func (wc *WorkspaceClient) GetTasksFromSection(section *Section) (ret []*Task, err error) {
|
||||||
// TODO: Handle pagination
|
|
||||||
path := fmt.Sprintf("sections/%s/tasks", section.GID)
|
path := fmt.Sprintf("sections/%s/tasks", section.GID)
|
||||||
|
values := &url.Values{}
|
||||||
|
|
||||||
|
for {
|
||||||
resp := &tasksResponse{}
|
resp := &tasksResponse{}
|
||||||
err := wc.client.get(path, nil, resp)
|
err = wc.client.get(path, values, resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return
|
||||||
}
|
}
|
||||||
return resp.Data, nil
|
|
||||||
|
ret = append(ret, resp.Data...)
|
||||||
|
|
||||||
|
if resp.NextPage == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
values.Set("offset", resp.NextPage.Offset)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Section) String() string {
|
func (s *Section) String() string {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type taskResponse struct {
|
|||||||
|
|
||||||
type tasksResponse struct {
|
type tasksResponse struct {
|
||||||
Data []*Task `json:"data"`
|
Data []*Task `json:"data"`
|
||||||
|
NextPage *nextPage `json:"next_page"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type taskUpdate struct {
|
type taskUpdate struct {
|
||||||
|
|||||||
@@ -25,15 +25,14 @@ func (c *Client) InWorkspace(name string) (*WorkspaceClient, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetWorkspaces() ([]*Workspace, error) {
|
func (c *Client) GetWorkspaces() (ret []*Workspace, err error) {
|
||||||
values := &url.Values{}
|
values := &url.Values{}
|
||||||
ret := []*Workspace{}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
resp := &workspacesResponse{}
|
resp := &workspacesResponse{}
|
||||||
err := c.get("workspaces", values, resp)
|
err = c.get("workspaces", values, resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = append(ret, resp.Data...)
|
ret = append(ret, resp.Data...)
|
||||||
@@ -45,7 +44,7 @@ func (c *Client) GetWorkspaces() ([]*Workspace, error) {
|
|||||||
values.Set("offset", resp.NextPage.Offset)
|
values.Set("offset", resp.NextPage.Offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetWorkspaceByName(name string) (*Workspace, error) {
|
func (c *Client) GetWorkspaceByName(name string) (*Workspace, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user