public static string GenerateFormPostData(ActionApiDescriptionModel action, int indent = 0) { var parameters = action .Parameters .Where(p => p.BindingSourceId == ParameterBindingSources.Form) .ToArray(); if (!parameters.Any()) { return(null); } return(ProxyScriptingJsFuncHelper.CreateJsObjectLiteral(parameters, indent)); }
private static string ReplacePathVariables(string url, IList <ParameterApiDescriptionModel> actionParameters) { var pathParameters = actionParameters .Where(p => p.BindingSourceId == ParameterBindingSources.Path) .ToArray(); if (!pathParameters.Any()) { return(url); } foreach (var pathParameter in pathParameters) { url = url.Replace($"{{{pathParameter.Name}}}", $"' + {ProxyScriptingJsFuncHelper.GetParamNameInJsFunc(pathParameter)} + '"); } return(url); }
public static string GenerateBody(ActionApiDescriptionModel action) { var parameters = action .Parameters .Where(p => p.BindingSourceId == ParameterBindingSources.Body) .ToArray(); if (parameters.Length <= 0) { return(null); } if (parameters.Length > 1) { throw new AbpException( $"Only one complex type allowed as argument to a controller action that's binding source is 'Body'. But {action.Name} ({action.Url}) contains more than one!" ); } return(ProxyScriptingJsFuncHelper.GetParamNameInJsFunc(parameters[0])); }
private static string AddQueryStringParameters(string url, IList <ParameterApiDescriptionModel> actionParameters) { var queryStringParameters = actionParameters .Where(p => p.BindingSourceId.IsIn(ParameterBindingSources.ModelBinding, ParameterBindingSources.Query)) .ToArray(); if (!queryStringParameters.Any()) { return(url); } var qsBuilderParams = queryStringParameters .Select(p => $"{{ name: '{p.Name.ToCamelCase()}', value: {ProxyScriptingJsFuncHelper.GetParamNameInJsFunc(p)} }}") .JoinAsString(", "); return(url + $"' + abp.utils.buildQueryString([{qsBuilderParams}]) + '"); }