diff --git a/protonmail/adresses.go b/protonmail/adresses.go new file mode 100644 index 0000000..2910157 --- /dev/null +++ b/protonmail/adresses.go @@ -0,0 +1,21 @@ +package protonmail + +type ( + AddressSend int + AddressStatus int + AddressType int +) + +type Address struct { + ID string + DomainID string + Email string + Send AddressSend + Receive int + Status AddressStatus + Type AddressType + DisplayName string + Signature string // HTML + HasKeys int + Keys []*Key +} diff --git a/protonmail/keys.go b/protonmail/keys.go new file mode 100644 index 0000000..f900a44 --- /dev/null +++ b/protonmail/keys.go @@ -0,0 +1,10 @@ +package protonmail + +type Key struct { + ID string + Version int + PublicKey string + PrivateKey string + Fingerprint string + Activation interface{} // TODO +} diff --git a/protonmail/users.go b/protonmail/users.go new file mode 100644 index 0000000..ba3bc32 --- /dev/null +++ b/protonmail/users.go @@ -0,0 +1,82 @@ +package protonmail + +import ( + "net/http" +) + +type ( + LogAuth int + ComposerMode int + MessageButtons int + ImagesMode int + ViewMode int + ViewLayout int + SwipeAction int +) + +type User struct { + ID string + Name string + NotificationEmail string + Signature string // HTML + NumMessagePerPage int + UsedSpace int + Notify int + AutoSaveContacts int + Language string // e.g. en_US + LogAuth LogAuth + ComposerMode ComposerMode + MessageButtons MessageButtons + Images ImagesMode + Moved int + ShowImages int + ShowEmbedded int + ViewMode ViewMode + ViewLayout ViewLayout + SwipeLeft SwipeAction + SwipeRight SwipeAction + Theme string + Currency string // e.g. EUR + Credit int + InvoiceText string + AlsoArchive int + Hotkeys int + PMSignature int + TwoFactor int + PasswordReset int + PasswordMode PasswordMode + News int + AutoResponder interface{} // TODO + AutoWildcardSearch int + DraftMIMEType string + ReceiveMIMEType string + ImageProxy int + DisplayName string + MaxSpace int + MaxUpload int + Subscribed int // TODO + Services int // TODO + Role int // TODO + Private int + VPN interface{} // TODO + Delinquent int + Addresses []*Address + Keys []*Key +} + +func (c *Client) GetCurrentUser() (*User, error) { + req, err := c.newRequest(http.MethodGet, "/users", nil) + if err != nil { + return nil, err + } + + var respData struct { + resp + User *User + } + if err := c.doJSON(req, &respData); err != nil { + return nil, err + } + + return respData.User, nil +}