Example #1
0
 private ParameterContract[] Parameters()
 {
     ParameterContract[] parameters =
     {
         ParameterContract.Create("petId", ParameterType.NUMBER.ToString())
     };
     return(parameters);
 }
Example #2
0
        private RequestContract Request()
        {
            RequestContract request = new RequestContract();

            request.Headers = new ParameterContract[] {
                ParameterContract.Create("Ocp-Apim-Subscription-Key", ParameterType.STRING.ToString())
            };
            request.QueryParameters = new ParameterContract[] {
                ParameterContract.Create("filter", ParameterType.STRING.ToString())
            };
            return(request);
        }
 private ParameterContract BuildParameter(BodyParameter p)
 {
     if (p != null)
     {
         string type = "string";
         if (p.Schema != null && p.Schema.Type != null)
         {
             type = p.Schema.Type;
         }
         return(ParameterContract.Create(p.Name, type, p.Description, null, p.Required));
     }
     return(null);
 }
            private ParameterContract BuildParameter(NonBodyParameter p)
            {
                if (p != null)
                {
                    string defaultValue = (p.Default != null) ? p.Default.ToString() : null;
                    string description  = (p.Format != null) ? "format - " + p.Format + ". " : "";
                    description += p.Description;

                    if (p.Type == "array")
                    {
                        if (p.Items != null && p.Items.Type != null)
                        {
                            description = "array " + p.Items.Type + ". " + description;
                        }
                    }

                    return(ParameterContract.Create(p.Name, p.Type, description, defaultValue, p.Required));
                }
                return(null);
            }
            // Ex. URL = ?username={username}&pasword={password}
            private string BuildQueryUrl()
            {
                StringBuilder builder = new StringBuilder();

                for (int i = 0; i < _queryParameters.Count; i++)
                {
                    ParameterContract p = _queryParameters.ElementAt(i);

                    if (i == 0)
                    {
                        builder.Append("?");
                    }
                    else
                    {
                        builder.Append("&");
                    }

                    builder.Append(p.Name).Append("={").Append(p.Name).Append("}");
                }
                return(builder.ToString());
            }
Example #6
0
        public void UpdateOperationParameter()
        {
            string apiId       = _apiId;
            string operationId = _operationId;

            APIOperation       entity = Client.GetAPIOperationAsync(apiId, operationId).Result;
            APIOperationHelper helper = new APIOperationHelper(entity);


            List <ParameterContract> parameters = new List <ParameterContract>();

            parameters.Add(ParameterContract.Create("account", "uuid"));
            parameters.Add(ParameterContract.Create("subscription", "uuid"));

            entity.UrlTemplate        = APIOperationHelper.BuildURL("/get", parameters);
            entity.TemplateParameters = parameters.ToArray();

            var task = Client.UpdateAPIOperationAsync(apiId, operationId, entity);

            task.Wait();
        }
Example #7
0
        public void UpdateOperationParameter()
        {
            string apiId       = "api_b8aad5c90425479c9e50c2513bfbc804";
            string operationId = "operation_be5ecb981a0d43678ae492502c925047";

            APIOperation       entity = Client.GetAPIOperationAsync(apiId, operationId).Result;
            APIOperationHelper helper = new APIOperationHelper(entity);


            List <ParameterContract> parameters = new List <ParameterContract>();

            parameters.Add(ParameterContract.Create("account", "uuid"));
            parameters.Add(ParameterContract.Create("subscription", "uuid"));

            entity.UrlTemplate        = APIOperationHelper.BuildURL("/get", parameters);
            entity.TemplateParameters = parameters.ToArray();

            var task = Client.UpdateAPIOperationAsync(apiId, operationId, entity);

            task.Wait();
        }