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

Inherits:
Object
  • Object
show all
Includes:
Viewpoint::EWS, StringUtils
Defined in:
lib/ews/soap/builders/ews_builder.rb

Overview

This class includes the element builders. The idea is that each element should know how to build themselves so each parent element can delegate creation of subelements to a method of the same name with a ‘!’ after it.

Constant Summary

Constants included from StringUtils

StringUtils::DURATION_RE

Constants included from Viewpoint::EWS

ConnectingSID

Instance Attribute Summary collapse

Attributes included from Viewpoint::EWS

#logger

Instance Method Summary collapse

Methods included from StringUtils

included

Methods included from Viewpoint::EWS

#remove_impersonation, root_logger, #set_impersonation

Constructor Details

#initializeEwsBuilder

Returns a new instance of EwsBuilder.



28
29
30
# File 'lib/ews/soap/builders/ews_builder.rb', line 28

def initialize
  @nbuild = Nokogiri::XML::Builder.new
end

Instance Attribute Details

#nbuildObject (readonly)

Returns the value of attribute nbuild.



27
28
29
# File 'lib/ews/soap/builders/ews_builder.rb', line 27

def nbuild
  @nbuild
end

Instance Method Details

#additional_properties!(addprops) ⇒ Object

Build the AdditionalProperties element



346
347
348
349
350
351
352
# File 'lib/ews/soap/builders/ews_builder.rb', line 346

def additional_properties!(addprops)
  @nbuild[NS_EWS_TYPES].AdditionalProperties {
    addprops.each_pair {|k,v|
      dispatch_field_uri!({k => v}, NS_EWS_TYPES)
    }
  }
end

#address!(email) ⇒ Object



378
379
380
# File 'lib/ews/soap/builders/ews_builder.rb', line 378

def address!(email)
  nbuild[NS_EWS_TYPES].Address(email)
end

#and_or(type, expr) ⇒ Object



543
544
545
546
547
548
549
550
# File 'lib/ews/soap/builders/ews_builder.rb', line 543

def and_or(type, expr)
  @nbuild[NS_EWS_TYPES].send(type) {
    expr.each do |e|
      type = e.keys.first
      self.send normalize_type(type), e[type]
    end
  }
end

#and_r(expr) ⇒ Object



535
536
537
# File 'lib/ews/soap/builders/ews_builder.rb', line 535

def and_r(expr)
  and_or('And', expr)
end

#append_to_item_field!(upd) ⇒ Object



1014
1015
1016
1017
1018
1019
1020
1021
1022
# File 'lib/ews/soap/builders/ews_builder.rb', line 1014

def append_to_item_field!(upd)
  uri = upd.select {|k,v| k =~ /_uri/i}
  raise EwsBadArgumentError, "Bad argument given for AppendToItemField." if uri.keys.length != 1
  upd.delete(uri.keys.first)
  @nbuild.AppendToItemField {
    dispatch_field_uri!(uri)
    dispatch_field_item!(upd)
  }
end

#attachment_id!(aid) ⇒ Object

Build the AttachmentId element



1087
1088
1089
1090
# File 'lib/ews/soap/builders/ews_builder.rb', line 1087

def attachment_id!(aid)
  attribs = {'Id' => aid}
  @nbuild[NS_EWS_TYPES].AttachmentId(attribs)
end

#attachment_ids!(aids) ⇒ Object

Build the AttachmentIds element



1076
1077
1078
1079
1080
1081
1082
1083
# File 'lib/ews/soap/builders/ews_builder.rb', line 1076

def attachment_ids!(aids)
  @nbuild.AttachmentIds {
    @nbuild.parent.default_namespace = @default_ns
    aids.each do |aid|
      attachment_id!(aid)
    end
  }
end

#attendee!(a) ⇒ Object



937
938
939
940
941
# File 'lib/ews/soap/builders/ews_builder.rb', line 937

def attendee!(a)
  nbuild[NS_EWS_TYPES].Attendee {
    mailbox!(a[:mailbox])
  }
end

#base_shape!(base_shape) ⇒ Object

Build the BaseShape element



154
155
156
# File 'lib/ews/soap/builders/ews_builder.rb', line 154

def base_shape!(base_shape)
  @nbuild[NS_EWS_TYPES].BaseShape(camel_case(base_shape))
end

#bcc_recipients!(r) ⇒ Object



906
907
908
909
910
# File 'lib/ews/soap/builders/ews_builder.rb', line 906

def bcc_recipients!(r)
  nbuild[NS_EWS_TYPES].BccRecipients {
    r.each {|mbox| mailbox!(mbox[:mailbox]) }
  }
end

#bitmask(expr) ⇒ Object



586
587
588
# File 'lib/ews/soap/builders/ews_builder.rb', line 586

def bitmask(expr)
  @nbuild[NS_EWS_TYPES].Bitmask('Value' => expr[:value])
end

#body!(b) ⇒ Object



880
881
882
883
884
# File 'lib/ews/soap/builders/ews_builder.rb', line 880

def body!(b)
  nbuild[NS_EWS_TYPES].Body(b[:text]) {|x|
    x.parent['BodyType'] = b[:body_type] if b[:body_type]
  }
end

#body_type!(body_type) ⇒ Object



162
163
164
165
166
167
168
169
170
# File 'lib/ews/soap/builders/ews_builder.rb', line 162

def body_type!(body_type)
  body_type = body_type.to_s
  if body_type =~ /html/i
    body_type = body_type.upcase
  else
    body_type = body_type.downcase.capitalize
  end
  nbuild[NS_EWS_TYPES].BodyType(body_type)
end

#build!(opts = {}, &block) ⇒ Object

Build the SOAP envelope and yield this object so subelements can be built. Once you have the EwsBuilder object you can use the nbuild object like shown in the example for the Header section. The nbuild object is the underlying Nokogiri::XML::Builder object.

Examples:

xb = EwsBuilder.new
xb.build! do |part, b|
  if(part == :header)
    b.nbuild.MyVar('blablabla')
  else
    b.folder_shape!({:base_shape => 'Default'})
  end
end

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :server_version (String)

    The version string that should get set in the Header. See ExchangeWebService#initialize

  • :time_zone_context (Hash)

    TimeZoneDefinition. Format: {id: time_zone_identifier}



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ews/soap/builders/ews_builder.rb', line 49

def build!(opts = {}, &block)
  @nbuild.Envelope(NAMESPACES) do |node|
    node.parent.namespace = parent_namespace(node)
    node.Header {
      set_version_header! opts[:server_version]
      set_impersonation! opts[:impersonation_type], opts[:impersonation_mail]
      set_time_zone_context_header! opts[:time_zone_context]
      yield(:header, self) if block_given?
    }
    node.Body {
      yield(:body, self) if block_given?
    }
  end
  @nbuild.doc
end

#build_xml!(elems) ⇒ Object

Build XML from a passed in Hash or Array in a specified format.

