]> git.rmz.io Git - dotfiles.git/blob - bin/old/office365-book
lazyvim: absorb treesitter plugins
[dotfiles.git] / bin / old / office365-book
1 #!/usr/bin/env bash
2
3 user=samir.benmendil@ultrahaptics.com
4 pass=$(pass ultrahaptics/okta.com/samir.benmendil@ultrahaptics.com)
5 url="https://outlook.office365.com/EWS/Exchange.asmx"
6
7 read -r -d '' data <<EOF
8 <?xml version="1.0" encoding="utf-8"?>
9 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
11 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
12 xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
13 <soap:Body>
14 <ResolveNames
15 xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
16 xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
17 ReturnFullContactData="true">
18 <UnresolvedEntry>$1</UnresolvedEntry>
19 </ResolveNames>
20 </soap:Body>
21 </soap:Envelope>
22 EOF
23
24 out=$(curl -s -u "$user:$pass" -L "$url" -d "$data")
25
26 readarray -t email < <(echo $out | xpath -q -e '//t:Mailbox/t:EmailAddress/text()')
27 readarray -t name < <(echo $out | xpath -q -e '//t:Contact/t:DisplayName/text()')
28
29 count=${#email[@]}
30
31 if [[ "$count" -eq 0 ]]; then
32 echo "No matches"
33 exit 1
34 fi
35
36 echo "$count matches"
37 for (( i = 0; i < $count; i++ )); do
38 echo -e "${email[$i]}\t${name[$i]}\t"
39 done