forked from linode/linodego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile_security_questions.go
49 lines (41 loc) · 1.36 KB
/
profile_security_questions.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
package linodego
import (
"context"
"encoding/json"
)
type SecurityQuestion struct {
ID int `json:"id"`
Question string `json:"question"`
Response string `json:"response"`
}
type SecurityQuestionsListResponse struct {
SecurityQuestions []SecurityQuestion `json:"security_questions"`
}
type SecurityQuestionsAnswerQuestion struct {
QuestionID int `json:"question_id"`
Response string `json:"response"`
}
type SecurityQuestionsAnswerOptions struct {
SecurityQuestions []SecurityQuestionsAnswerQuestion `json:"security_questions"`
}
// SecurityQuestionsList returns a collection of security questions and their responses, if any, for your User Profile.
func (c *Client) SecurityQuestionsList(ctx context.Context) (*SecurityQuestionsListResponse, error) {
e := "profile/security-questions"
req := c.R(ctx).SetResult(&SecurityQuestionsListResponse{})
r, err := coupleAPIErrors(req.Get(e))
if err != nil {
return nil, err
}
return r.Result().(*SecurityQuestionsListResponse), nil
}
// SecurityQuestionsAnswer adds security question responses for your User.
func (c *Client) SecurityQuestionsAnswer(ctx context.Context, opts SecurityQuestionsAnswerOptions) error {
body, err := json.Marshal(opts)
if err != nil {
return err
}
e := "profile/security-questions"
req := c.R(ctx).SetBody(string(body))
_, err = coupleAPIErrors(req.Post(e))
return err
}