Documentation ¶
Index ¶
- Variables
- type APIError
- type AuthFlowMessage
- type AuthMethod
- type AuthResponse
- type AuthenticateUsernameRequest
- type Client
- func (c *Client) CreateMaskedEmail(ctx context.Context, maskedEmail *MaskedEmail, enabled bool) (*MaskedEmail, error)
- func (c *Client) DeleteMaskedEmails(ctx context.Context, ids ...string) error
- func (c *Client) LoginUsernamePasswordMFA(ctx context.Context, username, password, mfaCode string) (*AuthResponse, error)
- func (c *Client) SetTokenAuthCredentials(accountID, accessToken string) *Client
- type ClientConfig
- type Credentials
- type JMAPRequest
- type JMAPResponse
- type MaskedEmail
- type MaskedEmailPayload
- type MethodCall
- type MethodResponse
- type MethodResponseError
- type MethodResponseMaskedEmailSet
Constants ¶
This section is empty.
Variables ¶
var ( // APIEndpoint is the Fastmail API endpoint. APIEndpoint = "https://api.fastmail.com/jmap/api/" // APIAuthEndpoint is the Fastmail authentication endpoint. APIAuthEndpoint = "https://www.fastmail.com/jmap/authenticate/" )
Functions ¶
This section is empty.
Types ¶
type AuthFlowMessage ¶
type AuthFlowMessage struct { LoginID string `json:"loginId,omitempty"` MayTrustDevice bool `json:"mayTrustDevice,omitempty"` Remember bool `json:"remember"` Type string `json:"type,omitempty"` Methods []AuthMethod `json:"methods,omitempty"` Value string `json:"value,omitempty"` }
func (*AuthFlowMessage) TOTPRequired ¶
func (a *AuthFlowMessage) TOTPRequired() bool
type AuthMethod ¶
type AuthResponse ¶
type AuthResponse struct { AccountType string `json:"accountType,omitempty"` UserID string `json:"userId,omitempty"` SigningID string `json:"signingId,omitempty"` SigningKey string `json:"signingKey,omitempty"` IsAdmin bool `json:"isAdmin,omitempty"` SessionKey string `json:"sessionKey,omitempty"` PrimaryAccounts map[string]string `json:"primaryAccounts,omitempty"` AccessToken string `json:"accessToken,omitempty"` DisplayName string `json:"displayName"` APIURL string `json:"apiUrl,omitempty"` DownloadURL string `json:"downloadUrl,omitempty"` UploadURL string `json:"uploadUrl"` IsLoginBlocked bool `json:"isLoginBlocked"` State string `json:"state"` IsReseller bool `json:"isReseller"` IsAppStore bool `json:"isAppStore"` IsVerified bool `json:"isVerified"` MayMailSync bool `json:"mayMailSync"` MayContactSync bool `json:"mayContactSync"` FeatureLevel int `json:"featureLevel"` IsReceiveBlocked bool `json:"isReceiveBlocked"` ProxyURL string `json:"proxyUrl,omitempty"` IsSendBlocked bool `json:"isSendBlocked,omitempty"` NewCalAlerts bool `json:"newCalAlerts,omitempty"` Language string `json:"language"` Capabilities map[string]interface{} `json:"capabilities,omitempty"` }
func (*AuthResponse) GetAccessToken ¶
func (a *AuthResponse) GetAccessToken() string
func (*AuthResponse) GetMailAccountID ¶
func (a *AuthResponse) GetMailAccountID() (accountID string, ok bool)
type AuthenticateUsernameRequest ¶
type AuthenticateUsernameRequest struct {
Username string `json:"username,omitempty"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
Returns NewClient with the given values. 'accountID' is the Fastmail account ID, this is not the same as the email address.
func (*Client) CreateMaskedEmail ¶
func (c *Client) CreateMaskedEmail(ctx context.Context, maskedEmail *MaskedEmail, enabled bool) (*MaskedEmail, error)
CreateMaskedEmail creates a new masked email for the given forDomain domain. If `enabled` is set to false, will only create a pending email and needs to be confirmed before it's usable.
func (*Client) DeleteMaskedEmails ¶
DeleteMaskedEmails deletes the given masked emails by ID.
func (*Client) LoginUsernamePasswordMFA ¶
func (c *Client) LoginUsernamePasswordMFA(ctx context.Context, username, password, mfaCode string) (*AuthResponse, error)
LoginUsernamePasswordMFA authenticates with the given username and password, mfaCode is optional based on account settings.
func (*Client) SetTokenAuthCredentials ¶
type ClientConfig ¶
type Credentials ¶
type Credentials struct {
// contains filtered or unexported fields
}
type JMAPRequest ¶
type JMAPRequest struct { Using []string `json:"using,omitempty"` MethodCalls []MethodCall `json:"methodCalls,omitempty"` }
type JMAPResponse ¶
type JMAPResponse struct { LatestClientVersion string `json:"latestClientVersion,omitempty"` MethodResponses []MethodResponse `json:"methodResponses,omitempty"` SessionState string `json:"sessionState,omitempty"` }
type MaskedEmail ¶
type MaskedEmail struct { ID string `json:"id,omitempty" mapstructure:"id"` State string `json:"state,omitempty" mapstructure:"state"` Email string `json:"email,omitempty" mapstructure:"email"` Description string `json:"description,omitempty" mapstructure:"description"` ForDomain string `json:"forDomain,omitempty" mapstructure:"forDomain"` URL string `json:"url,omitempty" mapstructure:"url"` CreatedBy string `json:"createdBy,omitempty" mapstructure:"createdBy"` CreatedAt string `json:"createdAt,omitempty" mapstructure:"createdAt"` LastMessageAt string `json:"lastMessageAt,omitempty" mapstructure:"lastMessageAt"` }
MaskedEmail represents a Fastmail masked email.
type MaskedEmailPayload ¶
type MaskedEmailPayload struct { AccountID string `json:"accountId,omitempty"` Create map[string]*MaskedEmail `json:"create,omitempty"` Set map[string]*MaskedEmail `json:"set,omitempty"` Update map[string]*MaskedEmail `json:"update,omitempty"` Destroy []string `json:"destroy,omitempty"` }
MaskedEmailPayload is the payload for the MaskedEmail/{set,update} method.
type MethodCall ¶
func (*MethodCall) MarshalJSON ¶
func (m *MethodCall) MarshalJSON() ([]byte, error)
MarshalJSON marshals a MethodCall into the format needed by the Fastmail API eg. ["MaskedEmail/set", {...}, "0"].
func (*MethodCall) UnmarshalJSON ¶
func (m *MethodCall) UnmarshalJSON(b []byte) error
type MethodResponse ¶
type MethodResponse [3]interface{}
type MethodResponseError ¶
func (MethodResponseError) Error ¶
func (m MethodResponseError) Error() string
type MethodResponseMaskedEmailSet ¶
type MethodResponseMaskedEmailSet struct { AccountID string `mapstructure:"accountId" json:"accountId,omitempty"` Created map[string]MaskedEmail `mapstructure:"created" json:"created,omitempty"` Updated map[string]interface{} `mapstructure:"updated" json:"updated,omitempty"` Destroyed []interface{} `mapstructure:"destroyed" json:"destroyed,omitempty"` NewState interface{} `mapstructure:"newState" json:"newState,omitempty"` OldState interface{} `mapstructure:"oldState" json:"oldState,omitempty"` }
func (*MethodResponseMaskedEmailSet) GetCreatedItem ¶
func (m *MethodResponseMaskedEmailSet) GetCreatedItem() (MaskedEmail, error)