Example #1
0
        public async Task <VehicleLookupData> GetVehicleDataByVINAsync(string vin)
        {
            HttpResponseMessage response = await _vpicHttpClient.DecodeVINAsync(vin);

            response.EnsureSuccessStatusCode();

            VehicleAPIData data = _responseParser.ParseResponse(await response.Content.ReadAsStringAsync());

            string make      = data.Results.Single(r => r.Variable == VehicleLookupData.VariableNames.Make).Value;
            string model     = data.Results.Single(r => r.Variable == VehicleLookupData.VariableNames.Model).Value;
            string modelYear = data.Results.Single(r => r.Variable == VehicleLookupData.VariableNames.ModelYear).Value;

            var lookupData = new VehicleLookupData
            {
                Make      = make,
                Model     = model,
                ModelYear = Int32.Parse(modelYear)
            };

            return(lookupData);
        }
        public VehicleAPIData ParseResponse(string json)
        {
            VehicleAPIData data = JsonConvert.DeserializeObject <VehicleAPIData>(json);

            return(data);
        }