Beispiel #1
0
        /// <summary>
        /// Gets the default list of cards or filter with a query.
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static Pokemon Get(Dictionary <string, string> query = null)
        {
            try
            {
                // Make sure this actually gets the default cards
                // from the API as described.
                query = QueryBuilderHelper.GetDefaultQuery(query);

                Pokemon pokemon = QueryBuilder.GetPokemonCards(query);
                if (pokemon == null)
                {
                    pokemon.Errors = new List <string>()
                    {
                        "Not Found"
                    };
                    return(pokemon);
                }
                else
                {
                    return(pokemon);
                }
            }
            catch (Exception ex)
            {
                Pokemon pokemon = new Pokemon();
                pokemon.Errors = new List <string>()
                {
                    ex.Message
                };
                return(pokemon);
            }
        }
        public static List <string> GetSuperTypes(Dictionary <string, string> query = null)
        {
            try
            {
                string queryString = string.Empty;
                HttpResponseMessage stringTask;
                List <string>       superTypes = new List <string>();
                query = QueryBuilderHelper.GetDefaultQuery(query);

                using (HttpClient client = QueryBuilderHelper.SetupClient())
                {
                    stringTask = QueryBuilderHelper.BuildTaskString(query, ref queryString, client, ResourceTypes.SuperTypes);
                    SuperType type = QueryBuilderHelper.CreateObject <SuperType>(stringTask);
                    superTypes.AddRange(type.Types);
                    return(superTypes);
                }
            }
            catch (Exception ex)
            {
                List <string> errors = new List <string>()
                {
                    ex.Message
                };
                return(errors);
            }
        }