// try to set the user's presence // first, try to make the user available if they're not // then, set their presence static void Presence() { if (ucwaAuthenticationResult == null) { Console.WriteLine("You haven't logged in yet!"); return; } Console.WriteLine("Please enter which presence value you want"); foreach (var v in UcwaPresence.UcwaPresenceOptions) { Console.Write(v.ToString() + " "); } Console.Write("\n"); Console.WriteLine("Presence>"); string userPresence = Console.ReadLine(); if (!UcwaPresence.UcwaPresenceOptions.Contains(userPresence, StringComparer.CurrentCultureIgnoreCase)) { Console.WriteLine("You didn't pick an option from the list"); Console.WriteLine("Enter presence if you want to try again"); return; } Console.WriteLine("MakeMeAvailable has to be called before you can set a user's presence"); Console.WriteLine("UCWA lets you set a user's presence when calling MakeMeAvailable, so we'll try it"); Console.WriteLine("We'll create a UcwaMakeMeAvailableObject that sets the user's presence as " + userPresence); UcwaMakeMeAvailable.UcwaMakeMeAvailableObject ucwaMakeMeAvailableObject = new UcwaMakeMeAvailable.UcwaMakeMeAvailableObject { signInAs = userPresence, phoneNumber = "212 867 5309" }; Console.WriteLine("createUcwaAppsResults is a JSON string containing links to all resources"); Console.WriteLine("We will parse to find MakeMeAvailable"); var ucwaMakeMeAvailableRootUri = UcwaMakeMeAvailable.GetMakeMeAvailableUri(createUcwaAppsResults, ucwaApplicationsHost); if (ucwaMakeMeAvailableRootUri != String.Empty) { if (UcwaMakeMeAvailable.MakeMeAvailable(ucwaAuthenticationResult, ucwaMakeMeAvailableRootUri, ucwaMakeMeAvailableObject)) { return; } //else //{ // Console.WriteLine("Looks like we encountered an error. Wait before trying this again"); // return; //} } Console.WriteLine("Whoops! MakeMeAvailable isn't in createUcwaAppsResults"); Console.WriteLine("The user is already available, let's simply change their presence to away"); Console.WriteLine("createUcwaAppsResults is a JSON string containing links to all resources"); Console.WriteLine("We will parse to find presence"); var ucwaPresenceRootUri = UcwaPresence.GetPresenceUri(createUcwaAppsResults, ucwaApplicationsHost); Console.WriteLine("We'll create a UcwaPresenceObject that sets the user's presence to be the same as we intended in UcwaMakeMeAvailableObject"); UcwaPresence.UcwaPresenceObject ucwaPresenceObject = new UcwaPresence.UcwaPresenceObject { availability = ucwaMakeMeAvailableObject.signInAs }; UcwaPresence.SetPresence(ucwaAuthenticationResult, ucwaPresenceRootUri, ucwaPresenceObject); #endregion }
// try to set the user's presence // first, try to make the user available if they're not // then, set their presence static void Presence() { if (ucwaAuthenticationResult == null) { Console.WriteLine("You haven't logged in yet!"); return; } Console.WriteLine("Please enter which presence value you want"); foreach(var v in UcwaPresence.UcwaPresenceOptions) { Console.Write(v.ToString() + " "); } Console.Write("\n"); Console.WriteLine("Presence>"); string userPresence = Console.ReadLine(); if (!UcwaPresence.UcwaPresenceOptions.Contains(userPresence,StringComparer.CurrentCultureIgnoreCase)) { Console.WriteLine("You didn't pick an option from the list"); Console.WriteLine("Enter presence if you want to try again"); return; } Console.WriteLine("MakeMeAvailable has to be called before you can set a user's presence"); Console.WriteLine("UCWA lets you set a user's presence when calling MakeMeAvailable, so we'll try it"); Console.WriteLine("We'll create a UcwaMakeMeAvailableObject that sets the user's presence as " + userPresence); UcwaMakeMeAvailable.UcwaMakeMeAvailableObject ucwaMakeMeAvailableObject = new UcwaMakeMeAvailable.UcwaMakeMeAvailableObject { signInAs = userPresence, phoneNumber = "212 867 5309" }; Console.WriteLine("createUcwaAppsResults is a JSON string containing links to all resources"); Console.WriteLine("We will parse to find MakeMeAvailable"); var ucwaMakeMeAvailableRootUri = UcwaMakeMeAvailable.GetMakeMeAvailableUri(createUcwaAppsResults, ucwaApplicationsHost); if (ucwaMakeMeAvailableRootUri != String.Empty) { if (UcwaMakeMeAvailable.MakeMeAvailable(httpClient, ucwaAuthenticationResult, ucwaMakeMeAvailableRootUri, ucwaMakeMeAvailableObject)) { return; } //else //{ // Console.WriteLine("Looks like we encountered an error. Wait before trying this again"); // return; //} } Console.WriteLine("Whoops! MakeMeAvailable isn't in createUcwaAppsResults"); Console.WriteLine("The user is already available, let's simply change their presence to away"); Console.WriteLine("createUcwaAppsResults is a JSON string containing links to all resources"); Console.WriteLine("We will parse to find presence"); var ucwaPresenceRootUri = UcwaPresence.GetPresenceUri(createUcwaAppsResults, ucwaApplicationsHost); Console.WriteLine("We'll create a UcwaPresenceObject that sets the user's presence to be the same as we intended in UcwaMakeMeAvailableObject"); UcwaPresence.UcwaPresenceObject ucwaPresenceObject = new UcwaPresence.UcwaPresenceObject { availability = ucwaMakeMeAvailableObject.signInAs }; UcwaPresence.SetPresence(httpClient, ucwaAuthenticationResult, ucwaPresenceRootUri, ucwaPresenceObject); #endregion }