Add Client.Contacts

This commit is contained in:
emersion 2017-08-22 12:40:27 +02:00
parent 4785888590
commit 67d7c932fe
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 51 additions and 0 deletions

51
protonmail/contacts.go Normal file
View File

@ -0,0 +1,51 @@
package protonmail
import (
"net/http"
)
type Contact struct {
ID string
Name string
LabelIDs []string
Emails []*ContactEmail
Data []*ContactData
}
type ContactEmail struct {
ID string
Name string
Email string
Type string
Encrypt int
Order int
ContactID string
LabelIDs []string
}
type ContactDataType int
type ContactData struct {
Type ContactDataType
Data string
}
type contactsResp struct {
resp
Contacts []*Contact
}
func (c *Client) Contacts() ([]*Contact, error) {
req, err := c.newRequest(http.MethodGet, "/contacts", nil)
if err != nil {
return nil, err
}
var respData contactsResp
if err := c.doJSON(req, &respData); err != nil {
return nil, err
}
return respData.Contacts, nil
}