Actually moving tasks

This commit is contained in:
Ian Gulliver
2021-09-12 21:49:54 +00:00
parent 305b1a0f98
commit a2c25af435
4 changed files with 234 additions and 124 deletions

View File

@@ -40,15 +40,15 @@ func NewClientFromEnv() *Client {
}
func (c *Client) InWorkspace(name string) (*WorkspaceClient, error) {
wrk, err := c.getWorkspaceByName(name)
if err != nil {
return nil, err
}
wrk, err := c.getWorkspaceByName(name)
if err != nil {
return nil, err
}
return &WorkspaceClient{
client: c,
workspace: wrk,
}, nil
return &WorkspaceClient{
client: c,
workspace: wrk,
}, nil
}
func (c *Client) getWorkspaces() ([]*workspace, error) {
@@ -66,13 +66,13 @@ func (c *Client) getWorkspaceByName(name string) (*workspace, error) {
return nil, err
}
for _, wrk := range wrks {
if wrk.Name == name {
return wrk, nil
}
}
for _, wrk := range wrks {
if wrk.Name == name {
return wrk, nil
}
}
return nil, fmt.Errorf("Workspace `%s` not found", name)
return nil, fmt.Errorf("Workspace `%s` not found", name)
}
const baseURL = "https://app.asana.com/api/1.0/"
@@ -98,8 +98,8 @@ func (c *Client) get(path string, values *url.Values, out interface{}) error {
dec := json.NewDecoder(resp.Body)
if resp.StatusCode != 200 {
errorResp := &errorResponse{}
err = dec.Decode(errorResp)
errorResp := &errorResponse{}
err = dec.Decode(errorResp)
if err != nil {
return err
}