Class: Exchanger::CreateItem::Request

Inherits:
Operation::Request show all
Defined in:
lib/exchanger/operations/create_item.rb

Instance Attribute Summary collapse

Attributes inherited from Operation::Request

#body, #response

Instance Method Summary collapse

Methods inherited from Operation::Request

#action, #headers, #initialize

Constructor Details

This class inherits a constructor from Exchanger::Operation::Request

Instance Attribute Details

#email_addressObject

Returns the value of attribute email_address.



14
15
16
# File 'lib/exchanger/operations/create_item.rb', line 14

def email_address
  @email_address
end

#folder_idObject

Returns the value of attribute folder_id.



14
15
16
# File 'lib/exchanger/operations/create_item.rb', line 14

def folder_id
  @folder_id
end

#itemsObject

Returns the value of attribute items.



14
15
16
# File 'lib/exchanger/operations/create_item.rb', line 14

def items
  @items
end

#send_meeting_invitationsObject

Returns the value of attribute send_meeting_invitations.



14
15
16
# File 'lib/exchanger/operations/create_item.rb', line 14

def send_meeting_invitations
  @send_meeting_invitations
end

Instance Method Details

#resetObject

Reset request options to defaults.



18
19
20
21
22
# File 'lib/exchanger/operations/create_item.rb', line 18

def reset
  @folder_id = :contacts
  @email_address = nil
  @items = []
end

#to_xmlObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/exchanger/operations/create_item.rb', line 24

def to_xml
  Nokogiri::XML::Builder.new do |xml|
    xml.send("soap:Envelope", "xmlns:soap" => NS["soap"], "xmlns:t" => NS["t"], "xmlns:xsi" => NS["xsi"], "xmlns:xsd" => NS["xsd"]) do
      xml.send("soap:Body") do
        xml.CreateItem(create_item_attributes) do
          xml.SavedItemFolderId do
            if folder_id.is_a?(Symbol)
              xml.send("t:DistinguishedFolderId", "Id" => folder_id) do
                if email_address
                  xml.send("t:Mailbox") do
                    xml.send("t:EmailAddress", email_address)
                  end
                end
              end
            else
              xml.send("t:FolderId", "Id" => folder_id)
            end
          end
          xml.Items do
            items.each do |item|
              item_xml = item.to_xml
              item_xml.add_namespace_definition("t", NS["t"])
              item_xml.namespace = item_xml.namespace_definitions[0]
              xml << item_xml.to_s
            end
          end
        end
      end
    end
  end
end