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

#accept_item!(opts) ⇒ Object



1272
1273
1274
1275
1276
1277
1278
# File 'lib/ews/soap/builders/ews_builder.rb', line 1272

def accept_item!(opts)
  @nbuild[NS_EWS_TYPES].AcceptItem {
    sensitivity!(opts)
    body!(opts) if opts[:text]
    reference_item_id!(opts)
  }
end

#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



1082
1083
1084
1085
1086
1087
1088
1089
1090
# File 'lib/ews/soap/builders/ews_builder.rb', line 1082

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



1155
1156
1157
1158
# File 'lib/ews/soap/builders/ews_builder.rb', line 1155

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

#attachment_ids!(aids) ⇒ Object

Build the AttachmentIds element



1144
1145
1146
1147
1148
1149
1150
1151
# File 'lib/ews/soap/builders/ews_builder.rb', line 1144

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

#attendee!(a) ⇒ Object



1001
1002
1003
1004
1005
# File 'lib/ews/soap/builders/ews_builder.rb', line 1001

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



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

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



944
945
946
947
948
# File 'lib/ews/soap/builders/ews_builder.rb', line 944

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



836
837
838
839
840
841
842
# File 'lib/ews/soap/builders/ews_builder.rb', line 836

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

#calendar_item_type!(type) ⇒ Object



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

def calendar_item_type!(type)
  nbuild[NS_EWS_TYPES].CalendarItemType(type)
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

#categories!(fa) ⇒ Object



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

def categories!(fa)
  @nbuild[NS_EWS_TYPES].Categories {
    @nbuild[NS_EWS_TYPES].String(fa)
  }
end

#cc_recipients!(r) ⇒ Object



964
965
966
967
968
# File 'lib/ews/soap/builders/ews_builder.rb', line 964

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

#daily_recurrence!(item) ⇒ Object



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

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

#decline_item!(opts) ⇒ Object



1288
1289
1290
1291
1292
1293
1294
# File 'lib/ews/soap/builders/ews_builder.rb', line 1288

def decline_item!(opts)
  @nbuild[NS_EWS_TYPES].DeclineItem {
    sensitivity!(opts)
    body!(opts) if opts[:text]
    reference_item_id!(opts)
  }
end

#delete_item_field!(upd) ⇒ Object



1104
1105
1106
1107
1108
1109
1110
# File 'lib/ews/soap/builders/ews_builder.rb', line 1104

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



1257
1258
1259
1260
# File 'lib/ews/soap/builders/ews_builder.rb', line 1257

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



1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
# File 'lib/ews/soap/builders/ews_builder.rb', line 1224

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



1177
1178
1179
1180
1181
1182
1183
1184
1185
# File 'lib/ews/soap/builders/ews_builder.rb', line 1177

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



1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
# File 'lib/ews/soap/builders/ews_builder.rb', line 1189

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)
  when :recurring_master_item_id
    recurring_master_item_id!(item)
  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



1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
# File 'lib/ews/soap/builders/ews_builder.rb', line 1207

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



1019
1020
1021
# File 'lib/ews/soap/builders/ews_builder.rb', line 1019

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



1011
1012
1013
# File 'lib/ews/soap/builders/ews_builder.rb', line 1011

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



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

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



1126
1127
1128
1129
1130
1131
# File 'lib/ews/soap/builders/ews_builder.rb', line 1126

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



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

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



976
977
978
979
980
# File 'lib/ews/soap/builders/ews_builder.rb', line 976

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



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

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

#importance!(sub) ⇒ Object



940
941
942
# File 'lib/ews/soap/builders/ews_builder.rb', line 940

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



1117
1118
1119
1120
1121
1122
1123
1124
# File 'lib/ews/soap/builders/ews_builder.rb', line 1117

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

#interval!(num) ⇒ Object



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

def interval!(num)
  nbuild[NS_EWS_TYPES].Interval(num)
end

#is_all_day_event!(all_day) ⇒ Object



1027
1028
1029
# File 'lib/ews/soap/builders/ews_builder.rb', line 1027

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

#is_read!(read) ⇒ Object



832
833
834
# File 'lib/ews/soap/builders/ews_builder.rb', line 832

def is_read!(read)
  nbuild[NS_EWS_TYPES].IsRead(read)
end

#is_response_requested!(response_requested) ⇒ Object



1031
1032
1033
# File 'lib/ews/soap/builders/ews_builder.rb', line 1031

def is_response_requested!(response_requested)
  nbuild[NS_EWS_TYPES].IsResponseRequested(response_requested)
end

#item!(item) ⇒ Object



813
814
815
816
817
818
819
# File 'lib/ews/soap/builders/ews_builder.rb', line 813

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

#item_attachment!(ia) ⇒ Object



1133
1134
1135
1136
1137
1138
1139
1140
# File 'lib/ews/soap/builders/ews_builder.rb', line 1133

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



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

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



1055
1056
1057
1058
1059
1060
1061
# File 'lib/ews/soap/builders/ews_builder.rb', line 1055

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]


1050
1051
1052
# File 'lib/ews/soap/builders/ews_builder.rb', line 1050

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