Parameters:

  • elems (Array, Hash)

    The elements to add to the Builder. They must be specified like so:

    {:top =>

    { :xmlns => 'http://stonesthrow/soap',
      :sub_elements => [
        {:elem1 => {:text => 'inside'}},
        => {:text => 'inside2'}
      ],
      :id => '3232', :tx_dd => 23, :asdf => 'turkey'
    }
    

    } or [ {:first => {:text => ‘hello’}},

    => {:text => 'world'}
    

    ]

    NOTE: there are specialized keys for text (:text), child elements (:sub_elements) and namespaces (:xmlns).



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/ews/soap/builders/ews_builder.rb', line 85

def build_xml!(elems)
  case elems.class.name
  when 'Hash'
    keys = elems.keys
    vals = elems.values
    if(keys.length > 1 && !vals.is_a?(Hash))
      raise "invalid input: #{elems}"
    end
    vals = vals.first.clone
    se = vals.delete(:sub_elements)
    txt = vals.delete(:text)
    xmlns_attribute = vals.delete(:xmlns_attribute)

    node = @nbuild.send(camel_case(keys.first), txt, vals) {|x|
      build_xml!(se) if se
    }

    # Set node level namespace
    node.xmlns = NAMESPACES["xmlns:#{xmlns_attribute}"] if xmlns_attribute
  when 'Array'
    elems.each do |e|
      build_xml!(e)
    end
  else
    raise "Unsupported type: #{elems.class.name}"
  end
end

#calendar_folder!(folder) ⇒ Object



324
325
326
# File 'lib/ews/soap/builders/ews_builder.rb', line 324

def calendar_folder!(folder)
  folder! folder, :CalendarFolder
end

#calendar_item!(item) ⇒ Object



825
826
827
828
829
830
831
# File 'lib/ews/soap/builders/ews_builder.rb', line 825

def calendar_item!(item)
  nbuild[NS_EWS_TYPES].CalendarItem {
    item.each_pair {|k,v|
      self.send("#{k}!", v)
    }
  }
end

#calendar_view!(cal_view) ⇒ Object

Build the CalendarView element



695
696
697
698
699
# File 'lib/ews/soap/builders/ews_builder.rb', line 695

def calendar_view!(cal_view)
  attribs = {}
  cal_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
  @nbuild[NS_EWS_MESSAGES].CalendarView(attribs)
end

#cc_recipients!(r) ⇒ Object



900
901
902
903
904
# File 'lib/ews/soap/builders/ews_builder.rb', line 900

def cc_recipients!(r)
  nbuild[NS_EWS_TYPES].CcRecipients {
    r.each {|mbox| mailbox!(mbox[:mailbox]) }
  }
end

#constant(expr) ⇒ Object



690
691
692
# File 'lib/ews/soap/builders/ews_builder.rb', line 690

def constant(expr)
  nbuild[NS_EWS_TYPES].Constant('Value' => expr[:value])
end

#contacts_folder!(folder) ⇒ Object



328
329
330
# File 'lib/ews/soap/builders/ews_builder.rb', line 328

def contacts_folder!(folder)
  folder! folder, :ContactsFolder
end

#contacts_view!(con_view) ⇒ Object

Build the ContactsView element



702
703
704
705
706
# File 'lib/ews/soap/builders/ews_builder.rb', line 702

def contacts_view!(con_view)
  attribs = {}
  con_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
  @nbuild[NS_EWS_MESSAGES].ContactsView(attribs)
end

#contains(expr) ⇒ Object



559
560
561
562
563
564
565
566
567
568
# File 'lib/ews/soap/builders/ews_builder.rb', line 559

def contains(expr)
  @nbuild[NS_EWS_TYPES].Contains(
    'ContainmentMode' => expr.delete(:containment_mode),
    'ContainmentComparison' => expr.delete(:containment_comparison)) {
    c = expr.delete(:constant) # remove constant 1st for ordering
    type = expr.keys.first
    self.send(type, expr[type])
    constant(c)
  }
end

#delete_item_field!(upd) ⇒ Object



1036
1037
1038
1039
1040
1041
1042
# File 'lib/ews/soap/builders/ews_builder.rb', line 1036

def delete_item_field!(upd)
  uri = upd.select {|k,v| k =~ /_uri/i}
  raise EwsBadArgumentError, "Bad argument given for SetItemField." if uri.keys.length != 1
  @nbuild[NS_EWS_TYPES].DeleteItemField {
    dispatch_field_uri!(uri, NS_EWS_TYPES)
  }
end

#dispatch_field_item!(item, ns_prefix = nil) ⇒ Object

Insert item, enforce xmlns attribute if prefix is present



1190
1191
1192
1193
# File 'lib/ews/soap/builders/ews_builder.rb', line 1190

def dispatch_field_item!(item, ns_prefix = nil)
  item.values.first[:xmlns_attribute] = ns_prefix if ns_prefix
  build_xml!(item)
end

#dispatch_field_uri!(uri, ns = NS_EWS_MESSAGES) ⇒ Object

TODO:

Implement ExtendedFieldURI

A helper to dispatch to a FieldURI, IndexedFieldURI, or an ExtendedFieldURI



1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
# File 'lib/ews/soap/builders/ews_builder.rb', line 1157

def dispatch_field_uri!(uri, ns=NS_EWS_MESSAGES)
  type = uri.keys.first
  vals = uri[type].is_a?(Array) ? uri[type] : [uri[type]]
  case type
  when :field_uRI, :field_uri
    vals.each do |val|
      value = val.is_a?(Hash) ? val[type] : val
      nbuild[ns].FieldURI('FieldURI' => value)
    end
  when :indexed_field_uRI, :indexed_field_uri
    vals.each do |val|
      nbuild[ns].IndexedFieldURI(
        'FieldURI'   => (val[:field_uRI] || val[:field_uri]),
        'FieldIndex' => val[:field_index]
      )
    end
  when :extended_field_uRI, :extended_field_uri
    vals.each do |val|
      nbuild[ns].ExtendedFieldURI {
        nbuild.parent['DistinguishedPropertySetId'] = val[:distinguished_property_set_id] if val[:distinguished_property_set_id]
        nbuild.parent['PropertySetId'] = val[:property_set_id] if val[:property_set_id]
        nbuild.parent['PropertyTag'] = val[:property_tag] if val[:property_tag]
        nbuild.parent['PropertyName'] = val[:property_name] if val[:property_name]
        nbuild.parent['PropertyId'] = val[:property_id] if val[:property_id]
        nbuild.parent['PropertyType'] = val[:property_type] if val[:property_type]
      }
    end
  else
    raise EwsBadArgumentError, "Bad URI type. #{type}"
  end
end

#dispatch_folder_id!(fid) ⇒ Object

A helper method to dispatch to a FolderId or DistinguishedFolderId correctly

Parameters:

  • fid (Hash)

    A folder_id Ex: => myid, :change_key => ck



1109
1110
1111
1112
1113
1114
1115
1116
1117
# File 'lib/ews/soap/builders/ews_builder.rb', line 1109

def dispatch_folder_id!(fid)
  if(fid[:id].is_a?(String))
    folder_id!(fid[:id], fid[:change_key])
  elsif(fid[:id].is_a?(Symbol))
    distinguished_folder_id!(fid[:id], fid[:change_key], fid[:act_as])
  else
    raise EwsBadArgumentError, "Bad argument given for a FolderId. #{fid[:id].class}"
  end
