private void addLinkToLocalSettings(RootObjectTeams td, string comp) { int i = 0; string link = (string)td.collection.links[0].href; while(!comp.Equals((string)td.collection.links[i].rel)) { i++; } ApplicationData.Current.LocalSettings.Values[comp + "API"] = (string)td.collection.links[i].href; }
//Testing stuff. private async void Launch_Click(object sender, RoutedEventArgs e) { string resp = null; //string href = "https://api.teamsnap.com/v3/me"; string href = RunAPI.Text; String temp_token = ApplicationData.Current.LocalSettings.Values["Tokens"] as String; if (!String.IsNullOrEmpty(temp_token)) { Token.Text = "already exists " + temp_token; resp = await LibFunctions.apiCall(temp_token, href); APICallResult.Text = "Response ::: " +resp; Debug.WriteLine("Trying to serialize back"); } else { Token.Text = "No token available"; string token = await LibFunctions.GetAuth(); Token.Text = "Token : " + token; resp = await LibFunctions.apiCall(temp_token, href); } try { aboutMe = Me.meDeserializer(resp); FirstName.Text = "Teams href:"+ aboutMe.collection.items[0].links[1].href; MemoryStream stream1 = new MemoryStream(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(RootObjectMe)); ser.WriteObject(stream1, aboutMe); stream1.Position = 0; StreamReader sr = new StreamReader(stream1); Debug.WriteLine("serializing to json"); //Debug.WriteLine(sr.ReadToEnd()); SerializeOutput.Text = "aboutme in JSON :"+ sr.ReadToEnd(); } catch (Exception) { } try { //resp = await LibFunctions.apiCall(temp_token, FirstName.Text); aboutTeam = Teams.teamDeserializer(resp); //TeamsAPI.Text = "Response of teams call : " + resp; } catch (Exception) { } }