-
Notifications
You must be signed in to change notification settings - Fork 1
/
application_role.go
82 lines (66 loc) · 2.08 KB
/
application_role.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
package rest
import (
"context"
"encoding/json"
"fmt"
"net/http"
"wumpgo.dev/wumpgo/objects"
)
func (c *Client) GetApplicationRoleConnectionMetadataRecords(ctx context.Context, application objects.Snowflake) ([]*objects.ApplicationRoleConnectionMetadata, error) {
metadata := []*objects.ApplicationRoleConnectionMetadata{}
err := NewRequest().
Method(http.MethodGet).
WithContext(ctx).
Path(fmt.Sprintf(ApplicationRoleConnection, application)).
ContentType(JsonContentType).
Bind(&metadata).
Send(c)
return metadata, err
}
func (c *Client) UpdateApplicationRoleConnectionMetadataRecords(
ctx context.Context, application objects.Snowflake, params []*objects.ApplicationRoleConnectionMetadata,
) ([]*objects.ApplicationRoleConnectionMetadata, error) {
metadata := []*objects.ApplicationRoleConnectionMetadata{}
data, err := json.Marshal(params)
if err != nil {
return nil, err
}
err = NewRequest().
Method(http.MethodPut).
WithContext(ctx).
Path(fmt.Sprintf(ApplicationRoleConnection, application)).
ContentType(JsonContentType).
Body(data).
Bind(&metadata).
Send(c)
return metadata, err
}
func (c *Client) GetUserApplicationRoleConnection(ctx context.Context, application objects.Snowflake) (*objects.ApplicationRoleConnection, error) {
var connection objects.ApplicationRoleConnection
err := NewRequest().
Method(http.MethodGet).
WithContext(ctx).
Path(fmt.Sprintf(UserApplicationRoleConnection, application)).
ContentType(JsonContentType).
Bind(&connection).
Send(c)
return &connection, err
}
func (c *Client) UpdateUserApplicationRoleConnection(
ctx context.Context, application objects.Snowflake, params *objects.ApplicationRoleConnection,
) (*objects.ApplicationRoleConnection, error) {
var connection objects.ApplicationRoleConnection
data, err := json.Marshal(params)
if err != nil {
return nil, err
}
err = NewRequest().
Method(http.MethodPut).
WithContext(ctx).
Path(fmt.Sprintf(UserApplicationRoleConnection, application)).
ContentType(JsonContentType).
Body(data).
Bind(&connection).
Send(c)
return &connection, err
}