Esempio n. 1
0
        public String GenerateCallRouteConcat(ApiServiceCall call)
        {
            if (String.IsNullOrEmpty(call.Route.Template))
            {
                return("\"" + String.Empty + "\"");
            }

            StringBuilder r = new StringBuilder();

            r.Append('"');

            foreach (var c in call.Route.Template)
            {
                if (c == '{')
                {
                    r.Append('"');
                    r.Append(" + ");
                    continue;
                }

                if (c == '}')
                {
                    r.Append(" + ");
                    r.Append('"');
                    continue;
                }

                r.Append(c);
            }

            r.Append('"');
            return(r.ToString());
        }
Esempio n. 2
0
        public string GetCallConfig(ApiServiceCall call)
        {
            var ps = call.Parameters.Where(x => x.FromQueryString != null);

            if (ps.Count() == 0)
            {
                return("{}");
            }
            return("{params: {" + string.Join(",", ps.Select(x => $"{ x.Parameter.Name}:{ x.Parameter.Name}")) + "} }");
        }
Esempio n. 3
0
        public String GetCallBodyParameter(ApiServiceCall call)
        {
            var p = call.Parameters.FirstOrDefault(x => x.FromBody != null);

            if (p != null)
            {
                return(p.Parameter.Name);
            }

            return("null");
        }
Esempio n. 4
0
        public String GenerateRESTCall(ApiServiceCall call, String routeVar, String argVar, string argCfg)
        {
            bool   hasArg   = call.HttpMethod.HttpMethods.Any(x => x == HttpMethod.Post || x == HttpMethod.Put);
            String restCall = $"Timple.http_{ call.HttpMethod.HttpMethods.First().Method.ToLower()}";

            restCall += "<" + Translator.Translate(call.ReturningType) + ">";
            restCall += "(this.$http," + routeVar;
            if (hasArg)
            {
                restCall += ", " + argVar;
            }
            restCall += "," + argCfg + ");";
            return(restCall);
        }
Esempio n. 5
0
 public String GenerateCallReturn(ApiServiceCall call)
 {
     //if (call.ReturningType == typeof(void))
     //  return String.Empty;
     return(": Promise<" + Translator.Translate(call.ReturningType) + ">");
 }
Esempio n. 6
0
 public String GenerateCallParameters(ApiServiceCall call)
 {
     return(String.Join(", ", call.Parameters.Select(x => x.Parameter.Name + ": " + Translator.Translate(x.Type))));
 }