blob: 65df4608bf53d5b0fba044f4c9b62376a06bfd5d (
plain)
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
|
package dto
import (
"bytes"
"encoding/json"
)
type TokenEndpointAuthMethod int
const (
None TokenEndpointAuthMethod = iota
ClientSecretPost
ClientSecretBasic
)
var toString = map[TokenEndpointAuthMethod]string{
None: "none",
ClientSecretPost: "client_secret_post",
ClientSecretBasic: "client_secret_basic",
}
var toID = map[string]TokenEndpointAuthMethod{
"none": None,
"client_secret_post": ClientSecretPost,
"client_secret_basic": ClientSecretBasic,
}
func (x TokenEndpointAuthMethod) MarshalJSON() ([]byte, error) {
buffer := bytes.NewBufferString(`"`)
buffer.WriteString(toString[x])
buffer.WriteString(`"`)
return buffer.Bytes(), nil
}
func (x *TokenEndpointAuthMethod) UnmarshalJSON(b []byte) error {
var val string
if err := json.Unmarshal(b, &val); err != nil {
return err
}
*x = toID[val]
return nil
}
func (x TokenEndpointAuthMethod) String() string {
return toString[x]
}
|