/// <summary> /// Resets the state of the requested translation components to queued. /// </summary> /// <param name="client"><see cref="InspireClient"/> used to communication with the API endpoint.</param> /// <param name="translationComponentIds">The translation component ids to reset state to queued.</param> /// <returns>Returns a List of <see cref="MinimalTranslationJobComponentModel" /> objects.</returns> public static List <MinimalTranslationJobComponentModel> ResetTranslationComponentsState(this InspireClient client, List <long> translationComponentIds) { if (translationComponentIds == null) { throw new ArgumentNullException(nameof(translationComponentIds)); } var request = client.CreateRequest($"/Translations/Components/SetQueued", HttpMethod.Post); return(client.RequestContent <List <long>, List <MinimalTranslationJobComponentModel> >(request, translationComponentIds)); }
/// <summary> /// This method is used to return components that are stored within a specific folder matching a specific search criteria. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="folderId">Contains the folder identity to retrieve components from, pass a value of zero to retrieve all components.</param> /// <param name="inputModel">Contains the <see cref="FolderComponentsQueryModel"/> input.</param> /// <returns>Returns a <see cref="FolderComponentsResultModel"/> object if found.</returns> public static FolderComponentsResultModel FindComponentsByFolderId(this InspireClient client, long folderId, FolderComponentsQueryModel inputModel) { if (folderId < 0) { throw new ArgumentNullException(nameof(folderId)); } var request = client.CreateRequest($"/Folders/{folderId}/Components", HttpMethod.Post); return(client.RequestContent <FolderComponentsQueryModel, FolderComponentsResultModel>(request, inputModel)); }
/// <summary> /// Sets the translation job statuses for each requested <see cref="TranslationExportJobModel"/>. /// </summary> /// <param name="client"><see cref="InspireClient"/> used to communication with the API endpoint.</param> /// <param name="models">The List of <see cref="TranslationExportJobModel"/> objects used to set translation job statuses.</param> /// <returns>Returns a List of <see cref="TranslationExportJobModel" /> objects.</returns> public static List <TranslationExportJobModel> SetTranslationJobStatus(this InspireClient client, List <TranslationExportJobModel> models) { if (models == null) { throw new ArgumentNullException(nameof(models)); } var request = client.CreateRequest($"/Translations/Jobs/SetStatus", HttpMethod.Post); return(client.RequestContent <List <TranslationExportJobModel>, List <TranslationExportJobModel> >(request, models)); }
/// <summary> /// This method is used to update an existing role. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="roleId">Contains the role identity.</param> /// <param name="inputModel">Contains the <see cref="RoleModel"/> input.</param> /// <returns>Returns the updated <see cref="RoleModel"/> object.</returns> public static RoleModel UpdateRole(this InspireClient client, long roleId, RoleModel inputModel) { if (inputModel == null) { throw new ArgumentNullException(nameof(inputModel)); } var request = client.CreateRequest($"/Roles/{roleId}", HttpMethod.Put); return(client.RequestContent <RoleModel, RoleModel>(request, inputModel)); }
/// <summary> /// This method is used to update existing folder permissions. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="folderId">Contains the folder identity.</param> /// <param name="inputModel">Contains the <see cref="PermissionUpdateModel"/> input.</param> /// <returns>Returns the updated <see cref="PermissionUpdateModel"/> object.</returns> public static PermissionUpdateModel UpdateFolderPermissions(this InspireClient client, long folderId, PermissionUpdateModel inputModel) { if (inputModel == null) { throw new ArgumentNullException(nameof(inputModel)); } var request = client.CreateRequest($"/Folders/{folderId}/Permissions", HttpMethod.Put); return(client.RequestContent <PermissionUpdateModel, PermissionUpdateModel>(request, inputModel)); }
/// <summary> /// This method is used to return folder permission details. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="folderId">Contains the folder identity.</param> /// <returns>Returns a <see cref="PermissionUpdateModel"/> object if found.</returns> public static PermissionUpdateModel FindFolderPermissions(this InspireClient client, long folderId) { if (folderId <= 0) { throw new ArgumentNullException(nameof(folderId)); } var request = client.CreateRequest($"/Folders/{folderId}/Permissions"); return(client.RequestContent <PermissionUpdateModel>(request)); }
/// <summary> /// This method is used to initiate an export request and return details about the successfully submitted export request. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="targetFolderId">Contains the folder identity.</param> /// <param name="exportId">Contains the export identity value.</param> /// <param name="includeSubFolders">Contains a flag indicating whether to include subfolders or not.</param> /// <returns>Returns a <see cref="ExportRequestModel"/> object if found.</returns> public static ExportRequestModel ExportFolder(this InspireClient client, long targetFolderId, long exportId = 0, bool includeSubFolders = false) { if (targetFolderId <= 0) { throw new ArgumentNullException(nameof(targetFolderId)); } var request = client.CreateRequest($"/Folders/{targetFolderId}/Export/{exportId}/?includeSubFolders={includeSubFolders}", HttpMethod.Post); return(client.RequestContent <ExportRequestModel, ExportRequestModel>(request, new ExportRequestModel())); }
/// <summary> /// Finds the translation integrations. /// </summary> /// <param name="client">The client.</param> /// <param name="model">The model.</param> /// <returns>Returns a <see cref="TranslationIntegrationBrowseResultModel"/> object containing the results of the query.</returns> /// <exception cref="ArgumentNullException">model</exception> public static TranslationIntegrationBrowseResultModel FindTranslationIntegrations(this InspireClient client, TranslationIntegrationBrowseQueryModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = client.CreateRequest($"/TranslationIntegrations/Query", HttpMethod.Post); return(client.RequestContent <TranslationIntegrationBrowseQueryModel, TranslationIntegrationBrowseResultModel>(request, model)); }
/// <summary> /// This method is used to move a source folder to a target folder. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="sourceFolderId">Contains the source folder identity.</param> /// <param name="targetFolderId">Contains the target folder identity to which to move this folder to.</param> /// <returns>Returns a <see cref="FolderBrowseModel"/> object if found.</returns> public static FolderBrowseModel MoveFolder(this InspireClient client, long sourceFolderId, long targetFolderId) { if (sourceFolderId <= 0 && targetFolderId <= 0) { throw new ArgumentNullException(nameof(sourceFolderId)); } var request = client.CreateRequest($"/Folders/{sourceFolderId}/Move/{targetFolderId}"); return(client.RequestContent <FolderBrowseModel>(request)); }
/// <summary> /// This method is used to create a new project. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="inputModel">Contains the <see cref="ProjectModel"/> input.</param> /// <returns>Returns the <see cref="ProjectModel"/> object if found.</returns> public static ProjectModel CreateProject(this InspireClient client, ProjectModel inputModel) { if (inputModel == null) { throw new ArgumentNullException(nameof(inputModel)); } var request = client.CreateRequest($"/Projects", HttpMethod.Post); return(client.RequestContent <ProjectModel, ProjectModel>(request, inputModel)); }
/// <summary> /// Finds the translation jobs for the requested translation job Ids. /// </summary> /// <param name="client"><see cref="InspireClient"/> used to communication with the API endpoint.</param> /// <param name="translationJobIds">The translation job ids.</param> /// <returns>Returns a List of the requested <see cref="MinimalTranslationJobModel" /> objects.</returns> public static List <MinimalTranslationJobModel> FindTranslationJobs(this InspireClient client, List <long> translationJobIds) { if (translationJobIds == null) { throw new ArgumentNullException(nameof(translationJobIds)); } var request = client.CreateRequest($"/Translations/RetrieveTranslationJobs", HttpMethod.Post); return(client.RequestContent <List <long>, List <MinimalTranslationJobModel> >(request, translationJobIds)); }
/// <summary> /// This method is used to update an existing user. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="userId">Contains the user identity.</param> /// <param name="inputModel">Contains the <see cref="UserModel"/> input.</param> /// <returns>Returns the updated <see cref="UserModel"/> object.</returns> public static UserModel UpdateUser(this InspireClient client, long userId, UserModel inputModel) { if (inputModel == null) { throw new ArgumentNullException(nameof(inputModel)); } var request = client.CreateRequest($"/Users/{userId}", HttpMethod.Put); return(client.RequestContent <UserModel, UserModel>(request, inputModel)); }
/// <summary> /// Cancels a Translation Job. /// </summary> /// <param name="client"><see cref="InspireClient"/> used to communication with the API endpoint.</param> /// <param name="model">The <see cref="TranslationJobModel"/> used to Cancel the Translation Job.</param> /// <returns>Returns the <see cref="TranslationJobModel" /> object that was canceled.</returns> public static TranslationJobModel PutTranslationCancel(this InspireClient client, TranslationJobModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = client.CreateRequest($"/Translations/{model.TranslationJobId}/Cancel", HttpMethod.Put); return(client.RequestContent <TranslationJobModel, TranslationJobModel>(request, model)); }
/// <summary> /// This method is used to rename an existing folder. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="folderId">Contains the folder identity.</param> /// <param name="inputModel">Contains the <see cref="FolderBrowseModel"/> input.</param> /// <returns>Returns the renamed <see cref="FolderBrowseModel"/> object.</returns> public static FolderBrowseModel RenameFolder(this InspireClient client, long folderId, FolderBrowseModel inputModel) { if (inputModel == null) { throw new ArgumentNullException(nameof(inputModel)); } var request = client.CreateRequest($"/Folders/{folderId}/Rename", HttpMethod.Put); return(client.RequestContent <FolderBrowseModel, FolderBrowseModel>(request, inputModel)); }
/// <summary> /// This method is used to return a list of folders that are children of the specified parent folder. /// If parent folder is not specified, a list of root folders will be returned. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="folderId">Contains the folder identity to retrieve child folders from, pass a value of zero to retrieve all folders.</param> /// <param name="includeAllDescendantFolders">Contains a value to indicate whether or not to include all descendant folders.</param> /// <param name="permissionFlag">Contains an optional <see cref="PermissionFlags"/> that will be used to filter the results of the query.</param> /// <returns>Returns a list of <see cref="FolderBrowseModel"/> objects if found.</returns> public static List <FolderBrowseModel> FindFoldersByFolderId(this InspireClient client, long folderId, bool includeAllDescendantFolders, PermissionFlags permissionFlag) { if (folderId < 0) { throw new ArgumentNullException(nameof(folderId)); } var request = client.CreateRequest($"/Folders/{folderId}?allDescendants={includeAllDescendantFolders}&permissionFlag={permissionFlag}"); return(client.RequestContent <List <FolderBrowseModel> >(request)); }
/// <summary> /// This method is used to return a list of folders including the specified folder, /// its ancestor folders, and corresponding sibling folders. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="folderId">Contains the folder identity.</param> /// <returns>Returns a list of <see cref="FolderBrowseModel"/> objects if found.</returns> public static List <FolderBrowseModel> FindAncestorSiblingFoldersByFolderId(this InspireClient client, long folderId) { if (folderId <= 0) { throw new ArgumentNullException(nameof(folderId)); } var request = client.CreateRequest($"/Folders/{folderId}/AncestorsSiblings"); return(client.RequestContent <List <FolderBrowseModel> >(request)); }
/// <summary> /// Creates the translation integration. /// </summary> /// <param name="client">The client.</param> /// <param name="inputModel">The input model.</param> /// <returns>Returns the new <see cref="TranslationIntegrationModel"/> object.</returns> /// <exception cref="ArgumentNullException">InputModel cannot be null.</exception> public static TranslationIntegrationModel CreateTranslationIntegration(this InspireClient client, TranslationIntegrationModel inputModel) { if (inputModel == null) { throw new ArgumentNullException(nameof(inputModel)); } var request = client.CreateRequest($"/TranslationIntegrations", HttpMethod.Post); return(client.RequestContent <TranslationIntegrationModel, TranslationIntegrationModel>(request, inputModel)); }
/// <summary> /// Processes the message received from Transport as part of a project delivery. /// </summary> /// <param name="client"><see cref="InspireClient"/> used to communication with the API endpoint.</param> /// <param name="transportProjectId">The Transport Project Id.</param> /// <returns>Returns success or failure of the operation.</returns> public static bool ProcessTransportResponse(this InspireClient client, string transportProjectId) { if (string.IsNullOrEmpty(transportProjectId)) { throw new ArgumentNullException(nameof(transportProjectId)); } var request = client.CreateRequest($"/Translations/ProcessTransportResponse/{transportProjectId}", HttpMethod.Post); return(client.RequestContent <bool>(request)); }
/// <summary> /// This method is used to delete an existing folder. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="folderId">Contains the folder identity.</param> /// <returns>Returns a boolean value indicating whether the action succeeded or not.</returns> public static bool DeleteFolder(this InspireClient client, long folderId) { if (folderId <= 0) { throw new ArgumentNullException(nameof(folderId)); } var request = client.CreateRequest($"/Folders/{folderId}", HttpMethod.Delete); client.RequestContent(request); return(client.HasError); }
/// <summary> /// Gets the translation export state. /// </summary> /// <param name="client"><see cref="InspireClient"/> used to communication with the API endpoint.</param> /// <param name="workerKey">The worker key.</param> /// <returns>Returns a <see cref="WorkerStateModel" /> of type <see cref="TranslationExportStateModel" />.</returns> public static MinimalWorkerStateModel <TranslationExportStateModel> FindTranslationExportState(this InspireClient client, string workerKey) { if (string.IsNullOrEmpty(workerKey)) { throw new ArgumentNullException(nameof(workerKey)); } string encodedWorkerKey = Uri.EscapeUriString(workerKey); var request = client.CreateRequest($"/Translations/Export/{encodedWorkerKey}/", HttpMethod.Get); return(client.RequestContent <MinimalWorkerStateModel <TranslationExportStateModel> >(request)); }
/// <summary> /// This method is used to update project participants. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="projectId">Contains the identity of the project that will have its participants updated.</param> /// <param name="models">Contains a list of <see cref="ProjectParticipantModel"/> related to the project.</param> /// <returns>Returns a list of <see cref="ProjectParticipantModel"/> objects.</returns> public static List <ProjectParticipantModel> UpdateProjectParticipants(this InspireClient client, long projectId, List <ProjectParticipantModel> models) { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (models == null) { throw new ArgumentNullException(nameof(models)); } var request = client.CreateRequest($"/Projects/{projectId}/Participants", HttpMethod.Put); return(client.RequestContent <List <ProjectParticipantModel>, List <ProjectParticipantModel> >(request, models)); }
/// <summary> /// This method is used to request an export process for one or more components. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="projectId">Contains the identity of the project.</param> /// <param name="folderId">Contains the identity of the project folder.</param> /// <param name="includeSubFolders">Contains a value indicating whether components in descendant sub-folders should be exported.</param> /// <param name="exportId">Contains the export identity.</param> /// <returns>The <see cref="ExportRequestModel"/> object with information about the export process.</returns> public static ExportRequestModel ExportComponents(this InspireClient client, long projectId, long folderId, bool includeSubFolders, long exportId = 0) { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (folderId <= 0) { throw new ArgumentNullException(nameof(folderId)); } var request = client.CreateRequest($"/Projects/{projectId}/FolderItems/{folderId}/Export/{exportId}/?includeSubFolders={includeSubFolders}", HttpMethod.Post); return(client.RequestContent <ExportRequestModel>(request)); }
/// <summary> /// This method is used to update an existing project. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="projectId">Contains the identity of the project to update.</param> /// <param name="inputModel">Contains the <see cref="ProjectModel"/> input.</param> /// <returns>Returns the updated <see cref="ProjectModel"/> object.</returns> public static ProjectModel UpdateProject(this InspireClient client, long projectId, ProjectModel inputModel) { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (inputModel == null) { throw new ArgumentNullException(nameof(inputModel)); } var request = client.CreateRequest($"/Projects/{projectId}", HttpMethod.Put); return(client.RequestContent <ProjectModel, ProjectModel>(request, inputModel)); }
/// <summary> /// This method is used to create a project folder item model. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="projectId">Contains the identity of the parent project.</param> /// <param name="model">Contains a <see cref="ProjectFolderItemModel"/> to create.</param> /// <returns>Returns the newly created <see cref="ProjectFolderItemModel"/> object.</returns> public static ProjectFolderItemModel CreateProjectFolder(this InspireClient client, long projectId, ProjectFolderItemModel model) { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = client.CreateRequest($"/Projects/{projectId}/FolderItems", HttpMethod.Post); return(client.RequestContent <ProjectFolderItemModel, ProjectFolderItemModel>(request, model)); }
/// <summary> /// This method is used to delete a project folder item model. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="projectId">Contains the identity of the parent project.</param> /// <param name="model">Contains the existing <see cref="ProjectFolderItemModel"/> to delete.</param> /// <returns>Returns a boolean value indicating whether the action succeeded or not.</returns> public static bool DeleteProjectFolder(this InspireClient client, long projectId, ProjectFolderItemModel model) { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = client.CreateRequest($"/Projects/{projectId}/FolderItems/0", HttpMethod.Delete); client.RequestContent(request, model); return(client.HasError); }
/// <summary> /// Gets the queued translation jobs. /// </summary> /// <param name="client"><see cref="InspireClient"/> used to communication with the API endpoint.</param> /// <param name="translationVendorId">The translation vendor identifier.</param> /// <returns>Returns a <see cref="WorkerStateModel" /> of type <see cref="TranslationExportStateModel" />.</returns> public static WorkerStateModel <TranslationExportStateModel> FindQueuedTranslationJobs(this InspireClient client, long translationVendorId) { if (translationVendorId <= 0) { throw new ArgumentNullException(nameof(translationVendorId)); } TranslationExportRequestModel translationExportRequestModel = new TranslationExportRequestModel { TranslationVendorId = translationVendorId, SendNotification = false }; var request = client.CreateRequest($"/Translations/Export/GetQueued/{translationVendorId}", HttpMethod.Post); return(client.RequestContent <TranslationExportRequestModel, WorkerStateModel <TranslationExportStateModel> >(request, translationExportRequestModel)); }
/// <summary> /// This method is used to delete a project assignment. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="projectId">Contains the identity of the project in which the assignment will be deleted.</param> /// <param name="projectAssignmentId">Contains the project assignment identity to delete.</param> /// <returns>Returns a boolean value indicating whether the action succeeded or not.</returns> public static bool DeleteProjectAssignment(this InspireClient client, long projectId, long projectAssignmentId) { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (projectAssignmentId <= 0) { throw new ArgumentNullException(nameof(projectAssignmentId)); } var request = client.CreateRequest($"/Projects/{projectId}/Assignments/{projectAssignmentId}", HttpMethod.Delete); client.RequestContent(request); return(client.HasError); }
/// <summary> /// This method is used to update a project assignment completion status. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="projectId">Contains the identity of the project.</param> /// <param name="projectAssignmentId">Contains the identity of the project assignment to update.</param> /// <param name="model">Contains the <see cref="ProjectAssignmentModel"/> object.</param> /// <returns>Returns the <see cref="ProjectAssignmentModel"/> object.</returns> public static ProjectAssignmentModel UpdateProjectAssignmentCompletionStatus(this InspireClient client, long projectId, long projectAssignmentId, ProjectAssignmentModel model) { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (projectAssignmentId <= 0) { throw new ArgumentNullException(nameof(projectAssignmentId)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = client.CreateRequest($"/Projects/{projectId}/Assignments/{projectAssignmentId}/State/Complete", HttpMethod.Put); return(client.RequestContent <ProjectAssignmentModel, ProjectAssignmentModel>(request, model)); }
/// <summary> /// This method is used to move a project folder to another target folder. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="model">Contains the existing project folder item model to move.</param> /// <param name="projectId">Contains the identity of the parent project.</param> /// <param name="itemId">Contains the identity of the folder item object.</param> /// <param name="targetFolderId">Contains the new target folder of the folder item.</param> /// <returns>Returns the <see cref="ProjectFolderItemModel"/> object.</returns> public static ProjectFolderItemModel MoveProjectFolder(this InspireClient client, ProjectFolderItemModel model, long projectId, string itemId, string targetFolderId = "") { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (string.IsNullOrEmpty(itemId)) { throw new ArgumentNullException(nameof(itemId)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = client.CreateRequest($"/Projects/{projectId}/FolderItems/{itemId}/Move/{targetFolderId}", HttpMethod.Put); return(client.RequestContent <ProjectFolderItemModel, ProjectFolderItemModel>(request, model)); }
/// <summary> /// This method is used to add components to an existing folder. /// </summary> /// <param name="client">Contains the <see cref="InspireClient"/> that is used for communication.</param> /// <param name="projectId">Contains the identity of the parent project.</param> /// <param name="folderId">Contains the identity of the project folder.</param> /// <param name="models">A list of <see cref="MinimalComponentModel"/> objects.</param> /// <returns>Returns a list of <see cref="MinimalComponentModel"/> objects.</returns> public static List <MinimalComponentModel> AddComponentsToFolder(this InspireClient client, long projectId, long folderId, List <MinimalComponentModel> models) { if (projectId <= 0) { throw new ArgumentNullException(nameof(projectId)); } if (folderId <= 0) { throw new ArgumentNullException(nameof(folderId)); } if (models == null) { throw new ArgumentNullException(nameof(models)); } var request = client.CreateRequest($"/Projects/{projectId}/Folders/{folderId}", HttpMethod.Post); return(client.RequestContent <List <MinimalComponentModel>, List <MinimalComponentModel> >(request, models)); }