api

package
v0.0.0-...-321511a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2018 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Ok    RespCode = 1000
	Batch          = 1001

	BadRequest   = 400
	Unauthorized = 401
	NotFound     = 404

	InternalServerError = 500
)
View Source
const SessionTimeout = 10 * time.Minute

Variables

This section is empty.

Functions

func New

func New(m *macaron.Macaron, backend *backend.Backend)

Types

type AddressResp

type AddressResp struct {
	Resp
	Address *backend.Address
}

type Api

type Api struct {
	// contains filtered or unexported fields
}

func (*Api) Auth

func (api *Api) Auth(ctx *macaron.Context, req AuthReq)

func (*Api) AuthCookies

func (api *Api) AuthCookies(ctx *macaron.Context, req AuthCookiesReq)

func (*Api) AuthInfo

func (api *Api) AuthInfo(ctx *macaron.Context, req AuthInfoReq)

func (*Api) Crash

func (api *Api) Crash(ctx *macaron.Context, req CrashReq)

func (*Api) CreateAddress

func (api *Api) CreateAddress(ctx *macaron.Context, req CreateAddressReq) (err error)

func (*Api) CreateContacts

func (api *Api) CreateContacts(ctx *macaron.Context, req CreateContactsReq)

func (*Api) CreateDraft

func (api *Api) CreateDraft(ctx *macaron.Context, req MessageReq) (err error)

func (*Api) CreateLabel

func (api *Api) CreateLabel(ctx *macaron.Context, req LabelReq) (err error)

func (*Api) CreatePrivateKey

func (api *Api) CreatePrivateKey(ctx *macaron.Context, req CreatePrivateKeyReq)

func (*Api) CreateUser

func (api *Api) CreateUser(ctx *macaron.Context, req CreateUserReq) (err error)

func (*Api) DeleteAddress

func (api *Api) DeleteAddress(ctx *macaron.Context) (err error)

func (*Api) DeleteAllContacts

func (api *Api) DeleteAllContacts(ctx *macaron.Context) (err error)

func (*Api) DeleteAllMessages

func (api *Api) DeleteAllMessages(ctx *macaron.Context) (err error)

func (*Api) DeleteAttachment

func (api *Api) DeleteAttachment(ctx *macaron.Context) error

func (*Api) DeleteAuth

func (api *Api) DeleteAuth(ctx *macaron.Context)

func (*Api) DeleteContacts

func (api *Api) DeleteContacts(ctx *macaron.Context, req BatchReq)

func (*Api) DeleteConversations

func (api *Api) DeleteConversations(ctx *macaron.Context, req BatchReq)

func (*Api) DeleteLabel

func (api *Api) DeleteLabel(ctx *macaron.Context) (err error)

func (*Api) DeleteMessages

func (api *Api) DeleteMessages(ctx *macaron.Context, req BatchReq)

func (*Api) GetAttachment

func (api *Api) GetAttachment(ctx *macaron.Context) (b []byte, err error)

func (*Api) GetAvailableDomains

func (api *Api) GetAvailableDomains(ctx *macaron.Context) (err error)

func (*Api) GetContacts

func (api *Api) GetContacts(ctx *macaron.Context) (err error)

func (*Api) GetConversation

func (api *Api) GetConversation(ctx *macaron.Context) (err error)

func (*Api) GetConversationsCount

func (api *Api) GetConversationsCount(ctx *macaron.Context) (err error)

func (*Api) GetCurrentUser

func (api *Api) GetCurrentUser(ctx *macaron.Context)

func (*Api) GetDirectUser

func (api *Api) GetDirectUser(ctx *macaron.Context)

func (*Api) GetDomain

func (api *Api) GetDomain(ctx *macaron.Context) (err error)

func (*Api) GetEvent

func (api *Api) GetEvent(ctx *macaron.Context) (err error)

func (*Api) GetLabels

func (api *Api) GetLabels(ctx *macaron.Context) (err error)

func (*Api) GetMembers

func (api *Api) GetMembers(ctx *macaron.Context)

func (*Api) GetMessage

func (api *Api) GetMessage(ctx *macaron.Context) (err error)

func (*Api) GetMessagesCount

func (api *Api) GetMessagesCount(ctx *macaron.Context) (err error)

