public static void SetGroupDisplayNameAndPrivacy(GroupType groupType, string group, string displayName, string privacyLevel, Action <ApiGroup> successCallback = null, Action <string> errorCallback = null) { ApiModelContainer <ApiGroup> apiModelContainer = new ApiModelContainer <ApiGroup>(); apiModelContainer.OnSuccess = delegate(ApiContainer c) { if (successCallback != null) { successCallback(c.Model as ApiGroup); } }; apiModelContainer.OnError = delegate(ApiContainer c) { if (errorCallback != null) { errorCallback(c.Error); } }; ApiModelContainer <ApiGroup> responseContainer = apiModelContainer; Dictionary <string, object> dictionary = new Dictionary <string, object>(); if (displayName != null) { dictionary["displayName"] = displayName; } if (privacyLevel != null) { dictionary["visibility"] = privacyLevel; } API.SendPutRequest("favorite/group/" + groupType.value + "/" + group + "/" + APIUser.CurrentUser.id, responseContainer, dictionary); }
public static void AddFeedback(string contentId, int version, ContentType contentType, ApprovalType approvalType, string reason, Action <ApiFeedback> successCallback, Action <string> errorCallback) { ApiModelContainer <ApiFeedback> apiModelContainer = new ApiModelContainer <ApiFeedback>(); apiModelContainer.OnSuccess = delegate(ApiContainer c) { if (successCallback != null) { successCallback(c.Model as ApiFeedback); } }; apiModelContainer.OnError = delegate(ApiContainer c) { if (errorCallback != null) { errorCallback(c.Error); } }; ApiContainer responseContainer = apiModelContainer; Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["contentType"] = contentType.ToString(); dictionary["type"] = approvalType.ToString(); dictionary["reason"] = reason; if (contentType == ContentType.world) { API.SendPostRequest("/feedback/" + contentId + "/" + version.ToString(), responseContainer, dictionary); } else { API.SendPostRequest("/feedback/" + contentId + "/" + contentType.ToString(), responseContainer, dictionary); } }
public static void AddToGroup(string objectId, GroupType groupType, Action <ApiModelContainer <ApiFavorite> > successCallback, Action <string> errorCallback, List <string> tags = null) { ApiModelContainer <ApiFavorite> apiModelContainer = new ApiModelContainer <ApiFavorite>(); apiModelContainer.OnSuccess = delegate(ApiContainer c) { if (successCallback != null) { successCallback(c as ApiModelContainer <ApiFavorite>); } }; apiModelContainer.OnError = delegate { if (errorCallback != null) { errorCallback("Error"); } }; ApiModelContainer <ApiFavorite> responseContainer = apiModelContainer; Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["type"] = groupType.value; dictionary["favoriteId"] = objectId; if (tags != null) { dictionary["tags"] = tags; } API.SendPostRequest("favorites", responseContainer, dictionary); }
public void DeleteVersion(int versionNumber, Action <ApiContainer> successCallback = null, Action <ApiContainer> errorCallback = null) { if (!IsInitialized) { Debug.LogError((object)"Unable to delete file: file not initialized."); } else if (versionNumber <= 0 || versionNumber >= versions.Count) { Debug.LogError((object)("ApiFile(" + base.id + "): version to delete is invalid: " + versionNumber)); } else { ApiModelContainer <ApiFile> apiModelContainer = new ApiModelContainer <ApiFile>(this); apiModelContainer.OnSuccess = successCallback; apiModelContainer.OnError = errorCallback; ApiModelContainer <ApiFile> responseContainer = apiModelContainer; API.SendRequest("file/" + base.id + "/" + versionNumber, HTTPMethods.Delete, responseContainer, null, authenticationRequired: true, disableCache: true); } }
public void CreateNewVersion(Version.FileType fileType, string fileOrDeltaMd5Base64, long fileOrDeltaSizeInBytes, string signatureMd5Base64, long signatureSizeInBytes, Action <ApiContainer> successCallback, Action <ApiContainer> errorCallback) { if (!IsInitialized) { Debug.LogError((object)"Unable to create new file version: file not initialized."); } else { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["signatureMd5"] = signatureMd5Base64; dictionary["signatureSizeInBytes"] = signatureSizeInBytes; dictionary[(fileType != 0) ? "deltaMd5" : "fileMd5"] = fileOrDeltaMd5Base64; dictionary[(fileType != 0) ? "deltaSizeInBytes" : "fileSizeInBytes"] = fileOrDeltaSizeInBytes; ApiModelContainer <ApiFile> apiModelContainer = new ApiModelContainer <ApiFile>(this); apiModelContainer.OnSuccess = successCallback; apiModelContainer.OnError = errorCallback; ApiModelContainer <ApiFile> responseContainer = apiModelContainer; API.SendRequest(MakeRequestEndpoint(), HTTPMethods.Post, responseContainer, dictionary, authenticationRequired: true, Application.get_isEditor()); } }
public static void GetGroupDisplayNameAndPrivacy(string userId, GroupType groupType, string group, Action <ApiGroup> successCallback = null, Action <string> errorCallback = null) { ApiModelContainer <ApiGroup> apiModelContainer = new ApiModelContainer <ApiGroup>(); apiModelContainer.OnSuccess = delegate(ApiContainer c) { if (successCallback != null) { successCallback(c.Model as ApiGroup); } }; apiModelContainer.OnError = delegate(ApiContainer c) { if (errorCallback != null) { errorCallback(c.Error); } }; ApiModelContainer <ApiGroup> responseContainer = apiModelContainer; API.SendGetRequest("favorite/group/" + groupType.value + "/" + group + "/" + userId, responseContainer, null, disableCache: true); }
public static void PublishWorldToCommunityLabs(string worldId, Action <ApiModelContainer <ApiWorld> > successCallback, Action <string> errorCallback) { ApiModelContainer <ApiWorld> apiModelContainer = new ApiModelContainer <ApiWorld>(); apiModelContainer.OnSuccess = delegate(ApiContainer c) { if (successCallback != null) { successCallback(c as ApiModelContainer <ApiWorld>); } }; apiModelContainer.OnError = delegate(ApiContainer c) { if (errorCallback != null) { errorCallback(c.Error); } }; ApiModelContainer <ApiWorld> responseContainer = apiModelContainer; API.SendPutRequest("worlds/" + worldId + "/publish", responseContainer); }
public static void FetchFeedback(string worldId, int version, ApiFeedback.ContentType contentType, Action <ApiContentFeedback> successCallback, Action <string> errorCallback) { ApiModelContainer <ApiContentFeedback> apiModelContainer = new ApiModelContainer <ApiContentFeedback>(); apiModelContainer.OnSuccess = delegate(ApiContainer c) { ApiContentFeedback obj = c.Model as ApiContentFeedback; if (successCallback != null) { successCallback(obj); } }; apiModelContainer.OnError = delegate(ApiContainer c) { if (errorCallback != null) { errorCallback(c.Error); } }; ApiContainer responseContainer = apiModelContainer; API.SendGetRequest("/worlds/" + worldId + "/" + version + "/feedback", responseContainer, null, disableCache: true); }
public void Fetch(string instanceID = null, string platforms = null, Action <ApiContainer> onSuccess = null, Action <ApiContainer> onFailure = null, Dictionary <string, object> parameters = null, bool compatibleVersionsOnly = true) { if (string.IsNullOrEmpty(base.id)) { onFailure(new ApiContainer { Error = "APIWorld.Fetch called with null id." }); } else if (localWorlds.ContainsKey(base.id)) { ApiModelContainer <ApiWorld> obj = new ApiModelContainer <ApiWorld>(localWorlds[base.id]); onSuccess(obj); } else { if (parameters == null) { parameters = new Dictionary <string, object>(); } if (compatibleVersionsOnly) { parameters["maxUnityVersion"] = VERSION.UnityVersion; parameters["minUnityVersion"] = MIN_LOADABLE_VERSION.UnityVersion; parameters["maxAssetVersion"] = VERSION.ApiVersion; parameters["minAssetVersion"] = MIN_LOADABLE_VERSION.ApiVersion; } if (platforms != null) { parameters["platform"] = platforms; } if (!string.IsNullOrEmpty(instanceID)) { ApiDictContainer apiDictContainer = new ApiDictContainer("users"); apiDictContainer.OnSuccess = delegate(ApiContainer c) { List <object> json = (c as ApiDictContainer).ResponseDictionary["users"] as List <object>; IEnumerable <APIUser> enumerable = API.ConvertJsonListToModelList <APIUser>(json, c.DataTimestamp); if (enumerable == null) { c.Error = "Failed to decode user model"; onFailure(c); } else { int num = enumerable.Count(); if (instances == null) { instances = new Dictionary <string, int>(); } if (!mWorldInstances.Any((ApiWorldInstance w) => w.idWithTags == instanceID)) { mWorldInstances.Add(new ApiWorldInstance(this, instanceID, num)); instances.Add(instanceID, num); } ApiWorldInstance apiWorldInstance = worldInstances.First((ApiWorldInstance w) => w.idWithTags == instanceID); apiWorldInstance.count = num; apiWorldInstance.users = enumerable.ToList(); onSuccess(c); } }; apiDictContainer.OnError = onFailure; ApiDictContainer responseContainer = apiDictContainer; API.SendRequest("worlds/" + base.id + "/" + instanceID, HTTPMethods.Get, responseContainer, parameters, authenticationRequired: true, disableCache: true); } else { ApiModelContainer <ApiWorld> apiModelContainer = new ApiModelContainer <ApiWorld>(this); apiModelContainer.OnSuccess = onSuccess; apiModelContainer.OnError = onFailure; ApiModelContainer <ApiWorld> responseContainer2 = apiModelContainer; API.SendRequest("worlds/" + base.id, HTTPMethods.Get, responseContainer2, parameters, authenticationRequired: true, disableCache: true); } } }