Documentation
¶
Overview ¶
Package simplelogin is a client of the SimpleLogin API (simplelogin.io and self-hosted instances), for the endpoints Godwit uses: the user's mailboxes and aliases, creating and toggling aliases, and the contacts whose reverse aliases mail from an alias is sent to.
The API is documented at https://github.com/simple-login/app/blob/master/docs/api.md. Every request carries the user's API key in the Authentication header.
Index ¶
- Constants
- Variables
- type Activity
- type Alias
- type AliasMailbox
- type AliasPatch
- type Client
- func (c *Client) Alias(ctx context.Context, id int64) (Alias, error)
- func (c *Client) Aliases(ctx context.Context) ([]Alias, error)
- func (c *Client) CreateContact(ctx context.Context, aliasID int64, contact string) (Contact, error)
- func (c *Client) CreateCustom(ctx context.Context, a CustomAlias, hostname string) (Alias, error)
- func (c *Client) CreateRandom(ctx context.Context, note, mode, hostname string) (Alias, error)
- func (c *Client) Mailboxes(ctx context.Context) ([]Mailbox, error)
- func (c *Client) Options(ctx context.Context, hostname string) (Options, error)
- func (c *Client) Toggle(ctx context.Context, id int64) (bool, error)
- func (c *Client) Update(ctx context.Context, id int64, p AliasPatch) error
- type Contact
- type CustomAlias
- type Error
- type Mailbox
- type Options
- type Suffix
Constants ¶
const DefaultBaseURL = "https://app.simplelogin.io"
DefaultBaseURL is SimpleLogin's own service.
Variables ¶
ErrUnauthorized is the API's 401: the key is wrong, revoked or missing.
Functions ¶
This section is empty.
Types ¶
type Activity ¶
type Activity struct {
Action string `json:"action"`
Timestamp int64 `json:"timestamp"`
Contact struct {
Email string `json:"email"`
Name string `json:"name"`
ReverseAlias string `json:"reverse_alias"`
} `json:"contact"`
}
Activity is an alias's latest forward, reply, block or bounce.
type Alias ¶
type Alias struct {
ID int64 `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
Note string `json:"note"`
Enabled bool `json:"enabled"`
Pinned bool `json:"pinned"`
Created int64 `json:"creation_timestamp"`
Forwards int `json:"nb_forward"`
Replies int `json:"nb_reply"`
Blocks int `json:"nb_block"`
Mailboxes []AliasMailbox `json:"mailboxes"`
LatestActivity *Activity `json:"latest_activity"`
}
Alias is one of the user's aliases.
type AliasMailbox ¶
AliasMailbox is one of the mailboxes an alias forwards to.
type AliasPatch ¶
type AliasPatch struct {
Name *string `json:"name,omitempty"`
Note *string `json:"note,omitempty"`
MailboxIDs []int64 `json:"mailbox_ids,omitempty"`
}
AliasPatch changes the alias's fields that are not nil.
type Client ¶
type Client struct {
BaseURL string // scheme and host, with no trailing slash: DefaultBaseURL or a self-hosted one
Key string // the user's API key
HTTP *http.Client // nil: http.DefaultClient; redirects are refused either way
}
Client calls one SimpleLogin instance as one user.
func (*Client) Aliases ¶
Aliases lists every alias of the user, reading page after page until one comes back empty.
func (*Client) CreateContact ¶
CreateContact adds contact ("Name <address>" or a bare address) to the alias, or returns the existing one (Existed).
func (*Client) CreateCustom ¶
CreateCustom creates a custom alias, used on hostname ("" for none).
func (*Client) CreateRandom ¶
CreateRandom creates a random alias forwarding to the default mailbox. mode is "word", "uuid" or "" for the user's setting.
type Contact ¶
type Contact struct {
ID int64 `json:"id"`
Contact string `json:"contact"`
ReverseAlias string `json:"reverse_alias"` // a header address: a display name and ReverseAliasAddress
ReverseAliasAddress string `json:"reverse_alias_address"` // the bare address
Existed bool `json:"existed"`
}
Contact is a correspondent of an alias. Mail from the alias to Contact is sent to ReverseAliasAddress from one of the alias's mailboxes; SimpleLogin rewrites its From to the alias.
type CustomAlias ¶
type CustomAlias struct {
Prefix string `json:"alias_prefix"`
SignedSuffix string `json:"signed_suffix"`
MailboxIDs []int64 `json:"mailbox_ids"`
Note string `json:"note,omitempty"`
Name string `json:"name,omitempty"`
}
CustomAlias is a custom alias to create: Prefix followed by the suffix SignedSuffix names, forwarding to MailboxIDs (at least one).
type Error ¶
Error is a refusal the API explained, such as an alias quota reached or a reverse alias that needs a premium plan: the API documents Message as fit to show the user as it is.
type Mailbox ¶
type Mailbox struct {
ID int64 `json:"id"`
Email string `json:"email"`
Default bool `json:"default"`
Verified bool `json:"verified"`
Aliases int `json:"nb_alias"`
}
Mailbox is a mailbox of the user's: a real address aliases forward to.
type Options ¶
type Options struct {
CanCreate bool `json:"can_create"`
PrefixSuggestion string `json:"prefix_suggestion"`
Suffixes []Suffix `json:"suffixes"`
}
Options is what a new alias can be: whether the user may create one, the suffixes a custom one can end with, and a prefix suggested for hostname.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package simplelogintest is a fake SimpleLogin API for tests: a user with mailboxes, aliases and contacts, served over HTTP on loopback.
|
Package simplelogintest is a fake SimpleLogin API for tests: a user with mailboxes, aliases and contacts, served over HTTP on loopback. |