@@ -0,0 +1,33 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// CreateAuthenticationToken exchanges credentials for a bearer token.
|
||||
func (c *Client) CreateAuthenticationToken(ctx context.Context, credentials Credentials) (AuthenticationToken, *Response, error) {
|
||||
var envelope struct {
|
||||
Token AuthenticationToken `json:"authentication_token"`
|
||||
}
|
||||
response, err := c.do(ctx, http.MethodPost, "v1/tokens/authentication", credentials, &envelope)
|
||||
return envelope.Token, response, err
|
||||
}
|
||||
|
||||
// CreateActivationToken requests a new account activation email.
|
||||
func (c *Client) CreateActivationToken(ctx context.Context, email string) (string, *Response, error) {
|
||||
var envelope struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
response, err := c.do(ctx, http.MethodPost, "v1/tokens/activation", EmailInput{Email: email}, &envelope)
|
||||
return envelope.Message, response, err
|
||||
}
|
||||
|
||||
// CreatePasswordResetToken requests password reset instructions for email.
|
||||
func (c *Client) CreatePasswordResetToken(ctx context.Context, email string) (string, *Response, error) {
|
||||
var envelope struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
response, err := c.do(ctx, http.MethodPost, "v1/tokens/password-reset", EmailInput{Email: email}, &envelope)
|
||||
return envelope.Message, response, err
|
||||
}
|
||||
Reference in New Issue
Block a user