forked from tears-of-noobs/gojira
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.go
41 lines (36 loc) · 870 Bytes
/
search.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package gojira
import (
"encoding/json"
"fmt"
"net/http"
)
func RawSearch(jql string) ([]byte, error) {
url := fmt.Sprintf("%s/search?jql=%s", BaseUrl, jql)
code, body := execRequest("GET", url, nil)
if code == http.StatusOK {
return body, nil
} else {
return nil, handleJiraError(body)
}
}
type Filter struct {
SearchUrl string `json:"searchUrl"`
}
func FilterSearch(id int) ([]byte, error) {
url := fmt.Sprintf("%s/filter/%d", BaseUrl, id)
code, body := execRequest("GET", url, nil)
if code != http.StatusOK {
return nil, handleJiraError(body)
}
filter := Filter{}
err := json.Unmarshal(body, &filter)
if err != nil {
return nil, fmt.Errorf("error parsing filter: %s", err.Error())
}
code, body = execRequest("GET", filter.SearchUrl, nil)
if code == http.StatusOK {
return body, nil
} else {
return nil, handleJiraError(body)
}
}