func (*Api) GetMessagesTotal

func (api *Api) GetMessagesTotal(ctx *macaron.Context) (err error)

func (*Api) GetPaymentMethods

func (api *Api) GetPaymentMethods(ctx *macaron.Context)

func (*Api) GetPlans

func (api *Api) GetPlans(ctx *macaron.Context)

func (*Api) GetPublicKeys

func (api *Api) GetPublicKeys(ctx *macaron.Context) (err error)

func (*Api) GetSubscription

func (api *Api) GetSubscription(ctx *macaron.Context)

func (*Api) GetUserDomains

func (api *Api) GetUserDomains(ctx *macaron.Context) (err error)

func (*Api) GetUserOrganization

func (api *Api) GetUserOrganization(ctx *macaron.Context)

func (*Api) GetUsernameAvailable

func (api *Api) GetUsernameAvailable(ctx *macaron.Context) (err error)

func (*Api) ListConversations

func (api *Api) ListConversations(ctx *macaron.Context) (err error)

func (*Api) ListMessages

func (api *Api) ListMessages(ctx *macaron.Context) (err error)

func (*Api) SendMessage

func (api *Api) SendMessage(ctx *macaron.Context, req SendMessageReq) (err error)

func (*Api) ToggleAddress

func (api *Api) ToggleAddress(ctx *macaron.Context) (err error)

func (*Api) UpdateAllPrivateKeys

func (api *Api) UpdateAllPrivateKeys(ctx *macaron.Context, req UpdateAllPrivateKeysReq)

func (*Api) UpdateContact

func (api *Api) UpdateContact(ctx *macaron.Context, req UpdateContactReq) (err error)

func (*Api) UpdateConversationsLabel

func (api *Api) UpdateConversationsLabel(ctx *macaron.Context, req UpdateConversationsLabelReq)

func (*Api) UpdateConversationsRead

func (api *Api) UpdateConversationsRead(ctx *macaron.Context, req BatchReq)

func (*Api) UpdateConversationsStar

func (api *Api) UpdateConversationsStar(ctx *macaron.Context, req BatchReq)

func (*Api) UpdateConversationsSystemLabel

func (api *Api) UpdateConversationsSystemLabel(ctx *macaron.Context, req BatchReq)

func (*Api) UpdateDraft

func (api *Api) UpdateDraft(ctx *macaron.Context, req MessageReq) (err error)

func (*Api) UpdateLabel

func (api *Api) UpdateLabel(ctx *macaron.Context, req LabelReq) (err error)

func (*Api) UpdateLabelsOrder

func (api *Api) UpdateLabelsOrder(ctx *macaron.Context, req LabelsOrderReq) (err error)

func (*Api) UpdateMessagesLabel

func (api *Api) UpdateMessagesLabel(ctx *macaron.Context, req UpdateMessagesLabelReq)

func (*Api) UpdateMessagesRead

func (api *Api) UpdateMessagesRead(ctx *macaron.Context, req BatchReq)

func (*Api) UpdateMessagesStar

func (api *Api) UpdateMessagesStar(ctx *macaron.Context, req BatchReq)

func (*Api) UpdateMessagesSystemLabel

func (api *Api) UpdateMessagesSystemLabel(ctx *macaron.Context, req BatchReq)

func (*Api) UpdateUserAutoSaveContacts

func (api *Api) UpdateUserAutoSaveContacts(ctx *macaron.Context, req UpdateUserSettingsReq)

func (*Api) UpdateUserComposerMode

func (api *Api) UpdateUserComposerMode(ctx *macaron.Context, req UpdateUserSettingsReq)

func (*Api) UpdateUserDisplayName

func (api *Api) UpdateUserDisplayName(ctx *macaron.Context, req UpdateUserSettingsReq)

func (*Api) UpdateUserMessageButtons

func (api *Api) UpdateUserMessageButtons(ctx *macaron.Context, req UpdateUserSettingsReq)

func (*Api) UpdateUserPassword

func (api *Api) UpdateUserPassword(ctx *macaron.Context, req UpdateUserPasswordReq)

func (*Api) UpdateUserShowImages

func (api *Api) UpdateUserShowImages(ctx *macaron.Context, req UpdateUserSettingsReq)

func (*Api) UpdateUserSignature

