forked from jarias/stormpath-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_data.go
38 lines (29 loc) · 1.19 KB
/
custom_data.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
package stormpath
type customDataAwareResource struct {
resource
CustomData *CustomData `json:"customData,omitempty"`
}
//CustomData represents Stormpath's custom data resouce
type CustomData map[string]interface{}
//GetCustomData returns the given resource custom data
//
//See: http://docs.stormpath.com/rest/product-guide/#custom-data
func (r *customDataAwareResource) GetCustomData() (CustomData, error) {
customData := make(CustomData)
err := client.get(buildAbsoluteURL(r.Href, "customData"), emptyPayload(), &customData)
return customData, err
}
//UpdateCustomData sets or updates the given resource custom data
//
//See: http://docs.stormpath.com/rest/product-guide/#custom-data
func (r *customDataAwareResource) UpdateCustomData(customData CustomData) (CustomData, error) {
customData = cleanCustomData(customData)
err := client.post(buildAbsoluteURL(r.Href, "customData"), customData, &customData)
return customData, err
}
//DeleteCustomData deletes all the resource custom data
//
//See: http://docs.stormpath.com/rest/product-guide/#custom-data
func (r *customDataAwareResource) DeleteCustomData() error {
return client.delete(buildAbsoluteURL(r.Href, "customData"), emptyPayload())
}