This repository has been archived by the owner on Jul 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
search.go
91 lines (73 loc) · 2.56 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package octokit
import (
"github.com/jingweno/go-sawyer/hypermedia"
"net/url"
)
var SearchURL = Hyperlink("search{/type}?q={query}{&page,per_page,sort,order}")
func (c *Client) Search(url *url.URL) (searches *SearchService) {
searches = &SearchService{client: c, URL: url}
return
}
// A service to return search records
type SearchService struct {
client *Client
URL *url.URL
}
// Get the user search results based on SearchService#URL
func (g *SearchService) Users() (userSearchResults UserSearchResults,
result *Result) {
result = g.client.get(g.URL, &userSearchResults)
return
}
// Get the issue search results based on SearchService#URL
func (g *SearchService) Issues() (issueSearchResults IssueSearchResults,
result *Result) {
result = g.client.get(g.URL, &issueSearchResults)
return
}
// Get the repository search results based on SearchService#URL
func (g *SearchService) Repositories() (
repositorySearchResults RepositorySearchResults, result *Result) {
result = g.client.get(g.URL, &repositorySearchResults)
return
}
// Get the code search results based on SearchService#URL
func (g *SearchService) Code() (
codeSearchResults CodeSearchResults, result *Result) {
result = g.client.get(g.URL, &codeSearchResults)
return
}
type UserSearchResults struct {
*hypermedia.HALResource
TotalCount int `json:"total_count,omitempty"`
IncompleteResults bool `json:"incomplete_results,omitempty"`
Items []User `json:"items,omitempty"`
}
type IssueSearchResults struct {
*hypermedia.HALResource
TotalCount int `json:"total_count,omitempty"`
IncompleteResults bool `json:"incomplete_results,omitempty"`
Items []Issue `json:"items,omitempty"`
}
type RepositorySearchResults struct {
*hypermedia.HALResource
TotalCount int `json:"total_count,omitempty"`
IncompleteResults bool `json:"incomplete_results,omitempty"`
Items []Repository `json:"items,omitempty"`
}
type CodeSearchResults struct {
*hypermedia.HALResource
TotalCount int `json:"total_count,omitempty"`
IncompleteResults bool `json:"incomplete_results,omitempty"`
Items []CodeFile `json:"items,omitempty"`
}
type CodeFile struct {
*hypermedia.HALResource
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
SHA string `json:"sha,omitempty"`
URL Hyperlink `json:"url,omitempty"`
GitURL Hyperlink `json:"git_url,omitempty"`
HTMLURL Hyperlink `json:"html_url,omitempty"`
Repository Repository `json:"repository,omitempty"`
}