end

#dispatch_item_id!(iid) ⇒ Object

A helper method to dispatch to an ItemId, OccurrenceItemId, or a RecurringMasterItemId

Parameters:

  • iid (Hash)

    The item id of some type



1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
# File 'lib/ews/soap/builders/ews_builder.rb', line 1121

def dispatch_item_id!(iid)
  type = iid.keys.first
  item = iid[type]
  case type
  when :item_id
    item_id!(item)
  when :occurrence_item_id
    occurrence_item_id!(
      item[:recurring_master_id], item[:change_key], item[:instance_index])
  when :recurring_master_item_id
    recurring_master_item_id!(item[:occurrence_id], item[:change_key])
  else
    raise EwsBadArgumentError, "Bad ItemId type. #{type}"
  end
end

#dispatch_update_type!(update) ⇒ Object

A helper method to dispatch to a AppendToItemField, SetItemField, or

DeleteItemField

Parameters:

  • update (Hash)

    An update of some type



1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
# File 'lib/ews/soap/builders/ews_builder.rb', line 1140

def dispatch_update_type!(update)
  type = update.keys.first
  upd  = update[type]
  case type
  when :append_to_item_field
    append_to_item_field!(upd)
  when :set_item_field
    set_item_field!(upd)
  when :delete_item_field
    delete_item_field!(upd)
  else
    raise EwsBadArgumentError, "Bad Update type. #{type}"
  end
end

#display_name!(name) ⇒ Object



340
341
342
# File 'lib/ews/soap/builders/ews_builder.rb', line 340

def display_name!(name)
  nbuild[NS_EWS_TYPES].DisplayName(name)
end

#distinguished_folder_id!(dfid, change_key = nil, act_as = nil) ⇒ Object

TODO:

add support for the Mailbox child object

Build the DistinguishedFolderId element



213
214
215
216
217
218
219
220
221
# File 'lib/ews/soap/builders/ews_builder.rb', line 213

def distinguished_folder_id!(dfid, change_key = nil, act_as = nil)
  attribs = {'Id' => dfid.to_s}
  attribs['ChangeKey'] = change_key if change_key
  @nbuild[NS_EWS_TYPES].DistinguishedFolderId(attribs) {
    if ! act_as.nil?
      mailbox!({:email_address => act_as})
    end
  }
end

#due_date!(dd) ⇒ Object



955
956
957
# File 'lib/ews/soap/builders/ews_builder.rb', line 955

def due_date!(dd)
  nbuild[NS_EWS_TYPES].DueDate format_time(dd[:text])
end

#duration!(opts) ⇒ Object



405
406
407
408
409
410
# File 'lib/ews/soap/builders/ews_builder.rb', line 405

def duration!(opts)
  nbuild.Duration {
    nbuild.StartTime(format_time opts[:start_time])
    nbuild.EndTime(format_time opts[:end_time])
  }
end

#email_address!(email) ⇒ Object



374
375
376
# File 'lib/ews/soap/builders/ews_builder.rb', line 374

def email_address!(email)
  nbuild[NS_EWS_TYPES].EmailAddress(email)
end

#end!(et) ⇒ Object



947
948
949
# File 'lib/ews/soap/builders/ews_builder.rb', line 947

def end!(et)
  nbuild[NS_EWS_TYPES].End(et[:text])
end

#end_time_zone!(zone) ⇒ Object

TODO:

Implement sub elements Periods, TransitionsGroups and Transitions to override zone

Specifies an optional time zone for the end time

Parameters:

  • attributes (Hash)

See Also:



508
509
510
511
512
513
# File 'lib/ews/soap/builders/ews_builder.rb', line 508

def end_time_zone!(zone)
  attributes = {}
  attributes['Id'] = zone[:id] if zone[:id]
  attributes['Name'] = zone[:name] if zone[:name]
  nbuild[NS_EWS_TYPES].EndTimeZone(attributes)
end

#event_types!(evtypes) ⇒ Object



709
710
711
712
713
714
715
# File 'lib/ews/soap/builders/ews_builder.rb', line 709

def event_types!(evtypes)
  @nbuild[NS_EWS_TYPES].EventTypes {
    evtypes.each do |et|
      @nbuild[NS_EWS_TYPES].EventType(camel_case(et))
    end
  }
end

#ews_types_builderObject



624
625
626
# File 'lib/ews/soap/builders/ews_builder.rb', line 624

def ews_types_builder
  nbuild[NS_EWS_TYPES]
end

#excludes(expr) ⇒ Object



570
571
572
573
574
575
576
577
# File 'lib/ews/soap/builders/ews_builder.rb', line 570

def excludes(expr)
  @nbuild[NS_EWS_TYPES].Excludes {
    b = expr.delete(:bitmask) # remove bitmask 1st for ordering
    type = expr.keys.first
    self.send(type, expr[type])
    bitmask(b)
  }
end

#exists(expr) ⇒ Object



579
580
581
582
583
584
# File 'lib/ews/soap/builders/ews_builder.rb', line 579

def exists(expr)
  @nbuild[NS_EWS_TYPES].Exists {
    type = expr.keys.first
    self.send(type, expr[type])
  }
end

#export_item_ids!(item_ids) ⇒ Object



256
257
258
259
260
261
262
263
264
265
# File 'lib/ews/soap/builders/ews_builder.rb', line 256

def export_item_ids!(item_ids)
  ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES
  @nbuild[ns].ExportItems{
    @nbuild.ItemIds {
      item_ids.each do |iid|
        dispatch_item_id!(iid)
      end
    }
  }
end

#extended_field_uRI(expr) ⇒ Object Also known as: extended_field_uri



644
645
646
647
648
649
650
651
652
653
# File 'lib/ews/soap/builders/ews_builder.rb', line 644

def extended_field_uRI(expr)
  nbuild[NS_EWS_TYPES].ExtendedFieldURI {
    nbuild.parent['DistinguishedPropertySetId'] = expr[:distinguished_property_set_id] if expr[:distinguished_property_set_id]
    nbuild.parent['PropertySetId'] = expr[:property_set_id] if expr[:property_set_id]
    nbuild.parent['PropertyTag'] = expr[:property_tag] if expr[:property_tag]
    nbuild.parent['PropertyName'] = expr[:property_name] if expr[:property_name]
    nbuild.parent['PropertyId'] = expr[:property_id] if expr[:property_id]
    nbuild.parent['PropertyType'] = expr[:property_type] if expr[:property_type]
  }
end

#extended_properties!(eprops) ⇒ Object



657
658
659
# File 'lib/ews/soap/builders/ews_builder.rb', line 657

def extended_properties!(eprops)
  eprops.each {|ep| extended_property!(ep)}
end

#extended_property!(eprop) ⇒ Object



661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
# File 'lib/ews/soap/builders/ews_builder.rb', line 661

