private static bool FetchList(bool areFavorites, Action <List <ApiAvatar> > successCallback) { if (areFavorites) { List <ApiAvatar> avatars = new List <ApiAvatar>(); foreach (string id in FavouriteOverriding.FavouriteOverriding.GetFavouriteAvatars()) { ApiModelContainer <ApiAvatar> res = new ApiModelContainer <ApiAvatar> { OnSuccess = delegate(ApiContainer c) { avatars.Add(c.Model as ApiAvatar); if (id == FavouriteOverriding.FavouriteOverriding.GetFavouriteAvatars()[FavouriteOverriding.FavouriteOverriding.GetFavouriteAvatars().Count - 1]) { successCallback(avatars); } }, OnError = delegate(ApiContainer c) { Logger.Log("Could not fetch avatar with error - " + c.Error, DebugLevel.Always, null); } }; API.SendRequest("avatars/" + id, HTTPMethods.Get, res, null, true, true); } return(false); } return(true); }
public static void SendNotification(string targetUserId, ApiNotification.NotificationType nType, string message, Dictionary <string, object> details, Action <ApiNotification> successCallback, Action <string> errorCallback) { string value = nType.ToString().ToLower(); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["type"] = value; dictionary["message"] = message; bool flag = details != null; if (flag) { dictionary["details"] = Json.Encode(details); } ApiModelContainer <ApiNotification> apiModelContainer = new ApiModelContainer <ApiNotification>(); apiModelContainer.OnSuccess = delegate(ApiContainer c) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("[Success] " + c.Text); Console.ForegroundColor = ConsoleColor.White; }; apiModelContainer.OnError = delegate(ApiContainer c) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[Fail] " + c.Text); Console.ForegroundColor = ConsoleColor.White; }; ApiModelContainer <ApiNotification> responseContainer = apiModelContainer; VRC.Core.API.SendPostRequest("user/" + targetUserId + "/notification", responseContainer, dictionary, null); }