protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            var result = HttpExecutor.AirlineFlightSchedule(args);

            if (result.Error != null && result.Error.Type != ApiExecuteErrorType.NoData)
            {
                Errors.Add(result.Error);
            }

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(AirlineFlightSchedule));

            var rows = new List <Row>();

            if (result.Data != null && result.Error == null)
            {
                foreach (var d in result.Data)
                {
                    var row = new Row()
                    {
                        Values = ToValues(d, tableDescriptor)
                    };
                    rows.Add(row);
                }
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
        protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            //{"error":"NO_DATA unknown airline INVALID"}
            var result = HttpExecutor.AirlineInfo(args);

            if (result.Error != null && result.Error.Type != ApiExecuteErrorType.NoData)
            {
                Errors.Add(result.Error);
            }

            if (QueryArgs.ContainsVariable("airlineCode"))
            {
                result.Data.airlineCode = (string)QueryArgs["airlineCode"].PropertyValue.Value;
            }

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(AirlineInfo));

            var rows = new List <Row>();

            if (result.Error == null)
            {
                rows.Add(new Row()
                {
                    Values = ToValues(result.Data, tableDescriptor)
                });
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
Ejemplo n.º 3
0
        protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            var result = HttpExecutor.GetInFlightInfo(args);

            if (result.Error != null && result.Error.Type != ApiExecuteErrorType.NoData)
            {
                Errors.Add(result.Error);
            }

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(InFlightInfo));

            var dto  = result.Data;
            var rows = new List <Row>();

            if (result.Error == null)
            {
                rows.Add(new Row()
                {
                    Values = ToValues(dto, tableDescriptor)
                });
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
        protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            var result = HttpExecutor.AirportInfo(args);

            if (result.Error != null)
            {
                Errors.Add(result.Error);
            }

            if (QueryArgs.ContainsVariable("airportCode"))
            {
                result.Data.airportCode = (string)QueryArgs["airportCode"].PropertyValue.Value;
            }

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(AirportInfo));

            var rows = new List <Row>();

            if (result.Error == null)
            {
                rows.Add(new Row()
                {
                    Values = ToValues(result.Data, tableDescriptor)
                });
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
Ejemplo n.º 5
0
        public void ProxyPostAction <DataT>(string url,
                                            string body, Variable.Enum.ContentTypeEnum contentType, ref ApiResult <DataT> apiResult)
        {
            var httpHeaders = new Dictionary <HttpRequestHeader, string>();

            httpHeaders.Add(HttpRequestHeader.ContentType, HttpExecutor.GetContentTypesString(Variable.Enum.ContentTypeEnum.Json));
            //httpHeaders.Add(HttpRequestHeader.Authorization, Variable.FakeToken);
            var httpExecutorResult = HttpExecutor.xPost(url, body, httpHeaders);

            this.ProcessResult <DataT>(httpExecutorResult, ref apiResult);
        }
        protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            var result = HttpExecutor.GetMapFlight(args);

            if (result.Error != null && result.Error.Type != ApiExecuteErrorType.NoData)
            {
                Errors.Add(result.Error);
            }

            var dto = result.Data;

            if (QueryArgs.ContainsVariable("ident"))
            {
                dto.ident = (string)QueryArgs["ident"].PropertyValue.Value;
            }

            long mapHeight = 480;

            if (QueryArgs.ContainsVariable("mapHeight"))
            {
                mapHeight = (long)QueryArgs["mapHeight"].PropertyValue.Value;
            }

            long mapWidth = 640;

            if (QueryArgs.ContainsVariable("mapWidth"))
            {
                mapWidth = (long)QueryArgs["mapWidth"].PropertyValue.Value;
            }

            dto.mapHeight = mapHeight;
            dto.mapWidth  = mapWidth;

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(MapFlight));

            var rows = new List <Row>();

            if (result.Error == null)
            {
                rows.Add(new Row()
                {
                    Values = ToValues(dto, tableDescriptor)
                });
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
Ejemplo n.º 7
0
        private static void Main(string[] args)
        {
            const string uri = "https://raw.githubusercontent.com/jason-roberts/PSPolDemoFiles/master/SomeRemoteData.txt-";

            var retry    = new LinealPollyRetryPolicy();
            var executor = new HttpExecutor(retry);

            var tableRuleResponse = executor.Execute <string>(uri);

            Console.WriteLine("Status: {0}", tableRuleResponse.Status);
            Console.WriteLine("Message: {0}", tableRuleResponse.Messages);
            Console.WriteLine("Data: {0}", tableRuleResponse.Data);

            Console.Read();
        }
        protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            var result = HttpExecutor.GetFlightID(args);

            if (result.Error != null && result.Error.Type != ApiExecuteErrorType.NoData)
            {
                Errors.Add(result.Error);
            }

            long departerTimeValue = 0;

            if (QueryArgs.ContainsVariable("departuretime"))
            {
                departerTimeValue = (long)(QueryArgs["departuretime"].PropertyValue.Value ?? 0L);
            }

            string identValue = string.Empty;

            if (QueryArgs.ContainsVariable("ident"))
            {
                identValue = (string)QueryArgs["ident"].PropertyValue.Value;
            }

            var dto = result.Data;

            dto.departureTime = (DateTime)Conversion.ConvertLongToDateTime(departerTimeValue);
            dto.ident         = identValue;

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(GetFlightId));

            var rows = new List <Row>();

            if (result.Error == null)
            {
                rows.Add(new Row()
                {
                    Values = ToValues(dto, tableDescriptor)
                });
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
        protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            var result = HttpExecutor.GetInboundFlightInfo(args);

            //{ "error":"INVALID_ARGUMENT Inbound flight is not known"}
            //{ "error":"INVALID_ARGUMENT: invalid {faFlightID}"}
            if (result.Error != null && result.Error.Type != ApiExecuteErrorType.InvalidArgument) //don't show invalid args as errors
            {
                Errors.Add(result.Error);
            }

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(InboundFlightInfo));

            var dto = result.Data;

            dto.ifaFlightID = dto.faFlightID;

            string faFlightID = string.Empty;

            if (QueryArgs.ContainsVariable("faFlightID"))
            {
                faFlightID = (string)QueryArgs["faFlightID"].PropertyValue.Value;
            }

            dto.faFlightID = faFlightID;

            var rows = new List <Row>();

            if (result.Error == null)
            {
                rows.Add(new Row()
                {
                    Values = ToValues(dto, tableDescriptor)
                });
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
        private async Task <GraphQLDataResult <T> > ExecuteQuery <T>(GraphQLOperationType operationType, IEnumerable <GraphQLField> selectionSet, GraphQLQueryArgument[] arguments, string url, HttpMethod httpMethod, IDictionary <string, string> headers, string authorizationMethod, string authorizationToken) where T : class
        {
            // Generate query
            var requestQuery = QueryGenerator.GenerateQuery(operationType, selectionSet, arguments.ToArray());

            // Get response
            GraphQLExecutorResponse response = await HttpExecutor.ExecuteQuery(requestQuery, url, httpMethod, headers : headers, authorizationToken : authorizationToken, authorizationMethod : authorizationMethod).ConfigureAwait(false);

            // Deserilize
            var result = Deserialization.DeserializeResult <T>(response.Response, selectionSet);

            if (result?.Errors?.Any() ?? false)
            {
                throw new GraphQLErrorException(query: requestQuery, errors: result.Errors);
            }

            // Set headers
            result.Headers = response.Headers;

            return(result);
        }
Ejemplo n.º 11
0
        protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            var result = HttpExecutor.GetDeparted(args);

            if (result.Error != null && result.Error.Type != ApiExecuteErrorType.NoData)
            {
                Errors.Add(result.Error);
            }

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(Departed));

            var rows = new List <Row>();

            if (result.Data != null && result.Error == null)
            {
                foreach (var d in result.Data)
                {
                    if (QueryArgs.ContainsVariable("airport"))
                    {
                        d.airport = (string)QueryArgs["airport"].PropertyValue.Value;
                    }

                    if (QueryArgs.ContainsVariable("filter"))
                    {
                        d.filter = (string)QueryArgs["filter"].PropertyValue.Value;
                    }

                    var row = new Row()
                    {
                        Values = ToValues(d, tableDescriptor)
                    };
                    rows.Add(row);
                }
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
Ejemplo n.º 12
0
        protected override ExecutedTable ExecuteCore(HttpExecuteArg args)
        {
            //{ "error":"INVALID: invalid {faFlightID}"}
            var result = HttpExecutor.GetHistoricalTrack(args);

            if (result.Error != null && result.Error.Type != ApiExecuteErrorType.NoData)
            {
                Errors.Add(result.Error);
            }

            TableDescriptor tableDescriptor = PropertyDescriptor.GenerateRunDescriptor(typeof(GetHistoricalTrack));

            var rows = new List <Row>();

            if (result.Data != null && result.Error == null)
            {
                foreach (var d in result.Data)
                {
                    if (QueryArgs.ContainsVariable("faFlightID"))
                    {
                        d.faFlightID = (string)QueryArgs["faFlightID"].PropertyValue.Value;
                    }

                    var row = new Row()
                    {
                        Values = ToValues(d, tableDescriptor)
                    };
                    rows.Add(row);
                }
            }

            return(new ExecutedTable(tableDescriptor)
            {
                Rows = rows.ToArray()
            });
        }
Ejemplo n.º 13
0
 protected string GetResponse()
 {
     return(HttpExecutor.Get(Url));
 }