func (api *Api) UpdateUserSignature(ctx *macaron.Context, req UpdateUserSettingsReq)

func (*Api) UpdateUserTheme

func (api *Api) UpdateUserTheme(ctx *macaron.Context, req UpdateUserSettingsReq)

func (*Api) UpdateUserViewLayout

func (api *Api) UpdateUserViewLayout(ctx *macaron.Context, req UpdateUserSettingsReq)

func (*Api) UploadAttachment

func (api *Api) UploadAttachment(ctx *macaron.Context, req UploadAttachmentReq) (err error)

type AuthCookie

type AuthCookie struct {
	AccessToken string
	Uid         string `json:"UID"`
}

type AuthCookiesReq

type AuthCookiesReq struct {
	Req
	ClientID     string
	RefreshToken string
	RedirectURI  string
	State        string
}

type AuthCookiesResp

type AuthCookiesResp struct {
	Resp
	SessionToken string
}

type AuthInfoReq

type AuthInfoReq struct {
	Req
	ClientID     string
	ClientSecret string
	Username     string
}

type AuthInfoResp

type AuthInfoResp struct {
	Resp
	Modulus         string
	ServerEphemeral string
	Version         int
	Salt            string
	SRPSession      string
	TwoFactor       int
}

type AuthReq

type AuthReq struct {
	Req
	ClientID      string
	ClientSecret  string
	Username      string
	Password      string
	TwoFactorCode string
}

type AuthResp

type AuthResp struct {
	Resp
	AccessToken  string
	ExpiresIn    int
	TokenType    TokenType
	Scope        string
	Uid          string
	RefreshToken string
	UserStatus   int
	PrivateKey   string
	KeySalt      string
	EventID      string
}

type AvailableDomainsResp

type AvailableDomainsResp struct {
	Resp
	Domains []string
}

type BatchReq

type BatchReq struct {
	Req
	IDs []string
}

type BatchResp

type BatchResp struct {
	Resp
	Responses []*BatchRespItem
}

type BatchRespItem

type BatchRespItem struct {
	ID       string
	Response interface{}
}

type ClientType

type ClientType int
const (
	ClientEmail ClientType = 1
	ClientVPN
)

type ContactResp

type ContactResp struct {
	Resp
	Contact *backend.Contact
}

type ContactsResp

type ContactsResp struct {
	Resp
	Contacts []*backend.Contact
}

type ConversationResp

type ConversationResp struct {
	Resp
	Conversation *backend.Conversation
	Messages     []*backend.Message
}

type ConversationsListResp

type ConversationsListResp struct {
	Resp
	Total         int
	Conversations []*backend.Conversation
}

type CrashReq

type CrashReq struct {
	Req
	OS             string
	OSVersion      string
	Browser        string
	BrowserVersion string
	Client         string
	ClientVersion  string
	ClientType     ClientType
	Debug          json.RawMessage
}

type CreateAddressReq

type CreateAddressReq struct {
	Req
	Domain   string
	Local    string
	MemberID string
}

type CreateContactsReq

type CreateContactsReq struct {
	Contacts []*backend.Contact
}

type CreatePrivateKeyReq

type CreatePrivateKeyReq struct {
	AddressID  string
	PrivateKey string
}

type CreateUserReq

type CreateUserReq struct {
	Req
	Username   string
	Password   string
	Domain     string
	Email      string
	News       bool
	PrivateKey string
	Token      string
	TokenType  string
}

type DirectUserResp

type DirectUserResp struct {
	Resp
	Direct int
}

type DomainResp

type DomainResp struct {
	Resp
	Domain *backend.Domain
}

type DomainsResp

type DomainsResp struct {
	Resp
	Domains []*backend.Domain
}

type ErrorResp

type ErrorResp struct {
	Resp
	Error            string
	ErrorDescription string
}

type EventResp

type EventResp struct {
	Resp
	*backend.Event
}

type LabelReq

type LabelReq struct {
	*backend.Label
}

type LabelResp

type LabelResp struct {
	Resp
	Label *backend.Label
}

type LabelsOrderReq

type LabelsOrderReq struct {
	Order []int
}

type LabelsResp

type LabelsResp struct {
	Resp
	Labels []*backend.Label
}

type Member

