Skip to content
This repository has been archived by the owner on Jul 24, 2018. It is now read-only.

Commit

Permalink
fill out more issue data
Browse files Browse the repository at this point in the history
Finding that most of the Mantis features are just not implemented fully in
MantisConnect has led me to think that testing from here on out will probably
not matter much anyway, since I can't get a full coverage of the features in Mantis
as it is.

I'll probably regroup on this later, but right now I wnat to get the features I can
out there and accessible, since the API is regular enough that I can hope that
people would fumble around with it anyway (sorry for them, but I'd rather it work
if you know what you're after than not work at all).
  • Loading branch information
klauern committed Sep 19, 2011
1 parent ea35b33 commit 3b04dfe
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -132,6 +132,10 @@ issue:
session.issues.checkin(issue_id, comment, completed?) # defaults to false
```

There are a number of other features that you can manipulate through the API,
so check out the documentation for more. See {Mantis::Issues} for more
information on the other types (relationships, attachments, etc.)

Filters
-------
Filters are Mantis' way of saving a configured search. You likely know what
Expand Down
6 changes: 6 additions & 0 deletions lib/mantisrb/config.rb
Expand Up @@ -74,6 +74,12 @@ def custom_field_types
@custom_field_types ||= @session.response_trimmed :mc_enum_custom_field_types
end

def enum_get(type)
@session.response_trimmed :mc_enum_get, {
enumeration: type
}
end

# instead of writing an individual <some_config_type>_for(value), create
# a meta-method that will just retrieve the actual ObjectRef for the type
# and the known value for it.
Expand Down
61 changes: 60 additions & 1 deletion lib/mantisrb/issues.rb
Expand Up @@ -106,9 +106,10 @@ def checkin(issue_id, comment, fixed=false)
end

def add_note(issue_id, note_data)
note_data = Mantis::XSD::IssueNoteData.new(note_data) if note_data.class == Hash
@session.response_trimmmed :mc_issue_note_add, {
issue_id: issue_id,
note: note_data.to_s
note: note.to_s
}
end

Expand All @@ -119,11 +120,69 @@ def delete_note(issue_note_id)
end

def update_note(note)
note = Mantis::XSD::IssueNoteData.new(note) if note.class == Hash
@session.response_trimmed :mc_issue_note_update, {
note: note
}
end

# Add a relationship to an issue.
# @param [Integer] issue id of the issue
# @param [Mantis::XSD::RelationshipData] relationship Relationship
# information
# @return [Integer] id of the relationship
def add_relationship(issue_id, relationship)
@session.response_trimmed :mc_issue_relationship_add, {
issue_id: issue_id,
relationship: relationship.to_s
}
end

# Delete an issue relationship (can be done from either side of the issue)
# @param [Integer] issue_id
# @param [Integer] relationship_id
# @return [Boolean] succes or failure
def delete_relationship(issue_id, relationship_id)
@session.response_trimmed :mc_issue_relationship_delete, {
issue_id: issue_id,
relationship_id: relationship_id
}
end

# Add an attachment to an issue
# @param [Integer] issue_id
# @param [String] name name of the file
# @param [String] file_type
# @param [Base64] data a Base64 encoded binary data representation of the
# attachment
# @return [Integer] attachment id to reference
def add_attachment(issue_id, name, file_type, data)
@session.response_trimmed :mc_issue_attachment_add, {
issue_id: issue_id,
name: name,
file_type: file_type,
content: data
}
end

# Delete an attachment
# @param [Integer] attachment_id
# @return [Boolean] success or failure
def delete_attachment(attachment_id)
@session.response_trimmed :mc_issue_attachment_delete, {
issue_attachment_id: attachment_id
}
end

# Get an attachment
# @param [Integer] attachment_id id of the attachment
# @return [Base64] Base64 encoded data representation of the file
def get_attachment(attachment_id)
@session.response_trimmed :mc_issue_attachment_get, {
issue_attachment_id: attachment_id
}
end

private

# User will pass in the name of a param, and this method will retrieve all
Expand Down
13 changes: 13 additions & 0 deletions lib/mantisrb/xsd/relationship_data.rb
Expand Up @@ -6,6 +6,19 @@ class RelationshipData

attr_accessor :id, :type, :target_id

# If you don't know what the id or type should be,
# these are some defaults that are installed on most
# 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"
}

def to_doc(tag_name)
builder = Nokogiri::XML::Builder.new { |xml|
xml.send(tag_name, type: "tns:RelationshipData") do
Expand Down

0 comments on commit 3b04dfe

Please sign in to comment.