ews-api 0.1.0.a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +24 -0
- data/LICENSE +20 -0
- data/README.rdoc +38 -0
- data/Rakefile +88 -0
- data/VERSION +1 -0
- data/ews-api.gemspec +96 -0
- data/lib/ews-api.rb +16 -0
- data/lib/ews/attachment.rb +7 -0
- data/lib/ews/error.rb +14 -0
- data/lib/ews/folder.rb +44 -0
- data/lib/ews/message.rb +22 -0
- data/lib/ews/model.rb +37 -0
- data/lib/ews/parser.rb +166 -0
- data/lib/ews/service.rb +476 -0
- data/spec/ews/attachment_spec.rb +29 -0
- data/spec/ews/folder_spec.rb +85 -0
- data/spec/ews/message_spec.rb +28 -0
- data/spec/ews/model_spec.rb +31 -0
- data/spec/ews/parser_spec.rb +119 -0
- data/spec/ews/service_spec.rb +14 -0
- data/spec/fixtures/find_folder.xml +25 -0
- data/spec/fixtures/find_item.xml +20 -0
- data/spec/fixtures/find_item_all_properties.xml +120 -0
- data/spec/fixtures/get_attachment.xml +77 -0
- data/spec/fixtures/get_folder.xml +16 -0
- data/spec/fixtures/get_item_all_properties.xml +80 -0
- data/spec/fixtures/get_item_default.xml +46 -0
- data/spec/fixtures/get_item_id_only.xml +13 -0
- data/spec/fixtures/get_item_no_attachments.xml +75 -0
- data/spec/fixtures/get_item_with_error.xml +11 -0
- data/spec/integration.rb +153 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +61 -0
- metadata +145 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
<m:GetAttachmentResponse
|
2
|
+
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
|
3
|
+
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
|
4
|
+
<m:ResponseMessages>
|
5
|
+
<m:GetAttachmentResponseMessage ResponseClass="Success">
|
6
|
+
<m:ResponseCode>NoError</m:ResponseCode>
|
7
|
+
<m:Attachments>
|
8
|
+
<t:ItemAttachment>
|
9
|
+
<t:AttachmentId Id="CCC"/>
|
10
|
+
<t:Name>I am an Attachment</t:Name>
|
11
|
+
<t:ContentType>message/rfc822</t:ContentType>
|
12
|
+
<t:Message>
|
13
|
+
<t:ItemClass>IPM.Note</t:ItemClass>
|
14
|
+
<t:Subject>I am subject. Hear me roar.</t:Subject>
|
15
|
+
<t:Sensitivity>Normal</t:Sensitivity>
|
16
|
+
<t:Body BodyType="Text">Lorem ipsum dolor sit amet</t:Body>
|
17
|
+
<t:DateTimeReceived>2009-12-02T16:38:47Z</t:DateTimeReceived>
|
18
|
+
<t:Size>930</t:Size>
|
19
|
+
<t:Importance>Normal</t:Importance>
|
20
|
+
<t:IsSubmitted>false</t:IsSubmitted>
|
21
|
+
<t:IsDraft>false</t:IsDraft>
|
22
|
+
<t:IsFromMe>false</t:IsFromMe>
|
23
|
+
<t:IsResend>false</t:IsResend>
|
24
|
+
<t:IsUnmodified>false</t:IsUnmodified>
|
25
|
+
<t:InternetMessageHeaders>
|
26
|
+
<t:InternetMessageHeader HeaderName="Received">from email.example.com ([0.0.0.0]) by filter.example.com; 02 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
27
|
+
<t:InternetMessageHeader HeaderName="Received">from email.example.com (0.0.0.0) by email.example.com (0.0.0.0) with Microsoft SMTP Server ; Wed, 2 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
28
|
+
<t:InternetMessageHeader HeaderName="Message-ID"><boo@smtp.example.com></t:InternetMessageHeader>
|
29
|
+
<t:InternetMessageHeader HeaderName="Date">Wed, 2 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
30
|
+
<t:InternetMessageHeader HeaderName="Subject">I am subject. Hear me roar.</t:InternetMessageHeader>
|
31
|
+
<t:InternetMessageHeader HeaderName="MIME-Version">1.0</t:InternetMessageHeader>
|
32
|
+
<t:InternetMessageHeader HeaderName="Content-Type">text/plain</t:InternetMessageHeader>
|
33
|
+
<t:InternetMessageHeader HeaderName="Content-Transfer-Encoding">7bit</t:InternetMessageHeader>
|
34
|
+
<t:InternetMessageHeader HeaderName="Return-Path">return@example.com</t:InternetMessageHeader>
|
35
|
+
</t:InternetMessageHeaders>
|
36
|
+
<t:DateTimeSent>2009-12-02T16:38:47Z</t:DateTimeSent>
|
37
|
+
<t:DateTimeCreated>2009-12-02T16:38:47Z</t:DateTimeCreated>
|
38
|
+
<t:ResponseObjects>
|
39
|
+
<t:ReplyToItem/>
|
40
|
+
<t:ReplyAllToItem/>
|
41
|
+
<t:ForwardItem/>
|
42
|
+
</t:ResponseObjects>
|
43
|
+
<t:DisplayCc/>
|
44
|
+
<t:DisplayTo>jon.snow@example.com</t:DisplayTo>
|
45
|
+
<t:HasAttachments>false</t:HasAttachments>
|
46
|
+
<t:Culture>en</t:Culture>
|
47
|
+
<t:Sender>
|
48
|
+
<t:Mailbox>
|
49
|
+
<t:Name>arya@example.com</t:Name>
|
50
|
+
<t:EmailAddress>arya@example.com</t:EmailAddress>
|
51
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
52
|
+
</t:Mailbox>
|
53
|
+
</t:Sender>
|
54
|
+
<t:ToRecipients>
|
55
|
+
<t:Mailbox>
|
56
|
+
<t:Name>jon.snow@example.com</t:Name>
|
57
|
+
<t:EmailAddress>jon.snow@example.com</t:EmailAddress>
|
58
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
59
|
+
</t:Mailbox>
|
60
|
+
</t:ToRecipients>
|
61
|
+
<t:ConversationIndex>XYZ</t:ConversationIndex>
|
62
|
+
<t:ConversationTopic>I am subject. Hear me roar.</t:ConversationTopic>
|
63
|
+
<t:From>
|
64
|
+
<t:Mailbox>
|
65
|
+
<t:Name>arya@example.com</t:Name>
|
66
|
+
<t:EmailAddress>arya@example.com</t:EmailAddress>
|
67
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
68
|
+
</t:Mailbox>
|
69
|
+
</t:From>
|
70
|
+
<t:InternetMessageId><boo@smtp.example.com></t:InternetMessageId>
|
71
|
+
<t:IsRead>true</t:IsRead>
|
72
|
+
</t:Message>
|
73
|
+
</t:ItemAttachment>
|
74
|
+
</m:Attachments>
|
75
|
+
</m:GetAttachmentResponseMessage>
|
76
|
+
</m:ResponseMessages>
|
77
|
+
</m:GetAttachmentResponse>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<m:GetFolderResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
|
2
|
+
<m:ResponseMessages>
|
3
|
+
<m:GetFolderResponseMessage ResponseClass="Success">
|
4
|
+
<m:ResponseCode>NoError</m:ResponseCode>
|
5
|
+
<m:Folders>
|
6
|
+
<t:Folder>
|
7
|
+
<t:FolderId Id="AAA" ChangeKey="BBB"/>
|
8
|
+
<t:DisplayName>Inbox</t:DisplayName>
|
9
|
+
<t:TotalCount>43</t:TotalCount>
|
10
|
+
<t:ChildFolderCount>2</t:ChildFolderCount>
|
11
|
+
<t:UnreadCount>0</t:UnreadCount>
|
12
|
+
</t:Folder>
|
13
|
+
</m:Folders>
|
14
|
+
</m:GetFolderResponseMessage>
|
15
|
+
</m:ResponseMessages>
|
16
|
+
</m:GetFolderResponse>
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
|
2
|
+
<m:ResponseMessages>
|
3
|
+
<m:GetItemResponseMessage ResponseClass="Success">
|
4
|
+
<m:ResponseCode>NoError</m:ResponseCode>
|
5
|
+
<m:Items>
|
6
|
+
<t:Message>
|
7
|
+
<t:ItemId Id="HRlZ" ChangeKey="0Tk4V"/>
|
8
|
+
<t:ParentFolderId Id="AQAUAAA" ChangeKey="AQAAAA=="/>
|
9
|
+
<t:ItemClass>REPORT.IPM.Note.NDR</t:ItemClass>
|
10
|
+
<t:Subject>A Clash of Kings</t:Subject>
|
11
|
+
<t:Sensitivity>Normal</t:Sensitivity>
|
12
|
+
<t:Body BodyType="HTML"><html><body>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ullamcorper egestas accumsan. Nulla rhoncus porttitor dictum. Curabitur ac nulla a orci sollicitudin blandit at quis odio. Integer eleifend fringilla bibendum. Sed condimentum, lectus vitae suscipit sollicitudin, quam tortor faucibus nisl, ac tristique lectus justo in leo. Aliquam placerat arcu erat, vel lobortis dui. Nulla posuere sodales sapien eu interdum. Cras in pretium ante. Pellentesque ut velit est. Quisque nisl risus, molestie vel porta in, pellentesque a odio. Curabitur sit amet faucibus lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas et fermentum enim. Nulla ac dolor elit. Quisque eu dui sapien, ac tincidunt orci.</body></html></t:Body>
|
13
|
+
<t:Attachments>
|
14
|
+
<t:ItemAttachment>
|
15
|
+
<t:AttachmentId Id="UAHR"/>
|
16
|
+
<t:Name>A Clash of Kings</t:Name>
|
17
|
+
<t:ContentType>message/rfc822</t:ContentType>
|
18
|
+
</t:ItemAttachment>
|
19
|
+
</t:Attachments>
|
20
|
+
<t:DateTimeReceived>2009-12-02T16:38:47Z</t:DateTimeReceived>
|
21
|
+
<t:Size>5496</t:Size>
|
22
|
+
<t:Importance>Normal</t:Importance>
|
23
|
+
<t:IsSubmitted>false</t:IsSubmitted>
|
24
|
+
<t:IsDraft>false</t:IsDraft>
|
25
|
+
<t:IsFromMe>false</t:IsFromMe>
|
26
|
+
<t:IsResend>false</t:IsResend>
|
27
|
+
<t:IsUnmodified>true</t:IsUnmodified>
|
28
|
+
<t:InternetMessageHeaders>
|
29
|
+
<t:InternetMessageHeader HeaderName="Received">from example.com (0.0.0.0) by example.com (0.0.0.0) with SMTP Server id 0.0.0.0; Wed, 2 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
30
|
+
<t:InternetMessageHeader HeaderName="Received">from example.com ([0.0.0.0]) by example.com with SMTP; 02 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
31
|
+
<t:InternetMessageHeader HeaderName="Received">from example.com (0.0.0.0) by example.com (0.0.0.0) with SMTP Server id 0.0.0.0; Wed, 2 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
32
|
+
<t:InternetMessageHeader HeaderName="Received">from localhost by example.com; 02 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
33
|
+
<t:InternetMessageHeader HeaderName="Subject">A Clash of Kings</t:InternetMessageHeader>
|
34
|
+
<t:InternetMessageHeader HeaderName="Message-ID"><847mtq@example.com></t:InternetMessageHeader>
|
35
|
+
<t:InternetMessageHeader HeaderName="Date">Wed, 2 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
36
|
+
<t:InternetMessageHeader HeaderName="MIME-Version">1.0</t:InternetMessageHeader>
|
37
|
+
<t:InternetMessageHeader HeaderName="Content-Type">multipart/report</t:InternetMessageHeader>
|
38
|
+
<t:InternetMessageHeader HeaderName="Return-Path"><></t:InternetMessageHeader>
|
39
|
+
</t:InternetMessageHeaders>
|
40
|
+
<t:DateTimeSent>2009-12-02T16:38:47Z</t:DateTimeSent>
|
41
|
+
<t:DateTimeCreated>2009-12-02T16:38:47Z</t:DateTimeCreated>
|
42
|
+
<t:ResponseObjects>
|
43
|
+
<t:ForwardItem/>
|
44
|
+
</t:ResponseObjects>
|
45
|
+
<t:DisplayCc/>
|
46
|
+
<t:DisplayTo>sansa@example.com</t:DisplayTo>
|
47
|
+
<t:HasAttachments>true</t:HasAttachments>
|
48
|
+
<t:Culture>en-US</t:Culture>
|
49
|
+
<t:Sender>
|
50
|
+
<t:Mailbox>
|
51
|
+
<t:Name>Mail Delivery System</t:Name>
|
52
|
+
<t:EmailAddress>DAEMON@example.com</t:EmailAddress>
|
53
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
54
|
+
</t:Mailbox>
|
55
|
+
</t:Sender>
|
56
|
+
<t:ToRecipients>
|
57
|
+
<t:Mailbox>
|
58
|
+
<t:Name>sansa@example.com</t:Name>
|
59
|
+
<t:EmailAddress>sansa@example.com</t:EmailAddress>
|
60
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
61
|
+
</t:Mailbox>
|
62
|
+
</t:ToRecipients>
|
63
|
+
<t:IsReadReceiptRequested>false</t:IsReadReceiptRequested>
|
64
|
+
<t:IsDeliveryReceiptRequested>false</t:IsDeliveryReceiptRequested>
|
65
|
+
<t:ConversationIndex>AAAADR</t:ConversationIndex>
|
66
|
+
<t:ConversationTopic>A Clash of Kings</t:ConversationTopic>
|
67
|
+
<t:From>
|
68
|
+
<t:Mailbox>
|
69
|
+
<t:Name>Mail Delivery System</t:Name>
|
70
|
+
<t:EmailAddress>DAEMON@example.com</t:EmailAddress>
|
71
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
72
|
+
</t:Mailbox>
|
73
|
+
</t:From>
|
74
|
+
<t:InternetMessageId><8i32324i$hmtq@example.com></t:InternetMessageId>
|
75
|
+
<t:IsRead>true</t:IsRead>
|
76
|
+
</t:Message>
|
77
|
+
</m:Items>
|
78
|
+
</m:GetItemResponseMessage>
|
79
|
+
</m:ResponseMessages>
|
80
|
+
</m:GetItemResponse>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
|
2
|
+
<m:ResponseMessages>
|
3
|
+
<m:GetItemResponseMessage ResponseClass="Success">
|
4
|
+
<m:ResponseCode>NoError</m:ResponseCode>
|
5
|
+
<m:Items>
|
6
|
+
<t:Message>
|
7
|
+
<t:ItemId Id="EEE" ChangeKey="999"/>
|
8
|
+
<t:Subject>I am a subject. Hear me roar.</t:Subject>
|
9
|
+
<t:Sensitivity>Normal</t:Sensitivity>
|
10
|
+
<t:Body BodyType="HTML"><html><body>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ullamcorper egestas accumsan. Nulla rhoncus porttitor dictum. Curabitur ac nulla a orci sollicitudin blandit at quis odio. Integer eleifend fringilla bibendum. Sed condimentum, lectus vitae suscipit sollicitudin, quam tortor faucibus nisl, ac tristique lectus justo in leo. Aliquam placerat arcu erat, vel lobortis dui. Nulla posuere sodales sapien eu interdum. Cras in pretium ante. Pellentesque ut velit est. Quisque nisl risus, molestie vel porta in, pellentesque a odio. Curabitur sit amet faucibus lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas et fermentum enim. Nulla ac dolor elit. Quisque eu dui sapien, ac tincidunt orci.</body></html></t:Body>
|
11
|
+
<t:Attachments>
|
12
|
+
<t:ItemAttachment>
|
13
|
+
<t:AttachmentId Id="XXX"/>
|
14
|
+
<t:Name>I have attached myself to this message.</t:Name>
|
15
|
+
<t:ContentType>message/rfc822</t:ContentType>
|
16
|
+
</t:ItemAttachment>
|
17
|
+
</t:Attachments>
|
18
|
+
<t:Size>5496</t:Size>
|
19
|
+
<t:DateTimeSent>2009-12-02T16:38:47Z</t:DateTimeSent>
|
20
|
+
<t:DateTimeCreated>2009-12-02T16:38:47Z</t:DateTimeCreated>
|
21
|
+
<t:ResponseObjects>
|
22
|
+
<t:ForwardItem/>
|
23
|
+
</t:ResponseObjects>
|
24
|
+
<t:HasAttachments>true</t:HasAttachments>
|
25
|
+
<t:ToRecipients>
|
26
|
+
<t:Mailbox>
|
27
|
+
<t:Name>doesnotexist@example.com</t:Name>
|
28
|
+
<t:EmailAddress>doesnotexist@example.com</t:EmailAddress>
|
29
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
30
|
+
</t:Mailbox>
|
31
|
+
</t:ToRecipients>
|
32
|
+
<t:IsReadReceiptRequested>false</t:IsReadReceiptRequested>
|
33
|
+
<t:IsDeliveryReceiptRequested>false</t:IsDeliveryReceiptRequested>
|
34
|
+
<t:From>
|
35
|
+
<t:Mailbox>
|
36
|
+
<t:Name>Mail Delivery System</t:Name>
|
37
|
+
<t:EmailAddress>MAILER-DAEMON@example.com</t:EmailAddress>
|
38
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
39
|
+
</t:Mailbox>
|
40
|
+
</t:From>
|
41
|
+
<t:IsRead>true</t:IsRead>
|
42
|
+
</t:Message>
|
43
|
+
</m:Items>
|
44
|
+
</m:GetItemResponseMessage>
|
45
|
+
</m:ResponseMessages>
|
46
|
+
</m:GetItemResponse>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
|
2
|
+
<m:ResponseMessages>
|
3
|
+
<m:GetItemResponseMessage ResponseClass="Success">
|
4
|
+
<m:ResponseCode>NoError</m:ResponseCode>
|
5
|
+
<m:Items>
|
6
|
+
<t:Message>
|
7
|
+
<t:ItemId Id="AFTRNedwA" ChangeKey="FwAAA"/>
|
8
|
+
</t:Message>
|
9
|
+
</m:Items>
|
10
|
+
</m:GetItemResponseMessage>
|
11
|
+
</m:ResponseMessages>
|
12
|
+
</m:GetItemResponse>
|
13
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
|
2
|
+
<m:ResponseMessages>
|
3
|
+
<m:GetItemResponseMessage ResponseClass="Success">
|
4
|
+
<m:ResponseCode>NoError</m:ResponseCode>
|
5
|
+
<m:Items>
|
6
|
+
<t:Message>
|
7
|
+
<t:ItemId Id="HRlZ" ChangeKey="0Tk4V"/>
|
8
|
+
<t:ParentFolderId Id="AQAUAAA" ChangeKey="AQAAAA=="/>
|
9
|
+
<t:ItemClass>REPORT.IPM.Note.NDR</t:ItemClass>
|
10
|
+
<t:Subject>A Clash of Kings</t:Subject>
|
11
|
+
<t:Sensitivity>Normal</t:Sensitivity>
|
12
|
+
<t:Body BodyType="HTML"><html><body>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ullamcorper egestas accumsan. Nulla rhoncus porttitor dictum. Curabitur ac nulla a orci sollicitudin blandit at quis odio. Integer eleifend fringilla bibendum. Sed condimentum, lectus vitae suscipit sollicitudin, quam tortor faucibus nisl, ac tristique lectus justo in leo. Aliquam placerat arcu erat, vel lobortis dui. Nulla posuere sodales sapien eu interdum. Cras in pretium ante. Pellentesque ut velit est. Quisque nisl risus, molestie vel porta in, pellentesque a odio. Curabitur sit amet faucibus lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas et fermentum enim. Nulla ac dolor elit. Quisque eu dui sapien, ac tincidunt orci.</body></html></t:Body>
|
13
|
+
<t:Attachments>
|
14
|
+
</t:Attachments>
|
15
|
+
<t:DateTimeReceived>2009-12-02T16:38:47Z</t:DateTimeReceived>
|
16
|
+
<t:Size>5496</t:Size>
|
17
|
+
<t:Importance>Normal</t:Importance>
|
18
|
+
<t:IsSubmitted>false</t:IsSubmitted>
|
19
|
+
<t:IsDraft>false</t:IsDraft>
|
20
|
+
<t:IsFromMe>false</t:IsFromMe>
|
21
|
+
<t:IsResend>false</t:IsResend>
|
22
|
+
<t:IsUnmodified>true</t:IsUnmodified>
|
23
|
+
<t:InternetMessageHeaders>
|
24
|
+
<t:InternetMessageHeader HeaderName="Received">from example.com (0.0.0.0) by example.com (0.0.0.0) with SMTP Server id 0.0.0.0; Wed, 2 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
25
|
+
<t:InternetMessageHeader HeaderName="Received">from example.com ([0.0.0.0]) by example.com with SMTP; 02 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
26
|
+
<t:InternetMessageHeader HeaderName="Received">from example.com (0.0.0.0) by example.com (0.0.0.0) with SMTP Server id 0.0.0.0; Wed, 2 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
27
|
+
<t:InternetMessageHeader HeaderName="Received">from localhost by example.com; 02 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
28
|
+
<t:InternetMessageHeader HeaderName="Subject">A Clash of Kings</t:InternetMessageHeader>
|
29
|
+
<t:InternetMessageHeader HeaderName="Message-ID"><847mtq@example.com></t:InternetMessageHeader>
|
30
|
+
<t:InternetMessageHeader HeaderName="Date">Wed, 2 Dec 2009 10:38:47 -0600</t:InternetMessageHeader>
|
31
|
+
<t:InternetMessageHeader HeaderName="MIME-Version">1.0</t:InternetMessageHeader>
|
32
|
+
<t:InternetMessageHeader HeaderName="Content-Type">multipart/report</t:InternetMessageHeader>
|
33
|
+
<t:InternetMessageHeader HeaderName="Return-Path"><></t:InternetMessageHeader>
|
34
|
+
</t:InternetMessageHeaders>
|
35
|
+
<t:DateTimeSent>2009-12-02T16:38:47Z</t:DateTimeSent>
|
36
|
+
<t:DateTimeCreated>2009-12-02T16:38:47Z</t:DateTimeCreated>
|
37
|
+
<t:ResponseObjects>
|
38
|
+
<t:ForwardItem/>
|
39
|
+
</t:ResponseObjects>
|
40
|
+
<t:DisplayCc/>
|
41
|
+
<t:DisplayTo>sansa@example.com</t:DisplayTo>
|
42
|
+
<t:HasAttachments>false</t:HasAttachments>
|
43
|
+
<t:Culture>en-US</t:Culture>
|
44
|
+
<t:Sender>
|
45
|
+
<t:Mailbox>
|
46
|
+
<t:Name>Mail Delivery System</t:Name>
|
47
|
+
<t:EmailAddress>DAEMON@example.com</t:EmailAddress>
|
48
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
49
|
+
</t:Mailbox>
|
50
|
+
</t:Sender>
|
51
|
+
<t:ToRecipients>
|
52
|
+
<t:Mailbox>
|
53
|
+
<t:Name>sansa@example.com</t:Name>
|
54
|
+
<t:EmailAddress>sansa@example.com</t:EmailAddress>
|
55
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
56
|
+
</t:Mailbox>
|
57
|
+
</t:ToRecipients>
|
58
|
+
<t:IsReadReceiptRequested>false</t:IsReadReceiptRequested>
|
59
|
+
<t:IsDeliveryReceiptRequested>false</t:IsDeliveryReceiptRequested>
|
60
|
+
<t:ConversationIndex>AAAADR</t:ConversationIndex>
|
61
|
+
<t:ConversationTopic>A Clash of Kings</t:ConversationTopic>
|
62
|
+
<t:From>
|
63
|
+
<t:Mailbox>
|
64
|
+
<t:Name>Mail Delivery System</t:Name>
|
65
|
+
<t:EmailAddress>DAEMON@example.com</t:EmailAddress>
|
66
|
+
<t:RoutingType>SMTP</t:RoutingType>
|
67
|
+
</t:Mailbox>
|
68
|
+
</t:From>
|
69
|
+
<t:InternetMessageId><8i32324i$hmtq@example.com></t:InternetMessageId>
|
70
|
+
<t:IsRead>true</t:IsRead>
|
71
|
+
</t:Message>
|
72
|
+
</m:Items>
|
73
|
+
</m:GetItemResponseMessage>
|
74
|
+
</m:ResponseMessages>
|
75
|
+
</m:GetItemResponse>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
|
2
|
+
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
|
3
|
+
<m:ResponseMessages>
|
4
|
+
<m:GetItemResponseMessage ResponseClass="Error">
|
5
|
+
<m:MessageText>Id must be non-empty.</m:MessageText>
|
6
|
+
<m:ResponseCode>ErrorInvalidIdEmpty</m:ResponseCode>
|
7
|
+
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
|
8
|
+
<m:Items/>
|
9
|
+
</m:GetItemResponseMessage>
|
10
|
+
</m:ResponseMessages>
|
11
|
+
</m:GetItemResponse>
|
data/spec/integration.rb
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
config_file = File.dirname(__FILE__) + '/test-config.yml'
|
4
|
+
|
5
|
+
if File.exist?(config_file)
|
6
|
+
unless defined? EWS_CONFIG
|
7
|
+
EWS_CONFIG = YAML.load_file config_file
|
8
|
+
end
|
9
|
+
|
10
|
+
EWS::Service.endpoint EWS_CONFIG['endpoint']
|
11
|
+
EWS::Service.set_auth EWS_CONFIG['username'], EWS_CONFIG['password']
|
12
|
+
else
|
13
|
+
unless defined? EWS_CONFIG
|
14
|
+
EWS_CONFIG = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
puts <<-EOS
|
18
|
+
|
19
|
+
=================================================================
|
20
|
+
Create 'spec/test-config.yml' to automatically configure
|
21
|
+
the endpoint and credentials. The file is ignored via
|
22
|
+
.gitignore so it will not be committed.
|
23
|
+
|
24
|
+
endpoint:
|
25
|
+
:uri: 'https://localhost/ews/exchange.asmx'
|
26
|
+
:version: 1
|
27
|
+
username: testuser
|
28
|
+
password: xxxxxx
|
29
|
+
|
30
|
+
=================================================================
|
31
|
+
|
32
|
+
EOS
|
33
|
+
end
|
34
|
+
|
35
|
+
EWS::Service.logger = $stdout
|
36
|
+
|
37
|
+
describe 'Integration Tests' do
|
38
|
+
context 'find_folder' do
|
39
|
+
it "should find the folder without errors" do
|
40
|
+
lambda do
|
41
|
+
EWS::Service.find_folder(:inbox)
|
42
|
+
end.should_not raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should raise a Fault when the item does not exist" do
|
46
|
+
error_msg = /The value 'does-not-exist' is invalid according to its datatype/
|
47
|
+
lambda do
|
48
|
+
EWS::Service.find_folder('does-not-exist')
|
49
|
+
end.should raise_error(Handsoap::Fault, error_msg)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'get_folder' do
|
54
|
+
it "should get the folder using the Default base_shape" do
|
55
|
+
EWS::Service.get_folder(:inbox).should be_instance_of(EWS::Folder)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should get the folder using the AllProperties base_shape" do
|
59
|
+
folder = EWS::Service.get_folder(:inbox, :base_shape => :AllProperties)
|
60
|
+
folder.should be_instance_of(EWS::Folder)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should get the folder without errors" do
|
64
|
+
EWS::Service.get_folder(:inbox).should be_instance_of(EWS::Folder)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should raise a SoapError when the ResponseMessage is an Error" do
|
68
|
+
error_msg = /The value 'does-not-exist' is invalid according to its datatype/
|
69
|
+
lambda do
|
70
|
+
EWS::Service.get_folder('does-not-exist')
|
71
|
+
end.should raise_error(Handsoap::Fault, error_msg)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'find_item' do
|
76
|
+
it "should find the item using the base_shape of 'Default'" do
|
77
|
+
items = EWS::Service.find_item :inbox, :base_shape => :Default
|
78
|
+
items.should be_instance_of(Array)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should find the item using the base_shape of 'AllProperties'" do
|
82
|
+
items = EWS::Service.find_item :inbox, :base_shape => :AllProperties
|
83
|
+
items.should be_instance_of(Array)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should raise a Fault when the item does not exist" do
|
87
|
+
error_msg = /The value 'does-not-exist' is invalid according to its datatype/
|
88
|
+
lambda do
|
89
|
+
EWS::Service.find_item('does-not-exist')
|
90
|
+
end.should raise_error(Handsoap::Fault, error_msg)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'get_item' do
|
95
|
+
it "should get the item using the base_shape of 'IdOnly'" do
|
96
|
+
item = EWS::Service.get_item EWS_CONFIG['item_id'], :base_shape => :IdOnly
|
97
|
+
item.should be_instance_of(EWS::Message)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should get the item using the base_shape of 'Default'" do
|
101
|
+
item = EWS::Service.get_item EWS_CONFIG['item_id'], :base_shape => :Default
|
102
|
+
item.should be_instance_of(EWS::Message)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should get the item using the base_shape of 'AllProperties'" do
|
106
|
+
item = EWS::Service.get_item EWS_CONFIG['item_id'], :base_shape => :AllProperties
|
107
|
+
item.should be_instance_of(EWS::Message)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should raise a SoapError when the ResponseMessage is an Error" do
|
111
|
+
lambda do
|
112
|
+
EWS::Service.get_item(nil)
|
113
|
+
end.should raise_error(EWS::ResponseError, /Id must be non-empty/)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'get_attachment' do
|
118
|
+
it "should get the attachment without errors" do
|
119
|
+
lambda do
|
120
|
+
rtn = EWS::Service.get_attachment EWS_CONFIG['attachment_id'] # lame
|
121
|
+
end.should_not raise_error
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should raise a EWS::ResponseError when the ResponseMessage is an Error" do
|
125
|
+
lambda do
|
126
|
+
EWS::Service.get_attachment(nil)
|
127
|
+
end.should raise_error(EWS::ResponseError, /Id must be non-empty/)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'move_item' do
|
132
|
+
#it "should move the item" do
|
133
|
+
# folder_id = 'AQAUAHRlc3RxZHNib3VuY2VAcWcuY29tAC4AAAMXckeXPuMKT4uj0fYRoj0SAQAUIOj2Wr1iR63wVBJuRuVLABU0TWDnAAAA'
|
134
|
+
#
|
135
|
+
# id = 'AAAUAHRlc3RxZHNib3VuY2VAcWcuY29tAEYAAAAAABdyR5c+4wpPi6PR9hGiPRIHABQg6PZavWJHrfBUEm5G5UsAFTRNedwAABQg6PZavWJHrfBUEm5G5UsAFTRNhHAAAA=='
|
136
|
+
#
|
137
|
+
# EWS::Service.move_item!(folder_id, [id])
|
138
|
+
# end
|
139
|
+
|
140
|
+
it "should raise an EWS::ResponseError when the item id does not exist" do
|
141
|
+
lambda do
|
142
|
+
EWS::Service.move_item!('aaaaa', ['does-not-exist'])
|
143
|
+
end.should raise_error(EWS::ResponseError, /Id is malformed/)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should raise a EWS::ResponseError when the folder_id does not exist" do
|
147
|
+
lambda do
|
148
|
+
EWS::Service.move_item!('does-not-exist', ['whatever'])
|
149
|
+
end.should raise_error(EWS::ResponseError, /Id is malformed/)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|