Class: Viewpoint::EWS::SOAP::EwsBuilder

Inherits:
Object
  • Object
show all
Includes:
EwsBuildHelpers
Defined in:
lib/soap/handsoap/builders/ews_builder.rb

Overview

This class includes all the build helpers and also contains some root level methods to help code reuse. The CreateItem operation is an example of this because the different item types share a lot but have a few subtle differences.

Instance Method Summary collapse

Methods included from EwsBuildHelpers

#add_hierarchy!, #attachment_ids!, #attachment_shape!, #attachments!, #calendar_item!, #contact_item!, #delegate_users!, #event_types!, #folder_id!, #folder_ids!, #folder_shape!, #item!, #item_changes!, #item_id!, #item_ids!, #item_shape!, #items!, #mailbox!, #message_item!, #parent_folder_ids!, #saved_item_folder_id!, #subscription_id!, #sync_state!, #task_item!, #to_folder_id!, #user_id!, #watermark!

Constructor Details

#initialize(node, opts, &block) ⇒ EwsBuilder

Returns a new instance of EwsBuilder.



31
32
33
34
# File 'lib/soap/handsoap/builders/ews_builder.rb', line 31

def initialize(node, opts, &block)
  @node, @opts = node, opts
  instance_eval(&block) if block_given?
end

Instance Method Details

#add_delegate!(owner, delegate, permissions) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/soap/handsoap/builders/ews_builder.rb', line 66

def add_delegate!(owner, delegate, permissions)
  d_user = {
    :user_id => {:primary_smtp_address => {:text => delegate}},
    :delegate_permissions => permissions
  }
  
  mailbox!(@node, {:email_address => {:text => owner}})
  delegate_users!(@node, [d_user])
end

#create_item!(folder_id, items, message_disposition, send_invites, type) ⇒ Object

TODO:

Fix max_changes_returned to be more flexible

Parameters:

  • type (String)

    The type of items in the items array message/calendar



58
59
60
61
62
63
64
# File 'lib/soap/handsoap/builders/ews_builder.rb', line 58

def create_item!(folder_id, items, message_disposition, send_invites, type)
  @node.set_attr('MessageDisposition', message_disposition) if message_disposition
  @node.set_attr('SendMeetingInvitations', send_invites) if send_invites

  saved_item_folder_id!(@node, folder_id) unless folder_id.nil?
  items!(@node, items, type)
end

#pull_subscription_request!(folder_ids, event_types, timeout) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/soap/handsoap/builders/ews_builder.rb', line 37

def pull_subscription_request!(folder_ids, event_types, timeout)
  @node.add("#{NS_EWS_MESSAGES}:PullSubscriptionRequest") do |ps|
    folder_ids!(ps, folder_ids, nil, "#{NS_EWS_TYPES}:FolderIds")
    event_types!(ps, event_types)
    ps.add("#{NS_EWS_TYPES}:Timeout", timeout)
  end
end

#push_subscription_request!(folder_ids, event_types, url, watermark = nil, status_frequency = 5) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/soap/handsoap/builders/ews_builder.rb', line 46

def push_subscription_request!(folder_ids, event_types, url, watermark=nil, status_frequency=5)
  @node.add("#{NS_EWS_MESSAGES}:PushSubscriptionRequest") do |ps|
    folder_ids!(ps, folder_ids, nil, "#{NS_EWS_TYPES}:FolderIds")
    event_types!(ps, event_types)
    ps.add("#{NS_EWS_TYPES}:Watermark", watermark) unless watermark.nil?
    ps.add("#{NS_EWS_TYPES}:StatusFrequency", status_frequency)
    ps.add("#{NS_EWS_TYPES}:URL", url)
  end
end

#query_strings!(query_strings) ⇒ Object

This is forthcoming in Exchange 2010. It will replace much of the Restriction based code.

Parameters:

  • An (Array)

    array of query strings

See Also:



87
88
89
90
91
# File 'lib/soap/handsoap/builders/ews_builder.rb', line 87

def query_strings!(query_strings)
  query_strings.each do |qs|
    @node.add("#{NS_EWS_MESSAGES}:QueryString", qs)
  end
end

#remove_delegate!(owner, delegate) ⇒ Object



76
77
78
79
80
81
# File 'lib/soap/handsoap/builders/ews_builder.rb', line 76

def remove_delegate!(owner, delegate)
  mailbox!(@node, {:email_address => {:text => owner}})
  @node.add("#{NS_EWS_MESSAGES}:UserIds") do |uids|
    user_id!(uids, {:user_id => {:primary_smtp_address => {:text => delegate}}})
  end
end