-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsearch.go
35 lines (27 loc) · 865 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
package zed
import "fmt"
// OrganizationSearchResponse struct
type OrganizationSearchResponse struct {
Organizations []Organization `json:"results,omitempty"`
NextPage *string `json:"next_page,omitempty"`
PreviousPage *string `json:"previous_page,omitempty"`
Count *int `json:"count,omitempty"`
}
// SearchService struct
type SearchService struct {
client *Client
}
// OrganizationByName searches the organization by name
func (s *SearchService) OrganizationByName(name string) (*OrganizationSearchResponse, error) {
result := &OrganizationSearchResponse{}
url := fmt.Sprintf("search.json?query=type:organization+name:%s", name)
req, err := s.client.NewRequest("GET", url, nil)
if err != nil {
return nil, err
}
_, err = s.client.Do(req, result)
if err != nil {
return nil, err
}
return result, nil
}