def extended_property!(eprop)
  nbuild[NS_EWS_TYPES].ExtendedProperty {
    key = eprop.keys.grep(/extended/i).first
    dispatch_field_uri!({key => eprop[key]}, NS_EWS_TYPES)
    if eprop[:values]
      nbuild.Values {
        eprop[:values].each do |v|
            value! v
        end
      }
    elsif eprop[:value]
      value! eprop[:value]
    end
  }
end

#field_uRI(expr) ⇒ Object Also known as: field_uri



628
629
630
631
# File 'lib/ews/soap/builders/ews_builder.rb', line 628

def field_uRI(expr)
  value = expr.is_a?(Hash) ? (expr[:field_uRI] || expr[:field_uri]) : expr
  ews_types_builder.FieldURI('FieldURI' => value)
end

#field_uRI_or_constant(expr) ⇒ Object Also known as: field_uri_or_constant



681
682
683
684
685
686
# File 'lib/ews/soap/builders/ews_builder.rb', line 681

def field_uRI_or_constant(expr)
  nbuild[NS_EWS_TYPES].FieldURIOrConstant {
    type = expr.keys.first
    self.send(type, expr[type])
  }
end

#file_attachment!(fa) ⇒ Object



1058
1059
1060
1061
1062
1063
# File 'lib/ews/soap/builders/ews_builder.rb', line 1058

def file_attachment!(fa)
  @nbuild[NS_EWS_TYPES].FileAttachment {
    @nbuild[NS_EWS_TYPES].Name(fa.name)
    @nbuild[NS_EWS_TYPES].Content(fa.content)
  }
end

#folder!(folder, type = :Folder) ⇒ Object



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/ews/soap/builders/ews_builder.rb', line 308

def folder!(folder, type = :Folder)
  nbuild[NS_EWS_TYPES].send(type) {|x|
    folder.each_pair do |e,v|
      ftype = "#{e}!".to_sym
      if e == :folder_id
        dispatch_folder_id!(v)
      elsif self.respond_to?(ftype)
        self.send ftype, v
      else
        raise Viewpoint::EWS::EwsNotImplemented,
          "#{ftype} not implemented as a builder."
      end
    end
  }
end

#folder_id!(fid, change_key = nil) ⇒ Object

Build the FolderId element



225
226
227
228
229
# File 'lib/ews/soap/builders/ews_builder.rb', line 225

def folder_id!(fid, change_key = nil)
  attribs = {'Id' => fid}
  attribs['ChangeKey'] = change_key if change_key
  @nbuild[NS_EWS_TYPES].FolderId(attribs)
end

#folder_ids!(fids, act_as = nil) ⇒ Object

Build the FolderIds element



192
193
194
195
196
197
198
199
200
# File 'lib/ews/soap/builders/ews_builder.rb', line 192

def folder_ids!(fids, act_as=nil)
  ns = @nbuild.parent.name.match(/subscription/i) ? NS_EWS_TYPES : NS_EWS_MESSAGES
  @nbuild[ns].FolderIds {
    fids.each do |fid|
      fid[:act_as] = act_as if act_as != nil
      dispatch_folder_id!(fid)
    end
  }
end

#folder_shape!(folder_shape) ⇒ Object

TODO:

need fully support all options

Build the FolderShape element

Parameters:

  • folder_shape (Hash)

    The folder shape structure to build from

See Also:



117
118
119
120
121
122
123
124
125
# File 'lib/ews/soap/builders/ews_builder.rb', line 117

def folder_shape!(folder_shape)
  @nbuild.FolderShape {
    @nbuild.parent.default_namespace = @default_ns
    base_shape!(folder_shape[:base_shape])
    if(folder_shape[:additional_properties])
      additional_properties!(folder_shape[:additional_properties])
    end
  }
end

#folders!(folders) ⇒ Object



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/ews/soap/builders/ews_builder.rb', line 292

def folders!(folders)
  @nbuild.Folders {|x|
    folders.each do |fold|
      fold.each_pair do |ftype, vars| # convenience, should only be one pair
        ftype = "#{ftype}!".to_sym
        if self.respond_to? ftype
          self.send ftype, vars
        else
          raise Viewpoint::EWS::EwsNotImplemented,
            "#{ftype} not implemented as a builder."
        end
      end
    end
  }
end

#forward_item!(item) ⇒ Object



841
842
843
844
845
846
847
# File 'lib/ews/soap/builders/ews_builder.rb', line 841

def forward_item!(item)
  nbuild[NS_EWS_TYPES].ForwardItem {
    item.each_pair {|k,v|
      self.send("#{k}!", v)
    }
  }
end

#free_busy_view_options!(opts) ⇒ Object



424
425
426
427
428
429
430
431
432
# File 'lib/ews/soap/builders/ews_builder.rb', line 424

def free_busy_view_options!(opts)
  nbuild[NS_EWS_TYPES].FreeBusyViewOptions {
    nbuild[NS_EWS_TYPES].TimeWindow {
      nbuild[NS_EWS_TYPES].StartTime(format_time opts[:time_window][:start_time])
      nbuild[NS_EWS_TYPES].EndTime(format_time opts[:time_window][:end_time])
    }
    nbuild[NS_EWS_TYPES].RequestedView(camel_case(opts[:requested_view][:requested_free_busy_view]))
  }
end

#from!(f) ⇒ Object



912
913
914
915
916
# File 'lib/ews/soap/builders/ews_builder.rb', line 912

def from!(f)
  nbuild[NS_EWS_TYPES].From {
    mailbox! f
  }
end

#get_server_time_zones!(get_time_zone_options) ⇒ Object

Request all known time_zones from server



477
478
479
480
481
482
483
484
485
486
487
# File 'lib/ews/soap/builders/ews_builder.rb', line 477

def get_server_time_zones!(get_time_zone_options)
  nbuild[NS_EWS_MESSAGES].GetServerTimeZones('ReturnFullTimeZoneData' => get_time_zone_options[:full]) do
    if get_time_zone_options[:ids] && get_time_zone_options[:ids].any?
      nbuild[NS_EWS_MESSAGES].Ids do
        get_time_zone_options[:ids].each do |id|
          nbuild[NS_EWS_TYPES].Id id
        end
      end
    end
  end
end

#ignore!(item_ids) ⇒ Object



780
781
782
783
784
785
786
# File 'lib/ews/soap/builders/ews_builder.rb', line 780

def ignore!(item_ids)
  @nbuild.Ignore {
    item_ids.each do |iid|
      item_id!(iid)
    end
  }
end

#importance!(sub) ⇒ Object



876
877
878
# File 'lib/ews/soap/builders/ews_builder.rb', line 876

def importance!(sub)
  nbuild[NS_EWS_TYPES].Importance(sub)
end

#indexed_field_uRI(expr) ⇒ Object Also known as: indexed_field_uri



635
636
637
638
639
640
# File 'lib/ews/soap/builders/ews_builder.rb', line 635

def indexed_field_uRI(expr)
  nbuild[NS_EWS_TYPES].IndexedFieldURI(
    'FieldURI'    => (expr[:field_uRI] || expr[:field_uri]),
    'FieldIndex'  => expr[:field_index]
  )
end

