Add Client.GetCurrentUser

This commit is contained in:
emersion 2017-08-24 10:51:15 +02:00
parent 1978c7ced0
commit f7c8ce8d9f
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
3 changed files with 113 additions and 0 deletions

21
protonmail/adresses.go Normal file
View File

@ -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
}

10
protonmail/keys.go Normal file
View File

@ -0,0 +1,10 @@
package protonmail
type Key struct {
ID string
Version int
PublicKey string
PrivateKey string
Fingerprint string
Activation interface{} // TODO
}

82
protonmail/users.go Normal file
View File

@ -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
}