2017-08-24 11:51:15 +03:00
|
|
|
package protonmail
|
|
|
|
|
2018-10-21 13:24:56 +03:00
|
|
|
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-20 16:28:02 +03:00
|
|
|
Order int
|
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
|
|
|
}
|
2018-10-21 13:24:56 +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
|
|
|
|
}
|