Class: Exchanger::CreateAttachment::Request

Inherits:
Operation::Request show all
Defined in:
lib/exchanger/operations/create_attachment.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

#attachmentsObject

Returns the value of attribute attachments


7
8
9
# File 'lib/exchanger/operations/create_attachment.rb', line 7

def attachments
  @attachments
end

#parent_item_idObject

Returns the value of attribute parent_item_id


7
8
9
# File 'lib/exchanger/operations/create_attachment.rb', line 7

def parent_item_id
  @parent_item_id
end

Instance Method Details

#resetObject

Reset request options to defaults.


10
11
12
13
# File 'lib/exchanger/operations/create_attachment.rb', line 10

def reset
  @parent_item_id = nil
  @attachments = []
end

#to_xmlObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/exchanger/operations/create_attachment.rb', line 15

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.CreateAttachment("xmlns" => NS["m"]) do
          xml.ParentItemId("Id" => parent_item_id)
          xml.Attachments do
            attachments.each do |attachment|
              attachment_xml = attachment.to_xml
              attachment_xml.add_namespace_definition("t", NS["t"])
              attachment_xml.namespace = attachment_xml.namespace_definitions[0]
              xml << attachment_xml.to_s
            end
          end
        end
      end
    end
  end
end