type Member struct {
	ID        string
	NickName  string
	Role      int
	Addresses []*backend.Address
	Private   int
}

type MembersResp

type MembersResp struct {
	Resp
	Members []*Member
}

type MessageReq

type MessageReq struct {
	Req
	Message  *backend.Message
	ID       string `json:"id"`
	ParentID string
}

type MessageResp

type MessageResp struct {
	Resp
	Message *backend.Message
}

type MessagesCountResp

type MessagesCountResp struct {
	Resp
	Counts []*backend.MessagesCount
}

type MessagesListResp

type MessagesListResp struct {
	Resp
	Total    int
	Messages []*backend.Message
}

type MessagesTotalResp

type MessagesTotalResp struct {
	Resp
	backend.MessagesTotal
}

type Organization

type Organization struct {
	ID            string
	UsedDomains   int
	MaxDomains    int
	UsedAddresses int
	MaxAddresses  int
}

type OrganizationResp

type OrganizationResp struct {
	Resp
	Organization *Organization
}

type PaymentMethodsResp

type PaymentMethodsResp struct {
	Resp
	PaymentMethods []interface{} // TODO
}

type Plan

type Plan struct {
	ID           string
	Type         int
	Cycle        int
	Name         string
	Currency     string
	Amount       int
	MaxDomains   int
	MaxAddresses int
	MaxSpace     int
	MaxMembers   int
	TwoFactor    int
}

type PlansResp

type PlansResp struct {
	Resp
	Plans []*Plan
}

type Req

type Req struct{}

type Resp

type Resp struct {
	Code RespCode
}

type RespCode

type RespCode int

type SendMessageReq

type SendMessageReq struct {
	Req
	ID             string `json:"id"`
	Packages       []*backend.MessagePackage
	AttachmentKeys []*backend.AttachmentKey
	ClearBody      string
}

type SendMessageResp

type SendMessageResp struct {
	Resp
	Sent *backend.Message
}

type Session

type Session struct {
	ID      string
	UserID  string
	Token   string
	Timeout *time.Timer
}

func NewSession

func NewSession(user string, expire func()) *Session

type Subscription

type Subscription struct {
	ID          string
	InvoiceID   string
	Cycle       int
	PeriodStart int64
	PeriodEnd   int64
	CouponCode  string
	Currency    string
	Amount      int
	Plans       []*Plan
}

type SubscriptionResp

type SubscriptionResp struct {
	Resp
	Subscription *Subscription
}

type TokenType

type TokenType string
const (
	TokenBearer TokenType = "Bearer"
)

type UpdateAllPrivateKeysReq

type UpdateAllPrivateKeysReq struct {
	Password string
	Keys     []*backend.Keypair
}

type UpdateContactReq

type UpdateContactReq struct {
	Req
	ID    string `json:"id"`
	Name  string
	Email string
}

type UpdateConversationsLabelReq

type UpdateConversationsLabelReq struct {
	UpdateLabelReq
	ConversationIDs []string
}

type UpdateLabelReq

type UpdateLabelReq struct {
	Req
	Action  int
	LabelID string
}

type UpdateMessagesLabelReq

type UpdateMessagesLabelReq struct {
	UpdateLabelReq
	MessageIDs []string
}

type UpdateUserPasswordReq

type UpdateUserPasswordReq struct {
	Req
	Password    string
	NewPassword string
}

type UpdateUserSettingsReq

type UpdateUserSettingsReq struct {
	Req
	*backend.User
	Password string
}

type UploadAttachmentReq

type UploadAttachmentReq struct {
	Filename   string                `form:"Filename"`
	MessageID  string                `form:"MessageID"`
	MIMEType   string                `form:"MIMEType"`
	ContentID  string                `form:"ContentID"`
	KeyPackets *multipart.FileHeader `form:"KeyPackets"`
	DataPacket *multipart.FileHeader `form:"DataPacket"`
}

form: attributes are needed to parse multipart form See https://github.com/go-macaron/binding/issues/10

type UploadAttachmentResp

type UploadAttachmentResp struct {
	Resp
	AttachmentID string
	Size         int
}

type UserResp

type UserResp struct {
	Resp
	User *backend.User
}

type UsernameAvailableResp

type UsernameAvailableResp struct {
	Resp
	Available int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL