Class: AkamaiApi::ECCU::SoapBody
- Inherits:
-
Object
- Object
- AkamaiApi::ECCU::SoapBody
- Defined in:
- lib/akamai_api/eccu/soap_body.rb
Overview
Theoretically this class shouldn’t exist because Savon should be able to understand the provided wsdl correctly and the request payload should be filled using its helpers. In practice, at least with Savon v2.2, it wasn’t able to do it, and this class tries to simplify the creation of the xml payload that encapsulate method arguments.
Utility class used by the ECCU request classes to fill the request payload with the arguments requested by a SOAP method.
The payload of each request is an xml describing the arguments of the method. E.g.
<filename xsi:type="xsd:string">./publish.xml</filename>
<contents xsi:type="xsd:base64Binary">aGVsbG8gd29ybGQ=</contents>
<notes xsi:type="xsd:string">ECCU Request using AkamaiApi</notes>
<versionString xsi:type="xsd:string"></versionString>
<propertyName xsi:type="xsd:string">foo.com</propertyName>
<propertyType xsi:type="xsd:string">hostheader</propertyType>
<propertyNameExactMatch xsi:type="xsd:boolean">true</propertyNameExactMatch>
Using this class you can create the above payload with the following code:
block = SoapBody.new
block.string :filename, './publish.xml'
block.text :contents, 'hello world'
block.string :notes, 'ECCU request using AkamaiApi'
block.string :versionString, ''
block.string :propertyName, 'foo.com'
block.string :propertyType, 'hostheader'
block.boolean :propertyExactMatch, true
block.to_s
Instance Method Summary collapse
-
#array(name, values) ⇒ SoapBody
Appends an argument of type array.
-
#boolean(name, value) ⇒ SoapBody
Appends an argument of type boolean.
-
#initialize ⇒ SoapBody
constructor
A new instance of SoapBody.
-
#integer(name, value) ⇒ SoapBody
Appends an argument of type integer.
-
#string(name, value) ⇒ SoapBody
Appends an argument of type string.
-
#text(name, value) ⇒ SoapBody
Appends an argument of type text, encoding the given value in base64.
-
#to_s ⇒ String
Returns the XML to use to set SOAP method arguments.
Constructor Details
#initialize ⇒ SoapBody
Returns a new instance of SoapBody.
43 44 45 |
# File 'lib/akamai_api/eccu/soap_body.rb', line 43 def initialize @builder = Builder::XmlMarkup.new end |
Instance Method Details
#array(name, values) ⇒ SoapBody
Appends an argument of type array
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/akamai_api/eccu/soap_body.rb', line 82 def array name, values array_attrs = { 'soapenc:arrayType' => "xsd:string[#{values.length}]", 'xsi:type' => 'wsdl:ArrayOfString' } builder.tag! name, array_attrs do |tag| values.each { |value| tag.item value } end self end |
#boolean(name, value) ⇒ SoapBody
Appends an argument of type boolean
71 72 73 74 75 76 |
# File 'lib/akamai_api/eccu/soap_body.rb', line 71 TAG_TYPES.each do |type, type_code| define_method type do |name, value| builder.tag! name, value, 'xsi:type' => type_code self end end |
#integer(name, value) ⇒ SoapBody
Appends an argument of type integer
71 72 73 74 75 76 |
# File 'lib/akamai_api/eccu/soap_body.rb', line 71 TAG_TYPES.each do |type, type_code| define_method type do |name, value| builder.tag! name, value, 'xsi:type' => type_code self end end |
#string(name, value) ⇒ SoapBody
Appends an argument of type string
71 72 73 74 75 76 |
# File 'lib/akamai_api/eccu/soap_body.rb', line 71 TAG_TYPES.each do |type, type_code| define_method type do |name, value| builder.tag! name, value, 'xsi:type' => type_code self end end |
#text(name, value) ⇒ SoapBody
Appends an argument of type text, encoding the given value in base64
51 52 53 54 |
# File 'lib/akamai_api/eccu/soap_body.rb', line 51 def text name, value builder.tag! name, Base64.encode64(value), 'xsi:type' => 'xsd:base64Binary' self end |
#to_s ⇒ String
Returns the XML to use to set SOAP method arguments
95 96 97 |
# File 'lib/akamai_api/eccu/soap_body.rb', line 95 def to_s builder.target! end |