forked from andlabs/ews
-
Notifications
You must be signed in to change notification settings - Fork 29
/
get_persona.go
51 lines (41 loc) · 1.15 KB
/
get_persona.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package ews
import (
"encoding/xml"
"errors"
)
type GetPersonaRequest struct {
XMLName struct{} `xml:"m:GetPersona"`
PersonaId PersonaId `xml:"m:PersonaId"`
}
type getPersonaResponseEnvelop struct {
XMLName struct{} `xml:"Envelope"`
Body getPersonaResponseBody `xml:"Body"`
}
type getPersonaResponseBody struct {
FindPeopleResponse GetPersonaResponse `xml:"GetPersonaResponseMessage"`
}
type GetPersonaResponse struct {
Response
Persona Persona `xml:"Persona"`
}
// GetPersona
//https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/getpersona-operation
func GetPersona(c Client, r *GetPersonaRequest) (*GetPersonaResponse, error) {
xmlBytes, err := xml.MarshalIndent(r, "", " ")
if err != nil {
return nil, err
}
bb, err := c.SendAndReceive(xmlBytes)
if err != nil {
return nil, err
}
var soapResp getPersonaResponseEnvelop
err = xml.Unmarshal(bb, &soapResp)
if err != nil {
return nil, err
}
if soapResp.Body.FindPeopleResponse.ResponseClass == ResponseClassError {
return nil, errors.New(soapResp.Body.FindPeopleResponse.MessageText)
}
return &soapResp.Body.FindPeopleResponse, nil
}