/// <summary> /// Builds the API URL and Sends a request to the NHTSA Database about the requested VIN. /// </summary> /// <param name="vin">The VIN to post from the UI.</param> /// <returns>Returns the deserialized json data. Needs to be parsed befor actual use.</returns> public static async Task <VINModel> GetVinFlatAsync(string vin) { string fullUrl; // Building the URL if (!string.IsNullOrEmpty(vin)) { fullUrl = $"{VinApiGetUrl}{vin}{VINDecodeOneFormatJson}"; } else { throw new Exception("Vin is null or empty."); } // The response from the APIClient using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(fullUrl)) { if (response.IsSuccessStatusCode) { // Awaits the response then deserializes the data. return(JsonController.ConvertStringToObject <VINModel>(await response.Content.ReadAsStringAsync())); } else { throw new Exception(response.ReasonPhrase); } } }