protonmail: add Client.GetConversation

This commit is contained in:
Simon Ser 2020-09-14 12:46:22 +02:00
parent 0e0fb0c38e
commit ea188ff133
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,44 @@
package protonmail
import (
"net/http"
"net/url"
)
type Conversation struct {
ID string
Order int64
Subject string
Senders []*MessageAddress
Recipients []*MessageAddress
NumMessages int
NumUnread int
NumAttachments int
ExpirationTime Timestamp
TotalSize int64
AddressID string
LabelIDs []string
}
func (c *Client) GetConversation(id, msgID string) (*Conversation, []*Message, error) {
v := url.Values{}
if msgID != "" {
v.Set("MessageID", msgID)
}
req, err := c.newRequest(http.MethodGet, "/conversations/"+id+"?"+v.Encode(), nil)
if err != nil {
return nil, nil, err
}
var respData struct {
resp
Conversation *Conversation
Messages []*Message
}
if err := c.doJSON(req, &respData); err != nil {
return nil, nil, err
}
return respData.Conversation, respData.Messages, nil
}