#indexed_page_item_view!(indexed_page_item_view) ⇒ Object

TODO:

needs peer check

Build the IndexedPageItemView element



146
147
148
149
150
# File 'lib/ews/soap/builders/ews_builder.rb', line 146

def indexed_page_item_view!(indexed_page_item_view)
  attribs = {}
  indexed_page_item_view.each_pair {|k,v| attribs[camel_case(k)] = v.to_s}
  @nbuild[NS_EWS_MESSAGES].IndexedPageItemView(attribs)
end

#inline_attachment!(fa) ⇒ Object



1049
1050
1051
1052
1053
1054
1055
1056
# File 'lib/ews/soap/builders/ews_builder.rb', line 1049

def inline_attachment!(fa)
  @nbuild[NS_EWS_TYPES].FileAttachment {
    @nbuild[NS_EWS_TYPES].Name(fa.name)
    @nbuild[NS_EWS_TYPES].ContentId(fa.name)
    @nbuild[NS_EWS_TYPES].IsInline(true)
    @nbuild[NS_EWS_TYPES].Content(fa.content)
  }
end

#is_all_day_event!(all_day) ⇒ Object



963
964
965
# File 'lib/ews/soap/builders/ews_builder.rb', line 963

def is_all_day_event!(all_day)
  nbuild[NS_EWS_TYPES].IsAllDayEvent(all_day)
end

#is_equal_to(expr) ⇒ Object



590
591
592
# File 'lib/ews/soap/builders/ews_builder.rb', line 590

def is_equal_to(expr)
  restriction_compare('IsEqualTo',expr)
end

#is_greater_than(expr) ⇒ Object



594
595
596
# File 'lib/ews/soap/builders/ews_builder.rb', line 594

def is_greater_than(expr)
  restriction_compare('IsGreaterThan',expr)
end

#is_greater_than_or_equal_to(expr) ⇒ Object



598
599
600
# File 'lib/ews/soap/builders/ews_builder.rb', line 598

def is_greater_than_or_equal_to(expr)
  restriction_compare('IsGreaterThanOrEqualTo',expr)
end

#is_less_than(expr) ⇒ Object



602
603
604
# File 'lib/ews/soap/builders/ews_builder.rb', line 602

def is_less_than(expr)
  restriction_compare('IsLessThan',expr)
end

#is_less_than_or_equal_to(expr) ⇒ Object



606
607
608
# File 'lib/ews/soap/builders/ews_builder.rb', line 606

def is_less_than_or_equal_to(expr)
  restriction_compare('IsLessThanOrEqualTo',expr)
end

#is_not_equal_to(expr) ⇒ Object



610
611
612
# File 'lib/ews/soap/builders/ews_builder.rb', line 610

def is_not_equal_to(expr)
  restriction_compare('IsNotEqualTo',expr)
end

#item!(item) ⇒ Object



806
807
808
809
810
811
812
# File 'lib/ews/soap/builders/ews_builder.rb', line 806

def item!(item)
  nbuild.Item {
    item.each_pair {|k,v|
      self.send("#{k}!", v)
    }
  }
end

#item_attachment!(ia) ⇒ Object



1065
1066
1067
1068
1069
1070
1071
1072
# File 'lib/ews/soap/builders/ews_builder.rb', line 1065

def item_attachment!(ia)
  @nbuild[NS_EWS_TYPES].ItemAttachment {
    @nbuild[NS_EWS_TYPES].Name(ia.name)
    @nbuild[NS_EWS_TYPES].Item {
      item_id!(ia.item)
    }
  }
end

#item_change!(change) ⇒ Object



996
997
998
999
1000
1001
1002
# File 'lib/ews/soap/builders/ews_builder.rb', line 996

def item_change!(change)
  @nbuild[NS_EWS_TYPES].ItemChange {
    updates = change.delete(:updates) # Remove updates so dispatch_item_id works correctly
    dispatch_item_id!(change)
    updates!(updates)
  }
end

#item_changes!(changes) ⇒ Object



987
988
989
990
991
992
993
# File 'lib/ews/soap/builders/ews_builder.rb', line 987

def item_changes!(changes)
  nbuild.ItemChanges {
    changes.each do |chg|
      item_change!(chg)
    end
  }
end

#item_id!(id) ⇒ Object



248
249
250
251
252
253
# File 'lib/ews/soap/builders/ews_builder.rb', line 248

def item_id!(id)
  nbuild[NS_EWS_TYPES].ItemId {|x|
    x.parent['Id'] = id[:id]
    x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
  }
end

#item_ids!(item_ids) ⇒ Object



232
233
234
235
236
237
238
# File 'lib/ews/soap/builders/ews_builder.rb', line 232

def item_ids!(item_ids)
  @nbuild.ItemIds {
    item_ids.each do |iid|
      dispatch_item_id!(iid)
    end
  }
end

#item_shape!(item_shape) ⇒ Object

TODO:

need fully support all options

Build the ItemShape element

Parameters:

  • item_shape (Hash)

    The item shape structure to build from

See Also:



131
132
133
134
135
136
137
138
139
140
141
# File 'lib/ews/soap/builders/ews_builder.rb', line 131

def item_shape!(item_shape)
  @nbuild[NS_EWS_MESSAGES].ItemShape {
    @nbuild.parent.default_namespace = @default_ns
    base_shape!(item_shape[:base_shape])
    mime_content!(item_shape[:include_mime_content]) if item_shape.has_key?(:include_mime_content)
    body_type!(item_shape[:body_type]) if item_shape[:body_type]
    if(item_shape[:additional_properties])
      additional_properties!(item_shape[:additional_properties])
    end
  }
end

#legacy_free_busy_status!(state) ⇒ Object

possible values Exchange Server 2010 = [Free, Tentative, Busy, OOF, NoData]

Exchange Server 2013 = [Free, Tentative, Busy, OOF, WorkingElsewhere, NoData]


982
983
984
# File 'lib/ews/soap/builders/ews_builder.rb', line 982

def legacy_free_busy_status!(state)
  nbuild[NS_EWS_TYPES].LegacyFreeBusyStatus(state)
end

#location!(loc) ⇒ Object



959
960
961
# File 'lib/ews/soap/builders/ews_builder.rb', line 959

def location!(loc)
  nbuild[NS_EWS_TYPES].Location(loc)
end

#mailbox!(mbox) ⇒ Object

Build the Mailbox element. This element is commonly used for delegation. Typically passing an

email_address is sufficient

Parameters:

  • mailbox (Hash)

    A well-formated hash

See Also:



359
360
361
362
363
364
365
366
367
368
# File 'lib/ews/soap/builders/ews_builder.rb', line 359

def mailbox!(mbox)
  nbuild[NS_EWS_TYPES].Mailbox {
    name!(mbox[:name]) if mbox[:name]
    email_address!(mbox[:email_address]) if mbox[:email_address]
    address!(mbox[:address]) if mbox[:address] # for Availability query
    routing_type!(mbox[:routing_type]) if mbox[:routing_type]
    mailbox_type!(mbox[:mailbox_type]) if mbox[:mailbox_type]
    item_id!(mbox[:item_id]) if mbox[:item_id]
  }
