using CaritasPWA.Shared.Models; using CaritasPWA.Shared.ResourceFiles; using Json.Net; using Microsoft.Extensions.Localization; using System; using System.Collections.Generic; using System.Globalization; using System.Net.Http; using System.Threading.Tasks; namespace CaritasPWA.Shared.Services { // REST interface responsible to submit lost or found reports and get the available masterdata. public class LFBicycleRest : ILFBicycleRest { private static readonly string VERSION = "v1"; private readonly IStringLocalizer _i18n; private readonly HttpClient httpClient; public LFBicycleRest(IStringLocalizer i18n) { _i18n = i18n; this.httpClient = new HttpClient { BaseAddress = new Uri("https://integrate.dynalias.net:9443/Fundvelo/") }; } public async Task> GetColors() { try { HttpResponseMessage httpResult = await httpClient.GetAsync(string.Format("api/{0}/{1}/fundvelo/colors", VERSION, CultureInfo.CurrentCulture.TwoLetterISOLanguageName)); if (httpResult.StatusCode == System.Net.HttpStatusCode.OK) { ColorItem[] colors = JsonNet.Deserialize(await httpResult.Content.ReadAsStringAsync()); return new List(colors); } // TODO: show a warning message here } catch (Exception ex) { // TODO: show a warning message here } return new List(); } public List GetBicycleTypes() { //return Defaults.GetBicycleTypeDefaults(_i18n); return new List(); } public List GetBrands() { //return Defaults.Brands.ToList(); return new List(); } } }