| 1 |
package proton |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
) |
| 6 |
|
| 7 |
func (m *Manager) GetCaptcha(ctx context.Context, token string) ([]byte, error) { |
| 8 |
res, err := m.r(ctx).SetQueryParam("Token", token).SetQueryParam("ForceWebMessaging", "1").Get("/core/v4/captcha") |
| 9 |
if err != nil { |
| 10 |
return nil, err |
| 11 |
} |
| 12 |
|
| 13 |
return res.Body(), nil |
| 14 |
} |
| 15 |
|
| 16 |
func (m *Manager) SendVerificationCode(ctx context.Context, req SendVerificationCodeReq) error { |
| 17 |
if _, err := m.r(ctx).SetBody(req).Post("/core/v4/users/code"); err != nil { |
| 18 |
return err |
| 19 |
} |
| 20 |
|
| 21 |
return nil |
| 22 |
} |
| 23 |
|
| 24 |
func (m *Manager) CreateUser(ctx context.Context, req CreateUserReq) (User, error) { |
| 25 |
var res struct { |
| 26 |
User User |
| 27 |
} |
| 28 |
|
| 29 |
if _, err := m.r(ctx).SetBody(req).SetResult(&res).Post("/core/v4/users"); err != nil { |
| 30 |
return User{}, err |
| 31 |
} |
| 32 |
|
| 33 |
return res.User, nil |
| 34 |
} |
| 35 |
|
| 36 |
func (m *Manager) GetUsernameAvailable(ctx context.Context, username string) error { |
| 37 |
if _, err := m.r(ctx).SetQueryParam("Name", username).Get("/core/v4/users/available"); err != nil { |
| 38 |
return err |
| 39 |
} |
| 40 |
|
| 41 |
return nil |
| 42 |
} |