end

#mailbox_data!(md) ⇒ Object



412
413
414
415
416
417
418
419
420
421
422
# File 'lib/ews/soap/builders/ews_builder.rb', line 412

def mailbox_data!(md)
  nbuild[NS_EWS_TYPES].MailboxData {
    nbuild[NS_EWS_TYPES].Email {
      mbox = md[:email]
      name!(mbox[:name]) if mbox[:name]
      address!(mbox[:address]) if mbox[:address] # for Availability query
      routing_type!(mbox[:routing_type]) if mbox[:routing_type]
    }
    nbuild[NS_EWS_TYPES].AttendeeType 'Required'
  }
end

#mailbox_type!(type) ⇒ Object



387
388
389
# File 'lib/ews/soap/builders/ews_builder.rb', line 387

def mailbox_type!(type)Standard
  nbuild[NS_EWS_TYPES].MailboxType(type)
end

#max_changes_returned!(cnum) ⇒ Object



789
790
791
# File 'lib/ews/soap/builders/ews_builder.rb', line 789

def max_changes_returned!(cnum)
  @nbuild[NS_EWS_MESSAGES].MaxChangesReturned(cnum)
end

#message!(item) ⇒ Object



814
815
816
817
818
819
820
821
822
823
# File 'lib/ews/soap/builders/ews_builder.rb', line 814

def message!(item)
  nbuild[NS_EWS_TYPES].Message {
    if item[:extended_properties]
      extended_properties! item.delete(:extended_properties)
    end
    item.each_pair {|k,v|
      self.send("#{k}!", v)
    }
  }
end

#mime_content!(include_mime_content) ⇒ Object



158
159
160
# File 'lib/ews/soap/builders/ews_builder.rb', line 158

def mime_content!(include_mime_content)
  @nbuild[NS_EWS_TYPES].IncludeMimeContent(include_mime_content.to_s.downcase)
end

#name!(name) ⇒ Object



370
371
372
# File 'lib/ews/soap/builders/ews_builder.rb', line 370

def name!(name)
  nbuild[NS_EWS_TYPES].Name(name)
end

#new_body_content!(b) ⇒ Object



886
887
888
889
890
# File 'lib/ews/soap/builders/ews_builder.rb', line 886

def new_body_content!(b)
  nbuild[NS_EWS_TYPES].NewBodyContent(b[:text]) {|x|
    x.parent['BodyType'] = b[:body_type] if b[:body_type]
  }
end

#not_r(expr) ⇒ Object



552
553
554
555
556
557
# File 'lib/ews/soap/builders/ews_builder.rb', line 552

def not_r(expr)
  @nbuild[NS_EWS_TYPES].Not {
    type = expr.keys.first
    self.send(type, expr[type])
  }
end

#occurrence_item_id!(id) ⇒ Object



268
269
270
271
272
273
274
# File 'lib/ews/soap/builders/ews_builder.rb', line 268

def occurrence_item_id!(id)
  @nbuild[NS_EWS_TYPES].OccurrenceItemId {|x|
    x.parent['RecurringMasterId'] = id[:recurring_master_id]
    x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
    x.parent['InstanceIndex'] = id[:instance_index]
  }
end

#optional_attendees!(attendees) ⇒ Object



924
925
926
927
928
# File 'lib/ews/soap/builders/ews_builder.rb', line 924

def optional_attendees!(attendees)
  nbuild[NS_EWS_TYPES].OptionalAttendees {
    attendees.each {|a| attendee!(a[:attendee])}
  }
end

#or_r(expr) ⇒ Object



539
540
541
# File 'lib/ews/soap/builders/ews_builder.rb', line 539

def or_r(expr)
  and_or('Or', expr)
end

#parent_folder_id!(pfid) ⇒ Object

Build the ParentFolderId element



184
185
186
187
188
# File 'lib/ews/soap/builders/ews_builder.rb', line 184

def parent_folder_id!(pfid)
  @nbuild.ParentFolderId {
    dispatch_folder_id!(pfid)
  }
end

#parent_folder_ids!(pfids) ⇒ Object

Build the ParentFolderIds element



174
175
176
177
178
179
180
# File 'lib/ews/soap/builders/ews_builder.rb', line 174

def parent_folder_ids!(pfids)
  @nbuild[NS_EWS_MESSAGES].ParentFolderIds {
    pfids.each do |pfid|
      dispatch_folder_id!(pfid)
    end
  }
end

#parent_item_id!(id) ⇒ Object



240
241
242
243
244
245
# File 'lib/ews/soap/builders/ews_builder.rb', line 240

def parent_item_id!(id)
  nbuild.ParentItemId {|x|
    x.parent['Id'] = id[:id]
    x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
  }
end

#pull_subscription_request(subopts) ⇒ Object



743
744
745
746
747
748
749
750
751
# File 'lib/ews/soap/builders/ews_builder.rb', line 743

def pull_subscription_request(subopts)
  subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
  @nbuild.PullSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
    folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
    event_types!(subopts[:event_types]) if subopts[:event_types]
    watermark!(subopts[:watermark]) if subopts[:watermark]
    timeout!(subopts[:timeout]) if subopts[:timeout]
  }
end

#push_subscription_request(subopts) ⇒ Object



754
755
756
757
758
759
760
761
762
763
# File 'lib/ews/soap/builders/ews_builder.rb', line 754

def push_subscription_request(subopts)
  subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
  @nbuild.PushSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
    folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
    event_types!(subopts[:event_types]) if subopts[:event_types]
    watermark!(subopts[:watermark]) if subopts[:watermark]
    status_frequency!(subopts[:status_frequency]) if subopts[:status_frequency]
    uRL!(subopts[:uRL]) if subopts[:uRL]
  }
end

#recurring_master_item_id!(id) ⇒ Object



277
278
279
280
281
282
# File 'lib/ews/soap/builders/ews_builder.rb', line 277

def recurring_master_item_id!(id)
  @nbuild[NS_EWS_TYPES].RecurringMasterItemId {|x|
    x.parent['OccurrenceId'] = id[:occurrence_id]
    x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
  }
end

#reference_item_id!(id) ⇒ Object



865
866
867
868
869
870
# File 'lib/ews/soap/builders/ews_builder.rb', line 865

def reference_item_id!(id)
  nbuild[NS_EWS_TYPES].ReferenceItemId {|x|
    x.parent['Id'] = id[:id]
    x.parent['ChangeKey'] = id[:change_key] if id[:change_key]
  }
end

#reminder_due_by!(date) ⇒ Object



971
972
973
# File 'lib/ews/soap/builders/ews_builder.rb', line 971

def reminder_due_by!(date)
  nbuild[NS_EWS_TYPES].ReminderDueBy format_time(date)
end

#reminder_is_set!(reminder) ⇒ Object



967
968
969
# File 'lib/ews/soap/builders/ews_builder.rb', line 967

def reminder_is_set!(reminder)
  nbuild[NS_EWS_TYPES].ReminderIsSet reminder
end

#reminder_minutes_before_start!(minutes) ⇒ Object



