Пример #1
0
        private SharpEntityResults <T> GetAllPaginated <T>(string entityName, string pageNumber = "1") where T : SharpEntity
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("page", pageNumber);

            SharpEntityResults <T> result = GetMultiple <T>(entityName, parameters);

            result.nextPageNo     = String.IsNullOrEmpty(result.next) ? null : GetQueryParameters(result.next)["page"];
            result.previousPageNo = String.IsNullOrEmpty(result.previous) ? null : GetQueryParameters(result.previous)["page"];

            return(result);
        }
Пример #2
0
        private SharpEntityResults <T> GetMultiple <T>(string endpoint, Dictionary <string, string> parameters) where T : SharpEntity
        {
            string serializedParameters = "";

            if (parameters != null)
            {
                serializedParameters = "?" + SerializeDictionary(parameters);
            }

            string json = Request(string.Format("{0}{1}{2}", apiUrl, endpoint, serializedParameters), HttpMethod.GET);
            SharpEntityResults <T> swapiResponse = JsonConvert.DeserializeObject <SharpEntityResults <T> >(json);

            return(swapiResponse);
        }
Пример #3
0
        /// <summary>
        /// get all the vehicle resources
        /// </summary>
        public SharpEntityResults <Vehicle> GetAllVehicles(string pageNumber = "1")
        {
            SharpEntityResults <Vehicle> result = GetAllPaginated <Vehicle>("/vehicles/", pageNumber);

            return(result);
        }
Пример #4
0
        /// <summary>
        /// get all the starship resources
        /// </summary>
        public SharpEntityResults <Starship> GetAllStarships(string pageNumber = "1")
        {
            SharpEntityResults <Starship> result = GetAllPaginated <Starship>("/starships/", pageNumber);

            return(result);
        }
Пример #5
0
        /// <summary>
        /// get all the specie resources
        /// </summary>
        public SharpEntityResults <Specie> GetAllSpecies(string pageNumber = "1")
        {
            SharpEntityResults <Specie> result = GetAllPaginated <Specie>("/species/", pageNumber);

            return(result);
        }
Пример #6
0
        /// <summary>
        /// get all the planet resources
        /// </summary>
        public SharpEntityResults <Planet> GetAllPlanets(string pageNumber = "1")
        {
            SharpEntityResults <Planet> result = GetAllPaginated <Planet>("/planets/", pageNumber);

            return(result);
        }
Пример #7
0
        /// <summary>
        /// get all the film resources
        /// </summary>
        public SharpEntityResults <Film> GetAllFilms(string pageNumber = "1")
        {
            SharpEntityResults <Film> result = GetAllPaginated <Film>("/films/", pageNumber);

            return(result);
        }
Пример #8
0
        /// <summary>
        /// get all the people resources
        /// </summary>
        public SharpEntityResults <People> GetAllPeople(string pageNumber = "1")
        {
            SharpEntityResults <People> result = GetAllPaginated <People>("/people/", pageNumber);

            return(result);
        }