private string GetReturnType(ProxyOperationModel operation)
        {
            if (operation.ReturnType == null)
            {
                return("boolean");
            }

            return(GetTypeName(operation.ReturnType));
        }
        private string GetDataServiceCall(ProxyOperationModel operation)
        {
            switch (GetHttpVerb(operation))
            {
            case HttpVerb.GET:
                return($"get(url)");

            case HttpVerb.POST:
                return($"post(url, {operation.Parameters.FirstOrDefault(x => IsComplexObject(x.TypeReference.Element))?.Name.ToCamelCase() ?? "null"})");

            case HttpVerb.PUT:
                return($"put(url, {operation.Parameters.FirstOrDefault(x => IsComplexObject(x.TypeReference.Element))?.Name.ToCamelCase() ?? "null"})");

            case HttpVerb.DELETE:
                return($"delete(url)");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private string GetUpdateUrl(ProxyOperationModel operation)
        {
            var mappedOperation = new OperationModel((IElement)operation.Mapping.Element);

            if (mappedOperation?.Parameters.Count != operation.Parameters.Count)
            {
                throw new Exception($"Different number of properties for mapped operation [{operation.Name}] on {ServiceProxyModel.SpecializationType} [{Model.Name}]");
            }

            var path          = GetPath(operation);
            var urlParameters = mappedOperation.Parameters.Where(x => !IsComplexObject(x.Type.Element) &&
                                                                 !path.Contains($"${{{x.Name.ToCamelCase()}}}")).ToList();

            if (!urlParameters.Any())
            {
                return("");
            }

            return($@"
        url = `${{url}}?{string.Join("&", urlParameters.Select((x, index) => $"{x.Name.ToCamelCase()}=${{{operation.Parameters[index].Name.ToCamelCase()}}}"))}`;");
        }
        private string GetPath(ProxyOperationModel operation)
        {
            var servicePath = Model.MappedService.GetHttpServiceSettings()?.Route()?.ToLower()
                              .Replace("[controller]", Model.MappedService.Name.ToLower().RemoveSuffix("controller", "service")) ?? $"api/{Model.MappedService.Name.ToLower().RemoveSuffix("controller", "service")}";
            var operationPath = operation.MappedOperation.GetHttpSettings()?.Route()?.ToLower()
                                .Replace("[action]", operation.MappedOperation.Name.ToLower());

            if (!string.IsNullOrWhiteSpace(operationPath))
            {
                foreach (var parameter in operation.Parameters)
                {
                    //var routeElements = operationPath.Split("/", StringSplitOptions.RemoveEmptyEntries);
                    //if (routeElements.Any(x => x.Contains('{')
                    //                           && x.Contains('}')
                    //                           && x.Split(new[] {'{', '}'}, StringSplitOptions.RemoveEmptyEntries).Any(i => i == parameter.Name.ToCamelCase())))
                    //{
                    if (operationPath.Contains($"{{{parameter.Name}}}", StringComparison.InvariantCultureIgnoreCase))
                    {
                        operationPath = operationPath.Replace($"{{{parameter.Name}}}", $"${{{parameter.Name.ToCamelCase()}}}", StringComparison.InvariantCultureIgnoreCase);
                    }
                    //}
                    //var startIndex = operationPath.IndexOf($"{{{parameter.Name}", StringComparison.InvariantCultureIgnoreCase);
                    //if (startIndex != -1)
                    //{
                    //    var endIndex = operationPath.IndexOf("}", startIndex, StringComparison.InvariantCultureIgnoreCase);
                    //    if (endIndex != -1)
                    //    {
                    //        operationPath = operationPath.Remove(startIndex, endIndex - startIndex + 1);
                    //        operationPath = operationPath.Insert(startIndex, $"${{{parameter.Name.ToCamelCase()}}}");
                    //    }
                    //}
                }
            }

            return(string.IsNullOrWhiteSpace(operationPath) ? $"/{servicePath}" : $"/{servicePath}/{operationPath}");
        }
 public bool Equals(OperationModel other)
 {
     return(Equals(_element, other?._element));
 }
 private string GetParameterDefinitions(ProxyOperationModel operation)
 {
     return(string.Join(", ", operation.Parameters.Select(x => x.Name.ToCamelCase() + (x.TypeReference.IsNullable ? "?" : "") + ": " + Types.Get(x.TypeReference, "{0}[]"))));
 }
 private HttpVerb GetHttpVerb(ProxyOperationModel operation)
 {
     return(Enum.TryParse(operation.MappedOperation.GetHttpSettings().Verb().Value, out HttpVerb verbEnum) ? verbEnum : HttpVerb.POST);
 }