-
-
Notifications
You must be signed in to change notification settings - Fork 931
/
request_method.go
98 lines (75 loc) · 2.54 KB
/
request_method.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package recovery
import (
"database/sql/driver"
"encoding/json"
"time"
"github.com/ory/x/sqlxx"
"github.com/gofrs/uuid"
"github.com/ory/kratos/selfservice/form"
)
// swagger:model recoveryRequestMethod
type RequestMethod struct {
// Method contains the request credentials type.
Method string `json:"method" db:"method"`
// Config is the credential type's config.
Config *RequestMethodConfig `json:"config" db:"config"`
// ID is a helper struct field for gobuffalo.pop.
ID uuid.UUID `json:"-" db:"id"`
// FlowID is a helper struct field for gobuffalo.pop.
FlowID uuid.UUID `json:"-" db:"selfservice_flow_request_id"`
// Flow is a helper struct field for gobuffalo.pop.
Flow *Request `json:"-" belongs_to:"selfservice_flow_request" fk_id:"FlowID"`
// CreatedAt is a helper struct field for gobuffalo.pop.
CreatedAt time.Time `json:"-" db:"created_at"`
// UpdatedAt is a helper struct field for gobuffalo.pop.
UpdatedAt time.Time `json:"-" db:"updated_at"`
}
func (u RequestMethod) TableName() string {
return "selfservice_recovery_request_methods"
}
type RequestMethodsRaw []RequestMethod // workaround for https://github.com/gobuffalo/pop/pull/478
type RequestMethods map[string]*RequestMethod
func (u RequestMethods) TableName() string {
// This must be stay a value receiver, using a pointer receiver will cause issues with pop.
return "selfservice_recovery_flow_methods"
}
func (u RequestMethodsRaw) TableName() string {
// This must be stay a value receiver, using a pointer receiver will cause issues with pop.
return "selfservice_recovery_flow_methods"
}
// swagger:ignore
type RequestMethodConfigurator interface {
form.ErrorParser
form.FieldSetter
form.FieldUnsetter
form.ValueSetter
form.Resetter
form.MessageResetter
form.CSRFSetter
form.FieldSorter
form.MessageAdder
}
// swagger:type recoveryRequestConfigPayload
type RequestMethodConfig struct {
// swagger:ignore
RequestMethodConfigurator
swaggerRequestMethodConfig
}
// swagger:model recoveryRequestConfigPayload
type swaggerRequestMethodConfig struct {
*form.HTMLForm
}
func (c *RequestMethodConfig) Scan(value interface{}) error {
return sqlxx.JSONScan(c, value)
}
func (c *RequestMethodConfig) Value() (driver.Value, error) {
return sqlxx.JSONValue(c)
}
func (c *RequestMethodConfig) UnmarshalJSON(data []byte) error {
c.RequestMethodConfigurator = form.NewHTMLForm("")
return json.Unmarshal(data, c.RequestMethodConfigurator)
}
func (c *RequestMethodConfig) MarshalJSON() ([]byte, error) {
out, err := json.Marshal(c.RequestMethodConfigurator)
return out, err
}