-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwarning_list.go
55 lines (45 loc) · 1.24 KB
/
warning_list.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
package qweather
import (
"encoding/json"
"fmt"
"net/http"
)
// V7WarningListRequest 天气预警城市列表请求
type V7WarningListRequest struct {
baseRequest
Range string `json:"range"` // 选择指定的国家或地区,使用ISO 3166格式化,例如:range=cn,range=fr
}
func NewV7WarningListRequest() *V7WarningListRequest {
r := new(V7WarningListRequest)
return r
}
func (r *V7WarningListRequest) Method() string {
return http.MethodGet
}
func (r *V7WarningListRequest) Url() string {
return fmt.Sprintf("%s/v7/warning/list", Api)
}
func (r *V7WarningListRequest) String() string {
bs, _ := json.Marshal(r)
return string(bs)
}
// V7WarningListResponse 天气预警城市列表响应
type V7WarningListResponse struct {
baseResponse
UpdateTime string `json:"updateTime"` // 当前API的最近更新时间
WarningLoclList []struct {
LocationId string `json:"LocationId"` // 当前预警的LocationID
} `json:"warningLoclList"`
}
func (r *V7WarningListResponse) String() string {
bs, _ := json.Marshal(r)
return string(bs)
}
func (c *Client) V7WarningList(req *V7WarningListRequest) (*V7WarningListResponse, error) {
resp := new(V7WarningListResponse)
err := c.Do(req, resp)
if err != nil {
return nil, err
}
return resp, nil
}