Class: Mantis

Inherits:
Object
  • Object
show all
Defined in:
lib/mantis.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, password, url) ⇒ Mantis

Returns a new instance of Mantis.



2
3
4
5
6
7
8
9
# File 'lib/mantis.rb', line 2

def initialize (user, password, url)
    @client = Savon::Client.new do |wdsl|
        wdsl.document = url
    end
    @client.wsdl.endpoint = url
    @user = user
    @password = password
end

Instance Method Details

#add_note(issue_id, text, time_tracking) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mantis.rb', line 25

def add_note (issue_id, text, time_tracking)
    user = @user
    password = @password
    begin
        res = @client.request "mc_issue_note_add" do 
            soap.body = {
                "username" => user,
                "password" => password,
                "issue_id" => issue_id,
                "note" => {
                    "text" => text,
                    "view_state" => {
                        "name" => "private",
                        "id"   => 50,
                        :order! => ["name", "id"]
                    },
                    "time_tracking" => time_tracking,
                    :order! => ["text", "view_state", "time_tracking"]
                },
                :order! => ["username","password","issue_id","note"]
            }
        end
    rescue Savon::Error
        puts "ERROR Logging " + issue_id + " " + text
    end
end

#issue_exists(issue_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mantis.rb', line 11

def issue_exists (issue_id)
    user = @user
    password = @password
    issue = @client.request "mc_issue_exists" do 
        soap.body = <<XML 
<username>#{user}</username>
<password>#{password}</password>
<issue_id>#{issue_id}</issue_id>
XML
    end

    issue.to_hash[:mc_issue_exists_response][:return]
end