0

I'm using savonrb as a SOAP client to make an api request to echosign to generate a widget.
Seems that savon overwrites my mergeField's with only the value of the last one rather than passing them in as an array.

params that I'm using to make the api call:

call_api(:create_personal_embedded_widget, senderInfo: {email: sender_email}, widgetInfo: {
 "callbackInfo" => {
   "signedDocumentUrl" => signed_document_url
 },  
 "fileInfos" => {
   "FileInfo" => {
     "file" =>encoded_file,
     "fileName" =>"simple_text.docx",
     "mimeType "=>"application/msword"
   }  
 },  
 "formFieldLayerTemplates" => "",
 "locale" => "",
 "mergeFieldInfo" => {
   "mergeFields" => {
     "MergeField" => 
     {
       "defaultValue" => "Foo Bar",
       "fieldName" => "fullName"
     },  
     "MergeField" => 
     {
       "defaultValue" => "01-01-1980",
       "fieldName" => "dob"
     }
   }  
 },  
 "name" => document_name,
 "securityOptions" => "",
 "signatureFlow" =>"SENDER_SIGNS_LAST",
 "widgetAuthFailureInfo" => {
   "deframe" =>"true",
   "delay" =>"10",
   "url" => error_call_back_url
 },  
 "widgetCompletionInfo" => {
   "deframe" =>"true",
   "delay" =>"10",
   "url" => success_call_back_url
 }  
}, personalizationInfo: "")  

what actually gets passed to echosign:

<ins2:mergeFieldInfo>
  <ins3:mergeFields>
    <ins3:MergeField>
      <ins3:defaultValue>01-01-1980</ins3:defaultValue>
      <ins3:fieldName>dob</ins3:fieldName>
    </ins3:MergeField>
  </ins3:mergeFields>
</ins2:mergeFieldInfo>

I'be been rattling my brain with this to no avail, I get that it overwrites the values, but can't understand why, and not sure how to index them so that the fields are incremental.

Thanks in advance!

Mike
  • 463
  • 3
  • 8
  • 22

1 Answers1

0

Seems wasn't an issue with soap or savon, was me not creating the array properly,

mergeFields = { 'MergeField' => [ 
    {'defaultValue' => 'Foo Bar', 'fieldName' => 'fullName' }, 
    {'defaultValue' => '212-555-1234',   'fieldName' => 'phoneNumber },
  ] 
}

and inside the hash it self, i just put in the variable

"mergeFieldInfo" => {
    "mergeFields" => mergeFields
},
Mike
  • 463
  • 3
  • 8
  • 22