/
comment_client.go
164 lines (135 loc) · 3.81 KB
/
comment_client.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package comment
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-swagger/go-swagger/client"
"github.com/go-swagger/go-swagger/strfmt"
)
// New creates a new comment API client.
func New(transport client.Transport, formats strfmt.Registry) *Client {
return &Client{transport: transport, formats: formats}
}
/*
Client for comment API
*/
type Client struct {
transport client.Transport
formats strfmt.Registry
}
/*删除评论
删除指定评论
*/
func (a *Client) DeleteCommentsID(params *DeleteCommentsIDParams, authInfo client.AuthInfoWriter) (*DeleteCommentsIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteCommentsIDParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "DeleteCommentsID",
Params: params,
Reader: &DeleteCommentsIDReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*DeleteCommentsIDOK), nil
}
/*查看评论列表
查看所有评论,支持分页和过滤器
*/
func (a *Client) GetComments(params *GetCommentsParams, authInfo client.AuthInfoWriter) (*GetCommentsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetCommentsParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "GetComments",
Params: params,
Reader: &GetCommentsReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*GetCommentsOK), nil
}
/*查询评论
得到指定评论的具体信息
*/
func (a *Client) GetCommentsID(params *GetCommentsIDParams, authInfo client.AuthInfoWriter) (*GetCommentsIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetCommentsIDParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "GetCommentsID",
Params: params,
Reader: &GetCommentsIDReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*GetCommentsIDOK), nil
}
/*创建评论
根据请求创建评论
*/
func (a *Client) PostComments(params *PostCommentsParams, authInfo client.AuthInfoWriter) (*PostCommentsCreated, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPostCommentsParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "PostComments",
Params: params,
Reader: &PostCommentsReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*PostCommentsCreated), nil
}
/*更新评论
根据请求中指定要更新的属性对评论进行更新
*/
func (a *Client) PutCommentsID(params *PutCommentsIDParams, authInfo client.AuthInfoWriter) (*PutCommentsIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPutCommentsIDParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "PutCommentsID",
Params: params,
Reader: &PutCommentsIDReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*PutCommentsIDOK), nil
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport client.Transport) {
a.transport = transport
}
// NewAPIError creates a new API error
func NewAPIError(opName string, response interface{}, code int) APIError {
return APIError{
OperationName: opName,
Response: response,
Code: code,
}
}
// APIError wraps an error model and captures the status code
type APIError struct {
OperationName string
Response interface{}
Code int
}
func (a APIError) Error() string {
return fmt.Sprintf("%s (status %d): %+v ", a.OperationName, a.Code, a.Response)
}