public static async Task <DJCollectionsRoot> GetCollections() { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("api-key", (string)AppDataService.LoadLocalSetting(Settings.apiKey)); var uri = new Uri(API.Host + API.London + API.Home + API.Collections); var res = await client.GetAsync(uri); var s = await res.Content.ReadAsStringAsync(); var r = JsonConvert.DeserializeObject <DJCollectionsRoot>(s); return(r); }
public static async Task <DJStoryRoot> LoadStory(string StoryID) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("api-key", (string)AppDataService.LoadLocalSetting(Settings.apiKey)); var uri = new Uri(API.Host + API.London + API.Stories + "/" + StoryID); var res = await client.GetAsync(uri); var s = await res.Content.ReadAsStringAsync(); var r = JsonConvert.DeserializeObject <DJStoryRoot>(s); Debug.WriteLine("Loaded Story " + r.story.name + "ID: " + r.story.id); return(r); }
public static async Task <DJUserRoot> LoginTemp() { HttpClient client = new HttpClient(); var uri = new Uri(API.Host + API.Users + "/temporary"); var res = await client.PostAsync(uri, new StringContent(string.Empty)); var s = await res.Content.ReadAsStringAsync(); var r = JsonConvert.DeserializeObject <DJUserRoot>(s); AppDataService.SaveLocalSetting(Settings.apiKey, r.user.api_key); Debug.WriteLine("Logged in as temporary user - API key = " + r.user.api_key); return(r); }
public static async Task <DJLocationSuccess> SetLocation(double lat, double lon) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("api-key", (string)AppDataService.LoadLocalSetting(Settings.apiKey)); var q = new QueryString { { "lat", lat.ToString() }, { "long", lon.ToString() } }; var uri = new Uri(API.Host + API.Locations + q); var res = await client.GetAsync(uri); var s = await res.Content.ReadAsStringAsync(); var r = JsonConvert.DeserializeObject <DJLocationSuccess>(s); return(r); }