public async Task <bool> CancelOrderAsync(IOrder order) { if (order?.OrderId.IsNotNullOrEmpty() != true) { return(false); } var path = $"/orders/{order?.OrderId}"; PrepareRequest(HttpMethod.Delete, path); var result = await Rest.DeleteAsync <string>(path); return(result.IsNullOrEmpty()); }
/// <summary> /// Deletes a specific requirement by its id /// </summary> /// <param name="requirementId">The id of the requirement which should be deleted</param> /// <returns>The deleted requirement</returns> public static async Task <Requirement> DeleteRequirement(int requirementId) { string url = baseUrl + "requirements/" + requirementId.ToString(); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Authorization", "Bearer " + ServiceManager.GetService <LearningLayersOidcService>().AccessToken); Response resp = await Rest.DeleteAsync(url, headers, -1, true); if (!resp.Successful) { Debug.LogError(resp.ResponseCode + ": " + resp.ResponseBody); return(null); } else { Requirement requirement = JsonUtility.FromJson <Requirement>(resp.ResponseBody); return(requirement); } }
/// <summary> /// Deletes a specific requirement by its name /// </summary> /// <param name="requirementName">The name of the requirement which should be deleted</param> /// /// <param name="projectId">The id of the project of the requirement which should be deleted</param> /// <returns>The deleted requirement</returns> public static async Task <Requirement> DeleteRequirement(string requirementName, int projectId) { Requirement[] projectRequirements = await GetProjectRequirements(projectId); int requirementId = 0; for (int i = 0; i < projectRequirements.Length; i++) { if (projectRequirements[i].Name == requirementName) { requirementId = projectRequirements[i].Id; break; } } if (requirementId == 0) { Debug.LogError("Requirement not found"); return(null); } Debug.Log(requirementId); string url = baseUrl + "requirements/" + requirementId.ToString(); Dictionary <string, string> headers = new Dictionary <string, string>(); if (ServiceManager.GetService <LearningLayersOidcService>() != null) { Debug.Log("Service not null"); } headers.Add("Authorization", "Bearer " + ServiceManager.GetService <LearningLayersOidcService>().AccessToken); Response resp = await Rest.DeleteAsync(url, headers, -1, true); if (!resp.Successful) { Debug.LogError(resp.ResponseCode + ": " + resp.ResponseBody); return(null); } else { Requirement requirement = JsonUtility.FromJson <Requirement>(resp.ResponseBody); return(requirement); } }
/// <summary> /// Uninstalls the target application on the target device /// </summary> /// <param name="appInfo">Optional cached <see cref="Microsoft.MixedReality.Toolkit.WindowsDevicePortal.ApplicationInfo"/>.</param> /// <returns>True, if uninstall was a success.</returns> public static async Task <bool> UninstallAppAsync(string packageName, DeviceInfo targetDevice, ApplicationInfo appInfo = null) { Debug.Assert(!string.IsNullOrEmpty(packageName)); if (appInfo == null) { appInfo = await GetApplicationInfoAsync(packageName, targetDevice); } if (appInfo == null) { Debug.LogWarning($"Application '{packageName}' not found"); return(false); } Debug.Log($"Attempting to uninstall {packageName} on {targetDevice.ToString()}..."); string query = $"{string.Format(InstallQuery, FinalizeUrl(targetDevice.IP))}?package={UnityWebRequest.EscapeURL(appInfo.PackageFullName)}"; var response = await Rest.DeleteAsync(query, targetDevice.Authorization); if (response.Successful) { Debug.Log($"Successfully uninstalled {packageName} on {targetDevice.ToString()}."); } else if (!response.Successful) { if (response.ResponseCode == 403 && await RefreshCsrfTokenAsync(targetDevice)) { return(await UninstallAppAsync(packageName, targetDevice)); } Debug.LogError($"Failed to uninstall {packageName} on {targetDevice.ToString()}"); Debug.LogError(response.ResponseBody); return(false); } return(true); }
/// <summary> /// Stops the target application on the target device. /// </summary> /// <param name="appInfo">Optional cached <see cref="Microsoft.MixedReality.Toolkit.WindowsDevicePortal.ApplicationInfo"/>.</param> /// <returns>true, if application was successfully stopped.</returns> public static async Task <bool> StopAppAsync(string packageName, DeviceInfo targetDevice, ApplicationInfo appInfo = null) { Debug.Assert(!string.IsNullOrEmpty(packageName)); if (appInfo == null) { appInfo = await GetApplicationInfoAsync(packageName, targetDevice); } if (appInfo == null) { Debug.LogWarning($"Application '{packageName}' not found"); return(false); } string query = $"{string.Format(AppQuery, FinalizeUrl(targetDevice.IP))}?package={UnityWebRequest.EscapeURL(appInfo.PackageFullName.EncodeTo64())}"; Response response = await Rest.DeleteAsync(query, targetDevice.Authorization); if (!response.Successful) { if (response.ResponseCode == 403 && await RefreshCsrfTokenAsync(targetDevice)) { return(await StopAppAsync(packageName, targetDevice)); } Debug.LogError(response.ResponseBody); return(false); } while (!await IsAppRunningAsync(packageName, targetDevice, appInfo)) { await new WaitForSeconds(1f); } return(true); }
/// <summary> /// Delete an existing person from a person group. All stored person data, and face images in the person entry will be deleted. /// </summary> /// <param name="personGroupId">Specifying the person group containing the person.</param> /// <param name="personId">The target personId to delete.</param> /// <returns>A successful call returns an empty response body.</returns> public static async Task DeletePersonAsync(string personGroupId, string personId) { var query = string.Format(GetPersonQuery, FaceApiClient.ResourceRegion.ToString().ToLower(), personGroupId, "/" + personId); await Rest.DeleteAsync(query, FaceApiClient.FaceApiKeyHeader); }