Exemplo n.º 1
0
        protected AsposeResponse PostMergeHtmlTemplate_Impl(string templateName, Stream inStream, string dataFileName, string outPath, string options = null, string folder = null, string storage = null)
        {
            var methodName = "PostMergeHtmlTemplate";

            // verify the required parameter 'templateName' is set
            if (templateName == null)
            {
                throw new ApiException(400, $"Missing required parameter 'templateName' when calling {methodName}");
            }
            // verify the required parameter 'outPath' is set
            if (outPath == null)
            {
                throw new ApiException(400, $"Missing required parameter 'outPath' when calling {methodName}");
            }
            // verify the required parameter 'inStream' is set
            if (inStream == null)
            {
                throw new ApiException(400, $"Missing required parameter 'inStream' when calling {methodName}");
            }

            var path = "/html/{templateName}/merge";

            path = path.Replace("{" + "templateName" + "}", ApiClientUtils.ParameterToString(templateName));

            var queryParams  = new Dictionary <String, String>();
            var headerParams = new Dictionary <String, String>();

            queryParams.Add("outPath", ApiClientUtils.ParameterToString(outPath)); // required query parameter

            if (options != null)
            {
                queryParams.Add("options", ApiClientUtils.ParameterToString(options));                  // query parameter
            }
            if (folder != null)
            {
                queryParams.Add("folder", ApiClientUtils.ParameterToString(folder));                 // query parameter
            }
            if (storage != null)
            {
                queryParams.Add("storage", ApiClientUtils.ParameterToString(storage));                  // query parameter
            }
            if (!string.IsNullOrEmpty(dataFileName))
            {
                var dataType = MimeHelper.GetFormatByExtension(Path.GetExtension(dataFileName).Replace(".", ""));
                if (!(dataType.ToLower() == "json" || dataType.ToLower() == "xml"))
                {
                    throw new ApiException(400, $"'dataType' parameter: Unsupported data type when calling {methodName}");
                }

                queryParams.Add(PAR_FILENAME_I, dataFileName);
                var contentType = MimeHelper.GetMimeType(dataType);
                if (contentType == null)
                {
                    throw new ApiException(400, $"'dataType' parameter: Unsupported data type provided when calling {methodName}");
                }

                headerParams.Add("Content-Type", contentType);
            }
            headerParams.Add("Content-Length", inStream.Length.ToString());
            // authentication setting, if contentType
            String[] authSettings = new String[] { };

            var response = CallPostApi(path, queryParams, headerParams, inStream, methodName);

            return(response);
        }