Method: DocuSign_Maestro::ApiClient#build_request_body

Defined in:
lib/docusign_maestro/client/api_client.rb

#build_request_body(header_params, form_params, body) ⇒ String

Builds the HTTP request body

Parameters:

  • header_params (Hash)

    Header parameters

  • form_params (Hash)

    Query parameters

  • body (Object)

    HTTP body (JSON/XML)

Returns:

  • (String)

    HTTP body data in the form of string

[View source]

273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/docusign_maestro/client/api_client.rb', line 273

def build_request_body(header_params, form_params, body)
  # http form
  if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
      header_params['Content-Type'] == 'multipart/form-data'
    data = {}
    form_params.each do |key, value|
      case value
      when File, Array, nil
        # let typhoeus handle File, Array and nil parameters
        data[key] = value
      else
        if header_params['Content-Type'] == 'multipart/form-data'
          header_params['Content-Disposition'] = 'form-data; name=file; filename=' + key
          data = value
        else
          data[key] = value.to_s
        end
      end
    end
  elsif body
    data = body.is_a?(String) ? body : body.to_json
  else
    data = nil
  end
  data
end