-
Notifications
You must be signed in to change notification settings - Fork 0
/
seach-in-country.go
44 lines (35 loc) · 1.38 KB
/
seach-in-country.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
package locationiq
import (
"context"
)
// SearchLimitCountryURL represents search with limit country url
const SearchLimitCountryURL = "/v1/search.php"
// SearchLimitCountryRequest represents search request
type SearchLimitCountryRequest struct {
Query string `query:"q"`
Format string `query:"format"`
CountryCodes string `query:"countrycodes"`
}
// SearchLimitCountryResponse represents search response
type SearchLimitCountryResponse struct {
PlaceID string `json:"place_id"`
Licence string `json:"licence"`
OsmType string `json:"osm_type"`
OsmID string `json:"osm_id"`
Boundingbox []string `json:"boundingbox"`
Lat string `json:"lat"`
Lon string `json:"lon"`
DisplayName string `json:"display_name"`
Class string `json:"class"`
Type string `json:"type"`
Importance float64 `json:"importance"`
Icon string `json:"icon,omitempty"`
}
// SearchLimitCountry place
func (c *client) SearchLimitCountry(ctx context.Context, req SearchLimitCountryRequest) ([]SearchLimitCountryResponse, error) {
url := c.baseURLs[BackendService] + SearchLimitCountryURL + "?key=" + c.Key + "&q=" + req.Query + "&format=" + req.Format + "&countrycodes=" + req.CountryCodes
var res []SearchLimitCountryResponse
header := map[string]string{}
_, err := c.request(ctx, "GET", url, header, &req, &res)
return res, err
}