#location!(loc) ⇒ Object



1023
1024
1025
# File 'lib/ews/soap/builders/ews_builder.rb', line 1023

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



796
797
798
# File 'lib/ews/soap/builders/ews_builder.rb', line 796

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

#message!(item) ⇒ Object



821
822
823
824
825
826
827
828
829
830
# File 'lib/ews/soap/builders/ews_builder.rb', line 821

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



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

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

#no_end_recurrence!(item) ⇒ Object



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

def no_end_recurrence!(item)
  nbuild[NS_EWS_TYPES].NoEndRecurrence {
    item.each_pair { |k, v|
      self.send("#{k}!", v)
    }
  }
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

#number_of_occurrences!(count) ⇒ Object



892
893
894
# File 'lib/ews/soap/builders/ews_builder.rb', line 892

def number_of_occurrences!(count)
  nbuild[NS_EWS_TYPES].NumberOfOccurrences(count)
end

#numbered_recurrence!(item) ⇒ Object



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

def numbered_recurrence!(item)
  nbuild[NS_EWS_TYPES].NumberedRecurrence {
    item.each_pair { |k, v|
      self.send("#{k}!", v)
    }
  }
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



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

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



750
751
752
753
754
755
756
757
758
# File 'lib/ews/soap/builders/ews_builder.rb', line 750

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



761
762
763
764
765
766
767
768
769
770
# File 'lib/ews/soap/builders/ews_builder.rb', line 761

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

#recurrence!(item) ⇒ Object



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

def recurrence!(item)
  nbuild[NS_EWS_TYPES].Recurrence {
    item.each_pair { |k, v|
      self.send("#{k}!", v)
    }
  }
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



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

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



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

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

#reminder_is_set!(reminder) ⇒ Object



1035
1036
1037
# File 'lib/ews/soap/builders/ews_builder.rb', line 1035

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

#reminder_minutes_before_start!(minutes) ⇒ Object



1043
1044
1045
# File 'lib/ews/soap/builders/ews_builder.rb', line 1043

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

#reply_all_to_item!(item) ⇒ Object



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

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



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

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

#required_attendees!(attendees) ⇒ Object



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

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

#resources!(attendees) ⇒ Object



994
995
996
997
998
# File 'lib/ews/soap/builders/ews_builder.rb', line 994

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



1113
1114
1115
# File 'lib/ews/soap/builders/ews_builder.rb', line 1113

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

#room_list!(cfg_prop) ⇒ Object



1262
1263
1264
1265
1266
# File 'lib/ews/soap/builders/ews_builder.rb', line 1262

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

#room_lists!Object



1268
1269
1270
# File 'lib/ews/soap/builders/ews_builder.rb', line 1268

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



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

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

#sensitivity!(value) ⇒ Object



1296
1297
1298
# File 'lib/ews/soap/builders/ews_builder.rb', line 1296

def sensitivity!(value)
  nbuild[NS_EWS_TYPES].Sensitivity(value[:sensitivity])
end

#set_item_field!(upd) ⇒ Object



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

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



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

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

#start_date!(sd) ⇒ Object



1015
1016
1017
# File 'lib/ews/soap/builders/ews_builder.rb', line 1015

def start_date!(sd)
  nbuild[NS_EWS_TYPES].StartDate 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



735
736
737
# File 'lib/ews/soap/builders/ews_builder.rb', line 735

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

#streaming_subscription_request(subopts) ⇒ Object



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

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



936
937
938
# File 'lib/ews/soap/builders/ews_builder.rb', line 936

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

#subscription_id!(subid) ⇒ Object



745
746
747
# File 'lib/ews/soap/builders/ews_builder.rb', line 745

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



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

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

#sync_state!(syncstate) ⇒ Object



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

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

#task!(item) ⇒ Object



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

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

#tentatively_accept_item!(opts) ⇒ Object



1280
1281
1282
1283
1284
1285
1286
# File 'lib/ews/soap/builders/ews_builder.rb', line 1280

def tentatively_accept_item!(opts)
  @nbuild[NS_EWS_TYPES].TentativelyAcceptItem {
    sensitivity!(opts)
    body!(opts) if opts[:text]
    reference_item_id!(opts)
  }
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



730
731
732
# File 'lib/ews/soap/builders/ews_builder.rb', line 730

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:



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

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

#updates!(updates) ⇒ Object



1073
1074
1075
1076
1077
1078
1079
# File 'lib/ews/soap/builders/ews_builder.rb', line 1073

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

#uRL!(url) ⇒ Object



740
741
742
# File 'lib/ews/soap/builders/ews_builder.rb', line 740

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

#user_configuration_name!(cfg_name) ⇒ Object



1160
1161
1162
1163
1164
1165
1166
# File 'lib/ews/soap/builders/ews_builder.rb', line 1160

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



1168
1169
1170
# File 'lib/ews/soap/builders/ews_builder.rb', line 1168

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



725
726
727
# File 'lib/ews/soap/builders/ews_builder.rb', line 725

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

#weekly_recurrence!(item) ⇒ Object



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

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