| 152 | } |
| 153 | |
| 154 | func (f TasksFilter) asRequestOption() RequestOption { |
| 155 | return func(r *http.Request) { |
| 156 | var params []string |
| 157 | // Make sure all user input is quoted to ensure it's parsed as a single |
| 158 | // string. |
| 159 | if f.Owner != "" { |
| 160 | params = append(params, fmt.Sprintf("owner:%q", f.Owner)) |
| 161 | } |
| 162 | if f.Organization != "" { |
| 163 | params = append(params, fmt.Sprintf("organization:%q", f.Organization)) |
| 164 | } |
| 165 | if f.Status != "" { |
| 166 | params = append(params, fmt.Sprintf("status:%q", string(f.Status))) |
| 167 | } |
| 168 | if f.FilterQuery != "" { |
| 169 | // If custom stuff is added, just add it on here. |
| 170 | params = append(params, f.FilterQuery) |
| 171 | } |
| 172 | |
| 173 | q := r.URL.Query() |
| 174 | q.Set("q", strings.Join(params, " ")) |
| 175 | r.URL.RawQuery = q.Encode() |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // Tasks lists all tasks belonging to the user or specified owner. |
| 180 | func (c *Client) Tasks(ctx context.Context, filter *TasksFilter) ([]Task, error) { |