hydroxide-push/protonmail/addresses.go

62 lines
977 B
Go
Raw Normal View History

2017-08-24 11:51:15 +03:00
package protonmail
import (
"net/http"
)
2017-08-24 11:51:15 +03:00
type (
2017-09-13 12:43:12 +03:00
AddressSend int
2017-08-24 11:51:15 +03:00
AddressStatus int
2017-09-13 12:43:12 +03:00
AddressType int
2017-08-24 11:51:15 +03:00
)
2017-09-21 21:02:54 +03:00
const (
AddressSendDisabled AddressSend = iota
AddressSendPrimary
AddressSendSecondary
)
const (
AddressDisabled AddressStatus = iota
AddressEnabled
)
const (
AddressOriginal AddressType = iota
AddressAlias
AddressCustom
)
2017-08-24 11:51:15 +03:00
type Address struct {
2017-09-13 12:43:12 +03:00
ID string
DomainID string
Email string
Send AddressSend
Receive int
Status AddressStatus
Type AddressType
2018-10-21 15:05:26 +03:00
Order int64
2017-08-24 11:51:15 +03:00
DisplayName string
2017-09-13 12:43:12 +03:00
Signature string // HTML
HasKeys int
2017-09-21 21:02:54 +03:00
Keys []*PrivateKey
2017-08-24 11:51:15 +03:00
}
func (c *Client) ListAddresses() ([]*Address, error) {
// TODO: Page, PageSize
req, err := c.newRequest(http.MethodGet, "/addresses", nil)
if err != nil {
return nil, err
}
var respData struct {
resp
Addresses []*Address
}
if err := c.doJSON(req, &respData); err != nil {
return nil, err
}
return respData.Addresses, nil
}