975
976
977
# File 'lib/ews/soap/builders/ews_builder.rb', line 975

def reminder_minutes_before_start!(minutes)
  nbuild[NS_EWS_TYPES].ReminderMinutesBeforeStart minutes
end

#reply_all_to_item!(item) ⇒ Object



857
858
859
860
861
862
863
# File 'lib/ews/soap/builders/ews_builder.rb', line 857

def reply_all_to_item!(item)
  nbuild[NS_EWS_TYPES].ReplyAllToItem {
    item.each_pair {|k,v|
      self.send("#{k}!", v)
    }
  }
end

#reply_to_item!(item) ⇒ Object



849
850
851
852
853
854
855
# File 'lib/ews/soap/builders/ews_builder.rb', line 849

def reply_to_item!(item)
  nbuild[NS_EWS_TYPES].ReplyToItem {
    item.each_pair {|k,v|
      self.send("#{k}!", v)
    }
  }
end

#required_attendees!(attendees) ⇒ Object



918
919
920
921
922
# File 'lib/ews/soap/builders/ews_builder.rb', line 918

def required_attendees!(attendees)
  nbuild[NS_EWS_TYPES].RequiredAttendees {
    attendees.each {|a| attendee!(a[:attendee])}
  }
end

#resources!(attendees) ⇒ Object



930
931
932
933
934
# File 'lib/ews/soap/builders/ews_builder.rb', line 930

def resources!(attendees)
  nbuild[NS_EWS_TYPES].Resources {
    attendees.each {|a| attendee!(a[:attendee])}
  }
end

#restriction!(restriction) ⇒ Object

Build the Restriction element

Parameters:

  • restriction (Hash)

    a well-formatted Hash that can be fed to #build_xml!

See Also:



527
528
529
530
531
532
533
# File 'lib/ews/soap/builders/ews_builder.rb', line 527

def restriction!(restriction)
  @nbuild[NS_EWS_MESSAGES].Restriction {
    restriction.each_pair do |k,v|
      self.send normalize_type(k), v
    end
  }
end

#restriction_compare(type, expr) ⇒ Object



614
615
616
617
618
619
620
621
622
# File 'lib/ews/soap/builders/ews_builder.rb', line 614

def restriction_compare(type,expr)
  nbuild[NS_EWS_TYPES].send(type) {
    expr.each do |e|
      e.each_pair do |k,v|
        self.send(k, v)
      end
    end
  }
end

#return_new_item_ids!(retval) ⇒ Object



1045
1046
1047
# File 'lib/ews/soap/builders/ews_builder.rb', line 1045

def return_new_item_ids!(retval)
  @nbuild.ReturnNewItemIds(retval)
end

#room_list!(cfg_prop) ⇒ Object



1195
1196
1197
1198
1199
# File 'lib/ews/soap/builders/ews_builder.rb', line 1195

def room_list!(cfg_prop)
  @nbuild[NS_EWS_MESSAGES].RoomList {
    email_address!(cfg_prop)
  }
end

#room_lists!Object



1201
1202
1203
# File 'lib/ews/soap/builders/ews_builder.rb', line 1201

def room_lists!
  @nbuild[NS_EWS_MESSAGES].GetRoomLists
end

#routing_type!(type) ⇒ Object

This is stupid. The only valid value is “SMTP”



383
384
385
# File 'lib/ews/soap/builders/ews_builder.rb', line 383

def routing_type!(type)
  nbuild[NS_EWS_TYPES].RoutingType(type)
end

#saved_item_folder_id!(fid) ⇒ Object



799
800
801
802
803
# File 'lib/ews/soap/builders/ews_builder.rb', line 799

def saved_item_folder_id!(fid)
  @nbuild.SavedItemFolderId {
    dispatch_folder_id!(fid)
  }
end

#search_folder!(folder) ⇒ Object



332
333
334
# File 'lib/ews/soap/builders/ews_builder.rb', line 332

def search_folder!(folder)
  folder! folder, :SearchFolder
end

#set_item_field!(upd) ⇒ Object



1025
1026
1027
1028
1029
1030
1031
1032
1033
# File 'lib/ews/soap/builders/ews_builder.rb', line 1025

def set_item_field!(upd)
  uri = upd.select {|k,v| k =~ /_uri/i}
  raise EwsBadArgumentError, "Bad argument given for SetItemField." if uri.keys.length != 1
  upd.delete(uri.keys.first)
  @nbuild[NS_EWS_TYPES].SetItemField {
    dispatch_field_uri!(uri, NS_EWS_TYPES)
    dispatch_field_item!(upd, NS_EWS_TYPES)
  }
end

#start!(st) ⇒ Object



943
944
945
# File 'lib/ews/soap/builders/ews_builder.rb', line 943

def start!(st)
  nbuild[NS_EWS_TYPES].Start(st[:text])
end

#start_date!(sd) ⇒ Object



951
952
953
# File 'lib/ews/soap/builders/ews_builder.rb', line 951

def start_date!(sd)
  nbuild[NS_EWS_TYPES].StartDate format_time(sd[:text])
end

#start_time_zone!(zone) ⇒ Object

TODO:

Implement sub elements Periods, TransitionsGroups and Transitions to override zone

Specifies an optional time zone for the start time

Parameters:

  • attributes (Hash)

See Also:



495
496
497
498
499
500
# File 'lib/ews/soap/builders/ews_builder.rb', line 495

def start_time_zone!(zone)
  attributes = {}
  attributes['Id'] = zone[:id] if zone[:id]
  attributes['Name'] = zone[:name] if zone[:name]
  nbuild[NS_EWS_TYPES].StartTimeZone(attributes)
end

#status_frequency!(freq) ⇒ Object



728
729
730
# File 'lib/ews/soap/builders/ews_builder.rb', line 728

def status_frequency!(freq)
  @nbuild[NS_EWS_TYPES].StatusFrequency(freq)
end

#streaming_subscription_request(subopts) ⇒ Object



766
767
768
769
770
771
772
# File 'lib/ews/soap/builders/ews_builder.rb', line 766

def streaming_subscription_request(subopts)
  subscribe_all = subopts[:subscribe_to_all_folders] ? 'true' : 'false'
  @nbuild.StreamingSubscriptionRequest('SubscribeToAllFolders' => subscribe_all) {
    folder_ids!(subopts[:folder_ids]) if subopts[:folder_ids]
    event_types!(subopts[:event_types]) if subopts[:event_types]
  }
end

#subject!(sub) ⇒ Object



872
873
874
# File 'lib/ews/soap/builders/ews_builder.rb', line 872

def subject!(sub)
  nbuild[NS_EWS_TYPES].Subject(sub)
end

#subscription_id!(subid) ⇒ Object



738
739
740
# File 'lib/ews/soap/builders/ews_builder.rb', line 738

def subscription_id!(subid)
  @nbuild.SubscriptionId(subid)
end

#suggestions_view_options!(opts) ⇒ Object



434
435
# File 'lib/ews/soap/builders/ews_builder.rb', line 434

def suggestions_view_options!(opts)
end

