-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.go
41 lines (32 loc) · 808 Bytes
/
delete.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
package smmssdk
import (
"context"
"fmt"
"net/http"
)
type DeleteRequest struct {
Hash string `json:"hash"`
Format string `json:"format"`
}
func (r *DeleteRequest) Request(ctx context.Context) (*http.Request, error) {
method := http.MethodGet
url := fmt.Sprintf("%s/delete/%s", baseURL, r.Hash)
return http.NewRequestWithContext(ctx, method, url, nil)
}
func NewDeleteRequest() *DeleteRequest {
return &DeleteRequest{}
}
type DeleteResponse struct {
baseResponse
}
func (c *Client) Delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) {
return c.delete(ctx, req)
}
func (c *Client) delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) {
var rsp DeleteResponse
err := c.Do(ctx, req, &rsp)
if err != nil {
return nil, err
}
return &rsp, nil
}