forked from ao-space/platform-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteClient.go
More file actions
40 lines (32 loc) · 853 Bytes
/
DeleteClient.go
File metadata and controls
40 lines (32 loc) · 853 Bytes
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
package platform
import (
"fmt"
"github.com/ao-space/platform-sdk-go/utils"
"github.com/jinzhu/copier"
"net/http"
"net/url"
)
type DeleteClientRequest struct {
UserId string
ClientUUID string
}
func (c *Client) DeleteClient(input *DeleteClientRequest) error {
if !c.IsAvailable(uriDeleteClient, http.MethodDelete) {
return fmt.Errorf("the ability is not available: [%v] %v ", http.MethodDelete, uriDeleteClient)
}
path := fmt.Sprintf("platform/boxes/%v/users/%v/clients/%v", c.BoxUUID, input.UserId, input.ClientUUID)
URL := new(url.URL)
copier.Copy(URL, c.BaseURL)
URL = URL.JoinPath(path)
op := new(Operation)
op.SetOperation(http.MethodDelete, URL)
resp, err := c.Send(op, nil)
if err != nil {
return err
}
if resp.StatusCode != http.StatusNoContent {
err = utils.GetBody(resp, nil)
return err
}
return nil
}