Esempio n. 1
0
        /// <summary>
        /// Get All Makes from the NHTSA <seealso cref="https://vpic.nhtsa.dot.gov/api/vehicles/getallmakes?format=XML"/>.
        /// </summary>
        /// <returns><see cref="Schema.AllVehicleMakes.GetAllVehicleMakes"/> for the NHTSA API.</returns>
        public static Schema.GetAllVehicleMakes GetAllMakes()
        {
            const string Method = "getallmakes";

            string url       = string.Join(string.Empty, VehicleAPI, Method, "?" + Format);
            string pathToXML = DownloadXML(url);

            return(SerializeConfig <Schema.GetAllVehicleMakes> .DeserializeUsingXmlSerializer(pathToXML));
        }
Esempio n. 2
0
        /// <summary>
        /// Get all manufacturers from the NHTSA. <seealso cref="https://vpic.nhtsa.dot.gov/api/vehicles/getallmanufacturers?format=XML&amp;page=2"/>
        /// </summary>
        /// <returns><see cref="Schema.GetModelsForMake"/> for the NHTSAAPI.</returns>
        public static Schema.GetModelsForMake GetAllManufacturers()
        {
            const string Method = "getallmanufacturers";

            // TODO: Deal with the pages
            // TODO: Update the Return Type
            string url       = string.Join(string.Empty, VehicleAPI, Method, "?" + Format);
            string pathToXML = DownloadXML(url);

            return(SerializeConfig <Schema.GetModelsForMake> .DeserializeUsingXmlSerializer(pathToXML));
        }
Esempio n. 3
0
        /// <summary>
        /// Get Models for a Make and Year from the NHTSA. <seealso cref="https://vpic.nhtsa.dot.gov/api/vehicles/getmodelsformake/honda?format=xml"/>
        /// </summary>
        /// <param name="make">The Make that you want models for.</param>
        /// <returns><see cref="Schema.ModelsForMake.Response"/> for the NHTSAAPI.</returns>
        public static Schema.GetModelsForMake GetModels(string make)
        {
            const string Method = "getmodelsformake";

            if (string.IsNullOrWhiteSpace(make))
            {
                throw new ArgumentException("The parameter for the make cannot be an empty string.", nameof(make));
            }

            string url       = string.Join(string.Empty, VehicleAPI, Method, "/" + make, "?" + Format);
            string pathToXML = DownloadXML(url);

            return(SerializeConfig <Schema.GetModelsForMake> .DeserializeUsingXmlSerializer(pathToXML));
        }
Esempio n. 4
0
        /// <summary>
        /// Get Models for a Make and Year from the NHTSA <seealso cref="https://vpic.nhtsa.dot.gov/api/vehicles/GetModelsForMakeId/440?format=xml"/>.
        /// </summary>
        /// <param name="makeId">The Make ID that you want Models for.</param>
        /// <returns><see cref="Schema.ModelsForMakeId.Response"/> for the NHTSAAPI.</returns>
        public static Schema.GetModelsForMake GetModels(int makeId)
        {
            const string Method = "GetModelsForMakeId";

            if (makeId < 0)
            {
                throw new ArgumentException("The parameter for the makeId must be greather than 0.", nameof(makeId));
            }

            string url       = string.Join(string.Empty, VehicleAPI, Method, "/" + makeId, "?" + Format);
            string pathToXML = DownloadXML(url);

            return(SerializeConfig <Schema.GetModelsForMake> .DeserializeUsingXmlSerializer(pathToXML));
        }
Esempio n. 5
0
        /// <summary>
        /// Get Models for a Make and Year from the NHTSA. <seealso cref="https://vpic.nhtsa.dot.gov/api/vehicles/getmodelsformakeyear/make/honda/modelyear/2015?format=xml"/>
        /// </summary>
        /// <param name="make">The Make that you want models for.</param>
        /// <param name="year">The year of models.</param>
        /// <returns><see cref="Schema.ModelsForMakeYear.Response"/> for the NHTSAAPI.</returns>
        public static Schema.GetMakeModels GetModels(string make, int year)
        {
            const string Method = "getmodelsformakeyear";

            const int MinimumYear = 1879;
            int       nextYear    = DateTime.Now.Year + 1;

            if (string.IsNullOrWhiteSpace(make))
            {
                throw new ArgumentException("The parameter for the make cannot be an empty string.", nameof(make));
            }
            else if (year < MinimumYear || year > nextYear)
            {
                throw new ArgumentException(string.Format("The parameter for the year must be between {0} and {1}.", MinimumYear, nextYear), nameof(year));
            }

            string url       = string.Join(string.Empty, VehicleAPI, Method, "/make/" + make, "/modelyear/" + year, "?" + Format);
            string pathToXML = DownloadXML(url);

            return(SerializeConfig <Schema.GetMakeModels> .DeserializeUsingXmlSerializer(pathToXML));
        }