#sync_folder_id!(fid) ⇒ Object

Build the SyncFolderId element



204
205
206
207
208
# File 'lib/ews/soap/builders/ews_builder.rb', line 204

def sync_folder_id!(fid)
  @nbuild.SyncFolderId {
    dispatch_folder_id!(fid)
  }
end

#sync_scope!(scope) ⇒ Object



794
795
796
# File 'lib/ews/soap/builders/ews_builder.rb', line 794

def sync_scope!(scope)
  @nbuild.SyncScope(scope)
end

#sync_state!(syncstate) ⇒ Object



775
776
777
# File 'lib/ews/soap/builders/ews_builder.rb', line 775

def sync_state!(syncstate)
  @nbuild.SyncState(syncstate)
end

#task!(item) ⇒ Object



833
834
835
836
837
838
839
# File 'lib/ews/soap/builders/ews_builder.rb', line 833

def task!(item)
  nbuild[NS_EWS_TYPES].Task {
    item.each_pair {|k,v|
      self.send("#{k}!", v)
    }
  }
end

#tasks_folder!(folder) ⇒ Object



336
337
338
# File 'lib/ews/soap/builders/ews_builder.rb', line 336

def tasks_folder!(folder)
  folder! folder, :TasksFolder
end

#time_zone!(zone) ⇒ Object



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/ews/soap/builders/ews_builder.rb', line 437

def time_zone!(zone)
  zone ||= {}
  zone = {
    bias: zone[:bias] || 480,
    standard_time: {
      bias: 0,
      time: "02:00:00",
      day_order: 5,
      month: 10,
      day_of_week: 'Sunday'
    }.merge(zone[:standard_time] || {}),
    daylight_time: {
      bias: -60,
      time: "02:00:00",
      day_order: 1,
      month: 4,
      day_of_week: 'Sunday'
    }.merge(zone[:daylight_time] || {})
  }

  nbuild[NS_EWS_TYPES].TimeZone {
    nbuild[NS_EWS_TYPES].Bias(zone[:bias])
    nbuild[NS_EWS_TYPES].StandardTime {
      nbuild[NS_EWS_TYPES].Bias(zone[:standard_time][:bias])
      nbuild[NS_EWS_TYPES].Time(zone[:standard_time][:time])
      nbuild[NS_EWS_TYPES].DayOrder(zone[:standard_time][:day_order])
      nbuild[NS_EWS_TYPES].Month(zone[:standard_time][:month])
      nbuild[NS_EWS_TYPES].DayOfWeek(zone[:standard_time][:day_of_week])
    }
    nbuild[NS_EWS_TYPES].DaylightTime {
      nbuild[NS_EWS_TYPES].Bias(zone[:daylight_time][:bias])
      nbuild[NS_EWS_TYPES].Time(zone[:daylight_time][:time])
      nbuild[NS_EWS_TYPES].DayOrder(zone[:daylight_time][:day_order])
      nbuild[NS_EWS_TYPES].Month(zone[:daylight_time][:month])
      nbuild[NS_EWS_TYPES].DayOfWeek(zone[:daylight_time][:day_of_week])
    }
  }
end

#time_zone_definition!(zone) ⇒ Object

TODO:

Implement subelements Periods, TransitionsGroups and Transitions to override zone

Specify a time zone



518
519
520
521
522
# File 'lib/ews/soap/builders/ews_builder.rb', line 518

def time_zone_definition!(zone)
  attributes = {'Id' => zone[:id]}
  attributes['Name'] = zone[:name] if zone[:name]
  nbuild[NS_EWS_TYPES].TimeZoneDefinition(attributes)
end

#timeout!(tout) ⇒ Object



723
724
725
# File 'lib/ews/soap/builders/ews_builder.rb', line 723

def timeout!(tout)
  @nbuild[NS_EWS_TYPES].Timeout(tout)
end

#to_folder_id!(to_fid) ⇒ Object



285
286
287
288
289
# File 'lib/ews/soap/builders/ews_builder.rb', line 285

def to_folder_id!(to_fid)
  @nbuild[NS_EWS_MESSAGES].ToFolderId {
    dispatch_folder_id!(to_fid)
  }
end

#to_recipients!(r) ⇒ Object

Parameters:

  • r (Array)

    An array of Mailbox type hashes to send to #mailbox!

See Also:



894
895
896
897
898
# File 'lib/ews/soap/builders/ews_builder.rb', line 894

def to_recipients!(r)
  nbuild[NS_EWS_TYPES].ToRecipients {
    r.each {|mbox| mailbox!(mbox[:mailbox]) }
  }
end

#updates!(updates) ⇒ Object



1005
1006
1007
1008
1009
1010
1011
# File 'lib/ews/soap/builders/ews_builder.rb', line 1005

def updates!(updates)
  @nbuild[NS_EWS_TYPES].Updates {
    updates.each do |update|
      dispatch_update_type!(update)
    end
  }
end

#uRL!(url) ⇒ Object



733
734
735
# File 'lib/ews/soap/builders/ews_builder.rb', line 733

def uRL!(url)
  @nbuild[NS_EWS_TYPES].URL(url)
end

#user_configuration_name!(cfg_name) ⇒ Object



1092
1093
1094
1095
1096
1097
1098
# File 'lib/ews/soap/builders/ews_builder.rb', line 1092

def user_configuration_name!(cfg_name)
  attribs = {'Name' => cfg_name.delete(:name)}
  @nbuild[NS_EWS_MESSAGES].UserConfigurationName(attribs) {
    fid = cfg_name.keys.first
    self.send "#{fid}!", cfg_name[fid][:id], cfg_name[fid][:change_key]
  }
end

#user_configuration_properties!(cfg_prop) ⇒ Object



1100
1101
1102
# File 'lib/ews/soap/builders/ews_builder.rb', line 1100

def user_configuration_properties!(cfg_prop)
  @nbuild[NS_EWS_MESSAGES].UserConfigurationProperties(cfg_prop)
end

#user_oof_settings!(opts) ⇒ Object



391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/ews/soap/builders/ews_builder.rb', line 391

def user_oof_settings!(opts)
  nbuild[NS_EWS_TYPES].UserOofSettings {
    nbuild.OofState(camel_case(opts[:oof_state]))
    nbuild.ExternalAudience(camel_case(opts[:external_audience])) if opts[:external_audience]
    duration!(opts[:duration]) if opts[:duration]
    nbuild.InternalReply {
      nbuild.Message(opts[:internal_reply])
    } if opts[:external_reply]
    nbuild.ExternalReply {
      nbuild.Message(opts[:external_reply])
    } if opts[:external_reply]
  }
end

#value!(val) ⇒ Object



677
678
679
# File 'lib/ews/soap/builders/ews_builder.rb', line 677

def value!(val)
  nbuild[NS_EWS_TYPES].Value(val)
end

#watermark!(wmark, ns = NS_EWS_TYPES) ⇒ Object



718
719
720
# File 'lib/ews/soap/builders/ews_builder.rb', line 718

def watermark!(wmark, ns = NS_EWS_TYPES)
  @nbuild[ns].Watermark(wmark)
end