diff --git a/client.go b/client.go index a2bbed9..fae6fd8 100644 --- a/client.go +++ b/client.go @@ -26,13 +26,21 @@ type JiraClient struct { Client *http.Client } -func (c JiraClient) get(url string) ([]byte, error) { +func (c JiraClient) get(url string, queryParams map[string]string) ([]byte, error) { req, err := http.NewRequest("GET", url, nil) if err != nil { return []byte{}, err } req.SetBasicAuth(c.Username, c.Token) + if queryParams != nil { + q := req.URL.Query() + for k, v := range queryParams { + q.Add(k, v) + } + req.URL.RawQuery = q.Encode() + } + resp, err := c.Client.Do(req) if err != nil { return []byte{}, err @@ -48,7 +56,7 @@ func (c JiraClient) GetIssue(keyOrId string) (Issue, error) { url := fmt.Sprintf("https://%s.atlassian.net/rest/api/2/issue/%s", c.Domain, keyOrId) - body, err := c.get(url) + body, err := c.get(url, nil) if err != nil { return issue, err } @@ -63,7 +71,7 @@ func (c JiraClient) GetProject(keyOrId string) (Project, error) { url := fmt.Sprintf("https://%s.atlassian.net/rest/api/2/project/%s", c.Domain, keyOrId) - body, err := c.get(url) + body, err := c.get(url, nil) if err != nil { return project, err }