diff --git a/lib/mantisrb/projects.rb b/lib/mantisrb/projects.rb index 71a41e0..2d581ab 100644 --- a/lib/mantisrb/projects.rb +++ b/lib/mantisrb/projects.rb @@ -134,6 +134,130 @@ def custom_fields_for(id_num) } end + + # Get a list of versions that this project has + # @param [Integer] project_id + # @return [Array] array of + # {Mantis::XSD::ProjectVersionData} objects for each version + def get_versions(project_id) + @session.response_trimmed :mc_project_get_versions, { + project_id: project_id + } + end + + # Update the version of the project + # @param [version_id] ID of the *version* of the project, not the project + # id. + # @param [Mantis::XSD::ProjectVersionData] project version data instance + def update_version(version_id, data) + @session.response_trimmed :mc_project_version_update, { + version_id: version_id, + version: data.to_s + } + end + + # Delete a version from a project + # @param [Integer] version_id id of the version instance, not the + # project_id + # @return [Boolean] true or false for success + def delete_version(version_id) + @session.response_trimmed :mc_project_version_delete, { + version_id: version_id + } + end + + + # Get a list of released versions for this project + # @param [Integer] project_id + # @return [Array] array of + # {Mantis::XSD::ProjectVersionData} + def get_released_versions(project_id) + versions_ary = @session.response_trimmed :mc_project_get_released_versions, { + project_id: project_id + } + versions_ary.map { |version| Mantis::XSD::ProjectVersionData.new version } + end + + # Get the unreleased versions that belong to a project + # @param [Integer] project_id + # @return [Array] array of + # ProjectVersionData + def get_unreleased_versions(project_id) + versions_ary = @session.response_trimmed :mc_project_get_unreleased_versions, { + project_id: project_id + } + versions_ary.map { |version| Mantis::XSD::ProjectVersionData.new version } + end + + # Get all attachments (information) for a given project + # @param [Integer] project_id + # @return [Array] array of project + # attachment data + def get_attachments(project_id) + attachments = @session.response_trimmed :mc_project_get_attachments, { + project_id: project_id + } + attachments.map { |attachment| Mantis::XSD::ProjectAttachmentData.new attachment } + end + + # Get the data for an attachment for this project + # @param [Integer] project_attachment_id id of the attachment in the + # project + # @return [Base64] Base64 encoded data of the file + def get_attachment(project_attachment_id) + @session.response_trimmed :mc_project_attachment_get, { + project_attachment_id: project_attachment_id + } + end + + # Add an attachment to a project + # @param [Integer] project_id + # @param [String] name filename + # @param [String] title Descriptive Title for the file + # @param [String] description + # @param [String] file_type + # @param [Base64] content Base64 encoded data representation + # @return [Integer] id of the attachment for reference later + def add_attachment(project_id, name, title, description, file_type, content) + @session.response_trimmed :mc_project_attachment_add, { + project_id: project_id, + name: name, + title: title, + description: description, + file_type: file_type, + content: content + } + end + + # Delete an attachment for a project + # @param [Integer] project_attachment_id + # @return [Boolean] successful deletion or failure + def delete_attachment(project_attachment_id) + @session.response_trimmed :mc_project_attachment_delete, { + project_attachment_id: project_attachment_id + } + end + + # Get all Sub Projects in a project + # @param [Integer] project_id + # @return [Array] list of projects + def get_all_subprojects(project_id) + @session.response_trimmed :mc_project_get_all_subprojects, { + project_id: project_id + } + end + + # Get the value for the specified user preference + # @param [Integer] project_id + # @param [String] pref_name name of the preference to get + # @return [String] + def get_user_preference(project_id, pref_name) + @session.response_trimmed :mc_user_pref_get_pref, { + project_id: project_id, + pref_name: pref_name + } + end + private # The SOAP response from MantisConnect is an array of diff --git a/lib/mantisrb/xsd/doc_builder.rb b/lib/mantisrb/xsd/doc_builder.rb index cc40bbb..6625223 100644 --- a/lib/mantisrb/xsd/doc_builder.rb +++ b/lib/mantisrb/xsd/doc_builder.rb @@ -15,8 +15,10 @@ module Mantis::XSD::DocBuilder "tns:IssueHeaderData" => Mantis::XSD::IssueHeaderData, "tns:IssueNoteData" => Mantis::XSD::IssueNoteData, "tns:ObjectRef" => Mantis::XSD::ObjectRef, + "tns:ProjectAttachmentData" => Mantis::XSD::ProjectAttachmentData, "tns:ProjectData" => Mantis::XSD::ProjectData, - "tns:RelationshipData" => Mantis::XSD::RelationshipData + "tns:ProjectVersionData" => Mantis::XSD::ProjectVersionData + "tns:RelationshipData" => Mantis::XSD::RelationshipData, } # Create a new instance of the XSD type diff --git a/lib/mantisrb/xsd/project_attachment_data.rb b/lib/mantisrb/xsd/project_attachment_data.rb new file mode 100644 index 0000000..bc6d5bc --- /dev/null +++ b/lib/mantisrb/xsd/project_attachment_data.rb @@ -0,0 +1,29 @@ +module Mantis::XSD + + class ProjectAttachmentData + + include Mantis::XSD::DocBuilder + + attr_accessor :id, :filename, :title, :description, :size, + :content_type, :date_submitted, :download_url, :user_id + + + # Creates a Nokogiri::XML::Element object out of this class + def to_doc(tag_filename) + builder = Nokogiri::XML::Builder.new { |xml| + xml.send(tag_filename, type: "tns:ProjectAttachmentData") do + xml.id_ @id unless @id == nil + xml.filename @name unless @name == nil + xml.title @project_id unless @project_id == nil + xml.description @description unless @description == nil + xml.size @description unless @description == nil + xml.content_type @description unless @description == nil + xml.date_submitted @description unless @description == nil + xml.download_url @description unless @description == nil + xml.user_id @description unless @description == nil + end + } + builder.doc + end # to_doc + end # ProjectData +end # Mantis::XSD diff --git a/lib/mantisrb/xsd/project_version_data.rb b/lib/mantisrb/xsd/project_version_data.rb new file mode 100644 index 0000000..177645c --- /dev/null +++ b/lib/mantisrb/xsd/project_version_data.rb @@ -0,0 +1,27 @@ +module Mantis::XSD + + class ProjectVersionData + + include Mantis::XSD::DocBuilder + + attr_accessor :id, :name, :project_id, :date_order, :description, + :released, :obsolete + + + # Creates a Nokogiri::XML::Element object out of this class + def to_doc(tag_name) + builder = Nokogiri::XML::Builder.new { |xml| + xml.send(tag_name, type: "tns:ProjectVersionData") do + xml.id_ @id unless @id == nil + xml.name @name unless @name == nil + xml.project_id @project_id unless @project_id == nil + xml.date_order @date_order unless @date_order == nil + xml.description @description unless @description == nil + xml.released @released unless @released == nil + xml.obsolete @obsolete unless @obsolete == nil + end + } + builder.doc + end # to_doc + end # ProjectData +end # Mantis::XSD diff --git a/lib/mantisrb/xsd/relationship_data.rb b/lib/mantisrb/xsd/relationship_data.rb index 01e1a2d..6c1c953 100644 --- a/lib/mantisrb/xsd/relationship_data.rb +++ b/lib/mantisrb/xsd/relationship_data.rb @@ -11,12 +11,11 @@ class RelationshipData # Mantis servers. it's not provided out-of-the-box # for the SOAP API, but unless a new type has been defined, # this should get you somewhere. - DEFAULT_TYPES = { - 2: "parent of", - 3: "child of", - 0: "duplicate of", - 4: "has duplicate", - 1: "related to" + DEFAULT_TYPES = { 2 => "parent of", + 3 => "child of", + 0 => "duplicate of", + 4 => "has duplicate", + 1 => "related to" } def to_doc(tag_name)