viewpoint 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.txt +939 -0
- data/VERSION +1 -1
- data/lib/model/{meeting_message.rb → attendee.rb} +13 -4
- data/lib/model/calendar_folder.rb +13 -0
- data/lib/model/calendar_item.rb +2 -2
- data/lib/model/generic_folder.rb +16 -0
- data/lib/model/item.rb +2 -12
- data/lib/model/message.rb +9 -0
- data/lib/model/model.rb +40 -3
- data/lib/soap/handsoap/ews_service.rb +13 -3
- data/lib/viewpoint.rb +1 -4
- metadata +4 -7
- data/lib/model/meeting_cancellation.rb +0 -28
- data/lib/model/meeting_request.rb +0 -41
- data/lib/model/meeting_response.rb +0 -26
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
@@ -20,11 +20,20 @@
|
|
20
20
|
|
21
21
|
module Viewpoint
|
22
22
|
module EWS
|
23
|
-
class MeetingMessage < Item
|
24
23
|
|
25
|
-
|
26
|
-
|
24
|
+
# This represents a Mailbox object in the Exchange data store
|
25
|
+
# @see http://msdn.microsoft.com/en-us/library/aa565036.aspx MSDN docs
|
26
|
+
# @todo Design a Class method that resolves to an Array of MailboxUsers
|
27
|
+
class Attendee < MailboxUser
|
28
|
+
include Model
|
29
|
+
|
30
|
+
attr_reader :response
|
31
|
+
|
32
|
+
def initialize(attendee)
|
33
|
+
@response = attendee[:response_type][:text]
|
34
|
+
super(attendee[:mailbox])
|
27
35
|
end
|
28
|
-
|
36
|
+
|
37
|
+
end # Attendee
|
29
38
|
end # EWS
|
30
39
|
end # Viewpoint
|
@@ -63,6 +63,19 @@ module Viewpoint
|
|
63
63
|
end
|
64
64
|
super(opts)
|
65
65
|
end
|
66
|
+
alias :items_between :find_items
|
67
|
+
|
68
|
+
# Fetch only items from today (since midnight)
|
69
|
+
def todays_items
|
70
|
+
#This is a bit convoluted for pre-1.9.x ruby versions that don't support to_datetime
|
71
|
+
find_items(DateTime.parse(Date.today.to_s), DateTime.parse((Date.today + 1).to_s))
|
72
|
+
end
|
73
|
+
|
74
|
+
# Fetch items since a give DateTime
|
75
|
+
# @param [DateTime] start_date_time the time to fetch Items since.
|
76
|
+
def items_since(start_date_time)
|
77
|
+
find_items(start_date_time, DateTime.now)
|
78
|
+
end
|
66
79
|
|
67
80
|
end # CalendarFolder
|
68
81
|
end # EWS
|
data/lib/model/calendar_item.rb
CHANGED
@@ -122,7 +122,7 @@ module Viewpoint
|
|
122
122
|
|
123
123
|
def init_methods
|
124
124
|
super
|
125
|
-
define_str_var :calendar_item_type, :duration, :time_zone, :when, :location
|
125
|
+
define_str_var :calendar_item_type, :duration, :time_zone, :when, :location, :u_i_d, {:u_i_d => :uid}
|
126
126
|
define_str_var :legacy_free_busy_status, :my_response_type, :meeting_workspace_url, :net_show_url
|
127
127
|
define_int_var :adjacent_meeting_count, :appointment_sequence_number, :appointment_state
|
128
128
|
define_int_var :conference_type, :conflicting_meeting_count
|
@@ -130,12 +130,12 @@ module Viewpoint
|
|
130
130
|
define_bool_var :is_all_day_event, :is_cancelled, :is_meeting, :is_online_meeting, :is_recurring
|
131
131
|
define_bool_var :allow_new_time_proposal, :meeting_request_was_sent
|
132
132
|
define_datetime_var :appointment_reply_time, :start, :end, :original_start
|
133
|
+
define_attendees :required_attendees, :optional_attendees, :resources
|
133
134
|
|
134
135
|
# @todo Handle:
|
135
136
|
# <AdjacentMeetings/> <ConflictingMeetings/> <DeletedOccurrences/>
|
136
137
|
# <FirstOccurrence/> <LastOccurrence/> <ModifiedOccurrences/>
|
137
138
|
# <StartTimeZone/> <EndTimeZone/> <MeetingTimeZone/>
|
138
|
-
# <OptionalAttendees/> <RequiredAttendees/> <Resources/>
|
139
139
|
# <Recurrence/>
|
140
140
|
end
|
141
141
|
|
data/lib/model/generic_folder.rb
CHANGED
@@ -40,6 +40,12 @@ module Viewpoint
|
|
40
40
|
|
41
41
|
@@event_types = %w{CopiedEvent CreatedEvent DeletedEvent ModifiedEvent MovedEvent NewMailEvent}
|
42
42
|
|
43
|
+
# Get a specific folder by its ID.
|
44
|
+
# @param [String,Symbol] folder_id either a DistinguishedFolderID or simply a FolderID
|
45
|
+
# @param [String,nil] act_as User to act on behalf as. This user must have been given
|
46
|
+
# delegate access to this folder or else this operation will fail.
|
47
|
+
# @param [Hash] folder_shape
|
48
|
+
# @option folder_shape [String] :base_shape IdOnly/Default/AllProperties
|
43
49
|
def self.get_folder(folder_id, act_as = nil, folder_shape = {:base_shape => 'Default'})
|
44
50
|
resp = (Viewpoint::EWS::EWS.instance).ews.get_folder( [normalize_id(folder_id)], folder_shape, act_as )
|
45
51
|
if(resp.status == 'Success')
|
@@ -88,6 +94,7 @@ module Viewpoint
|
|
88
94
|
|
89
95
|
# Gets a folder by name. This name must match the folder name exactly.
|
90
96
|
# @param [String] name The name of the folder to fetch.
|
97
|
+
# @param [String] shape the shape of the object to return IdOnly/Default/AllProperties
|
91
98
|
def self.get_folder_by_name(name, shape = 'Default')
|
92
99
|
# For now the :field_uRI and :field_uRI_or_constant must be in an Array for Ruby 1.8.7 because Hashes
|
93
100
|
# are not positional at insertion until 1.9
|
@@ -212,12 +219,15 @@ module Viewpoint
|
|
212
219
|
end
|
213
220
|
end
|
214
221
|
|
222
|
+
# Fetch only items from today (since midnight)
|
215
223
|
def todays_items
|
216
224
|
#opts = {:query_string => ["Received:today"]}
|
217
225
|
#This is a bit convoluted for pre-1.9.x ruby versions that don't support to_datetime
|
218
226
|
items_since(DateTime.parse(Date.today.to_s))
|
219
227
|
end
|
220
228
|
|
229
|
+
# Fetch items since a give DateTime
|
230
|
+
# @param [DateTime] date_time the time to fetch Items since.
|
221
231
|
def items_since(date_time)
|
222
232
|
restr = {:restriction =>
|
223
233
|
{:is_greater_than_or_equal_to =>
|
@@ -227,6 +237,9 @@ module Viewpoint
|
|
227
237
|
find_items(restr)
|
228
238
|
end
|
229
239
|
|
240
|
+
# Fetch items between a given time period
|
241
|
+
# @param [DateTime] start_date the time to start fetching Items from
|
242
|
+
# @param [DateTime] end_date the time to stop fetching Items from
|
230
243
|
def items_between(start_date, end_date)
|
231
244
|
restr = {:restriction => {:and => [
|
232
245
|
{:is_greater_than_or_equal_to =>
|
@@ -271,6 +284,9 @@ module Viewpoint
|
|
271
284
|
end
|
272
285
|
|
273
286
|
# Get Item
|
287
|
+
# @param [String] item_id the ID of the item to fetch
|
288
|
+
# @param [String] change_key specify an optional change_key if you want to
|
289
|
+
# make sure you are fetching a specific version of the object.
|
274
290
|
def get_item(item_id, change_key = nil)
|
275
291
|
resp = (Viewpoint::EWS::EWS.instance).ews.get_item([item_id])
|
276
292
|
if(resp.status == 'Success')
|
data/lib/model/item.rb
CHANGED
@@ -209,22 +209,12 @@ module Viewpoint
|
|
209
209
|
@parent_folder_id = @ews_item[:parent_folder_id][:id] if @ews_item[:parent_folder_id].is_a?(Hash)
|
210
210
|
@conversation_id = @ews_item[:conversation_id][:id] if @ews_item[:conversation_id].is_a?(Hash)
|
211
211
|
@ews_methods << :item_id
|
212
|
-
if(@ews_item[:body] && @ews_item[:body][:body_type])
|
213
|
-
@body_type = @ews_item[:body][:body_type]
|
214
|
-
@ews_methods << :body_type
|
215
|
-
end
|
216
|
-
if(@ews_item[:unique_body] && @ews_item[:unique_body][:body_type])
|
217
|
-
@unique_body_type = @ews_item[:body][:body_type]
|
218
|
-
@ews_methods << :unique_body_type
|
219
|
-
end
|
220
|
-
if(@ews_item[:mime_content] && @ews_item[:mime_content][:character_set])
|
221
|
-
@mime_charset = @ews_item[:mime_content][:character_set]
|
222
|
-
@ews_methods << :mime_charset
|
223
|
-
end
|
224
212
|
define_str_var :subject, :sensitivity, :body, :item_class, :importance, :in_reply_to, :unique_body
|
225
213
|
define_str_var :display_cc, :display_to, :culture, :last_modified_name, :mime_content
|
226
214
|
define_str_var :web_client_read_form_query_string, :web_client_edit_form_query_string
|
227
215
|
define_attr_str_var :body, :body_type
|
216
|
+
define_attr_str_var :unique_body, :body_type
|
217
|
+
define_attr_str_var :mime_content, :character_set
|
228
218
|
define_int_var :size, :reminder_minutes_before_start
|
229
219
|
define_bool_var :has_attachments, :is_submitted, :is_draft, :is_from_me, :is_resend, :is_unmodified, :reminder_is_set, :is_associated
|
230
220
|
define_datetime_var :date_time_sent, :date_time_created, :date_time_received, :reminder_due_by, :last_modified_time
|
data/lib/model/message.rb
CHANGED
@@ -112,6 +112,15 @@ module Viewpoint
|
|
112
112
|
body msg.body
|
113
113
|
end
|
114
114
|
end
|
115
|
+
|
116
|
+
# add attachments
|
117
|
+
if(self.has_attachments?)
|
118
|
+
self.attachments.each do |att|
|
119
|
+
if(att.is_a?(FileAttachment))
|
120
|
+
mail.attachments[att.file_name] = Base64.decode64(att.content)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
115
124
|
mail
|
116
125
|
end
|
117
126
|
|
data/lib/model/model.rb
CHANGED
@@ -47,16 +47,21 @@ module Viewpoint
|
|
47
47
|
# Define a method that returns a string. The vars are the keys in the
|
48
48
|
# hash that contain a :text key. In the original SOAP packet this would
|
49
49
|
# look something like this:
|
50
|
+
# @param [Array<Symbol,Hash>] *vars the symbols to map to methods. If the
|
51
|
+
# last item is a hash it will be used to map methods names. For instance
|
52
|
+
# UID comes through like this :u_i_d so we can map it like so {:u_i_d => :uid}
|
50
53
|
# @example
|
51
54
|
# <method_name>
|
52
55
|
# This is the text
|
53
56
|
# </method_name>
|
54
57
|
def define_str_var(*vars)
|
58
|
+
map = ( vars.last.is_a?(Hash) ? vars.pop : {})
|
55
59
|
vars.each do |var|
|
56
60
|
if(@ews_item[var])
|
57
|
-
|
61
|
+
mname = ( map.has_key?(var) ? map[var] : var )
|
62
|
+
@ews_methods << mname
|
58
63
|
self.instance_eval <<-EOF
|
59
|
-
def #{
|
64
|
+
def #{mname}
|
60
65
|
@ews_item[:#{var}][:text]
|
61
66
|
end
|
62
67
|
EOF
|
@@ -71,7 +76,8 @@ module Viewpoint
|
|
71
76
|
# to by :text. In the orignal SOAP it may have looked like this:
|
72
77
|
# @example
|
73
78
|
# <node my_method='this is the text'/>
|
74
|
-
#
|
79
|
+
# so you would specify this...
|
80
|
+
# define_attr_str_var :node, :my_method
|
75
81
|
def define_attr_str_var(parent, *vars)
|
76
82
|
return unless @ews_item[parent]
|
77
83
|
vars.each do |var|
|
@@ -160,6 +166,7 @@ module Viewpoint
|
|
160
166
|
end
|
161
167
|
end
|
162
168
|
|
169
|
+
|
163
170
|
def define_mbox_user(*vars)
|
164
171
|
vars.each do |var|
|
165
172
|
if(@ews_item[var])
|
@@ -174,6 +181,36 @@ module Viewpoint
|
|
174
181
|
end
|
175
182
|
end
|
176
183
|
end
|
184
|
+
|
185
|
+
|
186
|
+
# Define meeting attendees
|
187
|
+
# @param [String] *attendee_types the type of attendee we are defining :required_attendees, :optional_attendees
|
188
|
+
def define_attendees(*attendee_types)
|
189
|
+
attendee_types.each do |attendee_type|
|
190
|
+
if(@ews_item.has_key?(attendee_type))
|
191
|
+
@ews_methods << attendee_type
|
192
|
+
self.instance_eval <<-EOF
|
193
|
+
def #{attendee_type}
|
194
|
+
return @#{attendee_type} if defined?(@#{attendee_type})
|
195
|
+
if( (@ews_item[:#{attendee_type}][:attendee]).is_a?(Hash) )
|
196
|
+
@#{attendee_type} = [Attendee.new(@ews_item[:#{attendee_type}][:attendee])]
|
197
|
+
elsif( (@ews_item[:#{attendee_type}][:attendee]).is_a?(Array) )
|
198
|
+
@#{attendee_type} = []
|
199
|
+
@ews_item[:#{attendee_type}][:attendee].each do |i|
|
200
|
+
@#{attendee_type} << Attendee.new(i)
|
201
|
+
end
|
202
|
+
else
|
203
|
+
raise EwsError, "Bad value for mailbox: " + @ews_item[:#{attendee_type}][:attendee]
|
204
|
+
end
|
205
|
+
@#{attendee_type}
|
206
|
+
end
|
207
|
+
EOF
|
208
|
+
else
|
209
|
+
@ews_methods_undef << attendee_type
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
177
214
|
|
178
215
|
# After a delete is called on an object this method will clear
|
179
216
|
# out all of the defined EWS methods so they can't be called on the
|
@@ -360,12 +360,22 @@ module Viewpoint
|
|
360
360
|
parse!(resp)
|
361
361
|
end
|
362
362
|
|
363
|
+
# Defines a request to synchronize a folder hierarchy on a client
|
364
|
+
# @see http://msdn.microsoft.com/en-us/library/aa580990.aspx
|
363
365
|
def sync_folder_hierarchy
|
366
|
+
sync_state = nil
|
367
|
+
folder_id = :publicfoldersroot
|
364
368
|
action = "#{SOAP_ACTION_PREFIX}/SyncFolderHierarchy"
|
365
|
-
resp = invoke("#{NS_EWS_MESSAGES}:SyncFolderHierarchy", action) do |
|
366
|
-
|
369
|
+
resp = invoke("#{NS_EWS_MESSAGES}:SyncFolderHierarchy", action) do |root|
|
370
|
+
build!(root) do
|
371
|
+
folder_shape!(root, {:base_shape => 'Default'})
|
372
|
+
root.add("#{NS_EWS_MESSAGES}:SyncFolderId") do |sfid|
|
373
|
+
folder_id!(sfid, folder_id)
|
374
|
+
end
|
375
|
+
sync_state!(root, sync_state) unless sync_state.nil?
|
376
|
+
end
|
367
377
|
end
|
368
|
-
|
378
|
+
parse!(resp)
|
369
379
|
end
|
370
380
|
|
371
381
|
# Synchronizes items between the Exchange server and the client
|
data/lib/viewpoint.rb
CHANGED
@@ -33,6 +33,7 @@ require 'soap/soap_provider'
|
|
33
33
|
# Base Models
|
34
34
|
require 'model/model'
|
35
35
|
require 'model/mailbox_user'
|
36
|
+
require 'model/attendee'
|
36
37
|
require 'model/generic_folder'
|
37
38
|
require 'model/item'
|
38
39
|
# Specific Models
|
@@ -47,10 +48,6 @@ require 'model/message'
|
|
47
48
|
require 'model/calendar_item'
|
48
49
|
require 'model/contact'
|
49
50
|
require 'model/distribution_list'
|
50
|
-
require 'model/meeting_message'
|
51
|
-
require 'model/meeting_request'
|
52
|
-
require 'model/meeting_response'
|
53
|
-
require 'model/meeting_cancellation'
|
54
51
|
require 'model/task'
|
55
52
|
require 'model/attachment'
|
56
53
|
require 'model/file_attachment'
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 8
|
9
|
+
version: 0.1.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Dan Wanek
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-24 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/exceptions/exceptions.rb
|
119
119
|
- lib/extensions/string.rb
|
120
120
|
- lib/model/attachment.rb
|
121
|
+
- lib/model/attendee.rb
|
121
122
|
- lib/model/calendar_folder.rb
|
122
123
|
- lib/model/calendar_item.rb
|
123
124
|
- lib/model/contact.rb
|
@@ -130,10 +131,6 @@ files:
|
|
130
131
|
- lib/model/item.rb
|
131
132
|
- lib/model/item_attachment.rb
|
132
133
|
- lib/model/mailbox_user.rb
|
133
|
-
- lib/model/meeting_cancellation.rb
|
134
|
-
- lib/model/meeting_message.rb
|
135
|
-
- lib/model/meeting_request.rb
|
136
|
-
- lib/model/meeting_response.rb
|
137
134
|
- lib/model/message.rb
|
138
135
|
- lib/model/model.rb
|
139
136
|
- lib/model/search_folder.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
#############################################################################
|
2
|
-
# Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# This file is part of Viewpoint.
|
6
|
-
#
|
7
|
-
# Viewpoint is free software: you can redistribute it and/or
|
8
|
-
# modify it under the terms of the GNU General Public License as published
|
9
|
-
# by the Free Software Foundation, either version 3 of the License, or (at
|
10
|
-
# your option) any later version.
|
11
|
-
#
|
12
|
-
# Viewpoint is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
15
|
-
# Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License along
|
18
|
-
# with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
#############################################################################
|
20
|
-
|
21
|
-
module Viewpoint
|
22
|
-
module EWS
|
23
|
-
# Meeting cancellations have the exact same elements as a Meeting Message
|
24
|
-
# so MeetingCancellation is just a subclass of that.
|
25
|
-
class MeetingCancellation < MeetingMessage
|
26
|
-
end # MeetingCancellation
|
27
|
-
end # EWS
|
28
|
-
end # Viewpoint
|
@@ -1,41 +0,0 @@
|
|
1
|
-
#############################################################################
|
2
|
-
# Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# This file is part of Viewpoint.
|
6
|
-
#
|
7
|
-
# Viewpoint is free software: you can redistribute it and/or
|
8
|
-
# modify it under the terms of the GNU General Public License as published
|
9
|
-
# by the Free Software Foundation, either version 3 of the License, or (at
|
10
|
-
# your option) any later version.
|
11
|
-
#
|
12
|
-
# Viewpoint is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
15
|
-
# Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License along
|
18
|
-
# with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
#############################################################################
|
20
|
-
|
21
|
-
module Viewpoint
|
22
|
-
module EWS
|
23
|
-
class MeetingRequest < Item
|
24
|
-
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def init_methods
|
29
|
-
super()
|
30
|
-
define_str_var :conversation_index, :conversation_topic, :internet_message_id, :references
|
31
|
-
define_mbox_users :to_recipients, :cc_recipients, :bcc_recipients, :reply_to, :required_attendees, :optional_attendees
|
32
|
-
define_mbox_user :from, :sender, :received_by, :received_representing, :organizer
|
33
|
-
define_bool_var :is_read, :is_read_receipt_requested, :is_response_requested, :is_delivery_receipt_requested, :is_draft, :is_from_me
|
34
|
-
define_bool_var :is_all_day_event, :is_cancelled, :is_delegated, :is_meeting, :is_out_of_date, :is_recurring, :is_resend
|
35
|
-
define_bool_var :is_submitted, :is_unmodified, :allow_new_time_proposal
|
36
|
-
define_int_var :adjacent_meeting_count, :appointment_sequence_number, :appointment_state, :conflicting_meeting_count
|
37
|
-
define_datetime_var :start, :end
|
38
|
-
end
|
39
|
-
end # MeetingRequest
|
40
|
-
end # EWS
|
41
|
-
end # Viewpoint
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#############################################################################
|
2
|
-
# Copyright © 2010 Dan Wanek <dan.wanek@gmail.com>
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# This file is part of Viewpoint.
|
6
|
-
#
|
7
|
-
# Viewpoint is free software: you can redistribute it and/or
|
8
|
-
# modify it under the terms of the GNU General Public License as published
|
9
|
-
# by the Free Software Foundation, either version 3 of the License, or (at
|
10
|
-
# your option) any later version.
|
11
|
-
#
|
12
|
-
# Viewpoint is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
15
|
-
# Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License along
|
18
|
-
# with Viewpoint. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
#############################################################################
|
20
|
-
|
21
|
-
module Viewpoint
|
22
|
-
module EWS
|
23
|
-
class MeetingResponse < Item
|
24
|
-
end # MeetingResponse
|
25
|
-
end # EWS
|
26
|
-
end # Viewpoint
|