Skip to content

Commit

Permalink
issues.add + issues.add_note working with savon2
Browse files Browse the repository at this point in the history
  • Loading branch information
ronald committed Oct 17, 2014
1 parent 9a527fa commit 43e0f96
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 81 deletions.
158 changes: 91 additions & 67 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,97 +6,121 @@ PATH
bundler
log4r
nokogiri (~> 1.6.0)
savon
savon (~> 2.0)

GEM
remote: http://rubygems.org/
specs:
akami (1.0.0)
akami (1.2.2)
gyoku (>= 0.4.0)
builder (2.1.2)
coderay (0.9.8)
diff-lcs (1.1.3)
docile (1.1.1)
ffi (1.0.9)
ffi (1.0.9-x86-mingw32)
nokogiri
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
diff-lcs (1.2.5)
docile (1.1.5)
ffi (1.9.6)
ffi (1.9.6-x86-mingw32)
formatador (0.2.5)
growl (1.0.3)
guard (0.6.3)
thor (~> 0.14.6)
guard-minitest (0.4.0)
guard (~> 0.4)
guard-rake (0.0.1)
guard (2.6.1)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
guard-minitest (2.3.2)
guard (~> 2.0)
minitest (>= 3.0)
guard-rake (0.0.9)
guard
rake
gyoku (0.4.4)
gyoku (1.1.1)
builder (>= 2.1.2)
httpi (0.9.5)
hitimes (1.2.2)
httpi (2.2.7)
rack
listen (2.7.11)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
log4r (1.1.10)
metaclass (0.0.1)
method_source (0.6.5)
ruby_parser (>= 2.0.5)
mini_portile (0.5.2)
minitest (2.6.0)
mocha (0.10.0)
lumberjack (1.0.9)
macaddr (1.7.1)
systemu (~> 2.6.2)
metaclass (0.0.4)
method_source (0.8.2)
mini_portile (0.6.0)
minitest (5.4.2)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.8.2)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
nokogiri (1.6.1-x86-mingw32)
mini_portile (~> 0.5.0)
nori (1.0.2)
pry (0.9.5)
coderay (>= 0.9.8)
method_source (>= 0.6.5)
ruby_parser (>= 2.0.5)
slop (~> 2.1.0)
pry (0.9.5-x86-mingw32)
coderay (>= 0.9.8)
method_source (>= 0.6.5)
ruby_parser (>= 2.0.5)
slop (~> 2.1.0)
win32console (>= 1.3.0)
rack (1.3.2)
rake (0.9.2)
rb-fchange (0.0.5)
multi_json (1.10.1)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
nokogiri (1.6.3.1-x86-mingw32)
mini_portile (= 0.6.0)
nori (2.4.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry (0.10.1-x86-mingw32)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
win32console (~> 1.3)
rack (1.5.2)
rake (10.3.2)
rb-fchange (0.0.6)
ffi
rb-fsevent (0.4.3.1)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rb-notifu (0.0.4)
rdiscount (1.6.8)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
ruby_parser (2.3.0)
sexp_processor (~> 3.0)
savon (0.9.7)
akami (~> 1.0)
rdiscount (2.1.7.1)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
savon (2.7.2)
akami (~> 1.2.0)
builder (>= 2.1.2)
gyoku (>= 0.4.0)
httpi (~> 0.9)
gyoku (~> 1.1.0)
httpi (~> 2.2.3)
nokogiri (>= 1.4.0)
nori (~> 1.0)
wasabi (~> 2.0)
nori (~> 2.4.0)
uuid (~> 2.3.7)
wasabi (~> 3.3.0)
savon_spec (0.1.6)
mocha (>= 0.9.8)
rspec (>= 2.0.0)
savon (>= 0.8.0)
sexp_processor (3.0.6)
simplecov (0.8.2)
simplecov (0.9.1)
docile (~> 1.1.0)
multi_json
multi_json (~> 1.0)
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (2.1.0)
thor (0.14.6)
wasabi (2.0.0)
slop (3.6.0)
systemu (2.6.4)
thor (0.19.1)
timers (4.0.1)
hitimes
uuid (2.3.7)
macaddr (~> 1.0)
wasabi (3.3.1)
httpi (~> 2.0)
nokogiri (>= 1.4.0)
win32console (1.3.0-x86-mingw32)
yard (0.7.2)
win32console (1.3.2-x86-mingw32)
yard (0.8.7.4)

PLATFORMS
ruby
Expand Down
7 changes: 3 additions & 4 deletions lib/mantisrb/issues.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ def checkin(issue_id, comment, fixed=false)
# @param [Mantis::XSD::IssueNoteData] note_data
# @return [Integer] the issue_note_id that you created
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, {
@session.response_trimmed :mc_issue_note_add, {
:issue_id => issue_id,
:note => note.to_s,
:order! => [:issue_note_id, :note]
:note => note_data,
:order! => [:issue_id, :note]
}
end

Expand Down
17 changes: 8 additions & 9 deletions lib/mantisrb/session.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Mantis module that is the base for all {::Configs}, {::Session}'s, and
# {::Projects} and {::Filters}
module Mantis

# A Session is how you will perform requests to Mantis through the SOAP API.
#
# To create a session, simply pass in the URL to the Mantis server, username,
Expand All @@ -15,7 +15,7 @@ module Mantis
# From here, you can use your session to get access to the other parts of the
# Mantis API, such as Filters, Configs, Issues and Projects.
class Session

attr_reader :connection
# By default, Mantis ships with MantisConnect at
# "/api/soap/mantisconnect.php", with the WSDL endpoint being "?wsdl".
SOAP_API = "/api/soap/mantisconnect.php?wsdl"
Expand All @@ -26,13 +26,14 @@ class Session
# @param [String] user
# @param [String] pass
def initialize(url, user, pass, http_user=nil, http_pass=nil)
if !url.include?('/api/')
url += SOAP_API
end
@url = url
@user = user
@pass = pass
@connection = Savon::Client.new do
wsdl.document = sanitize_api_url(url)
http.proxy = ENV['http_proxy'] if ENV['http_proxy']
http.auth.basic(http_user, http_pass) if http_user && http_pass
@connection = Savon.client(wsdl: url, pretty_print_xml: true) do
convert_request_keys_to :none
end
end

Expand All @@ -43,9 +44,7 @@ def initialize(url, user, pass, http_user=nil, http_pass=nil)
# wrapped into <key>value</key> so nesting is encouraged.
# @return [Hash] Raw response back from Mantis converted from XML to Hash.
def response(request, params={})
@connection.request request do
soap.body = add_credentials(params)
end
@connection.call request, :message=>add_credentials(params)
end

# Create a trimmed response from Mantis. Mantis will generate alot of
Expand Down
2 changes: 1 addition & 1 deletion mantisrb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "nokogiri", "~> 1.6.0"
s.add_runtime_dependency "bundler"
s.add_runtime_dependency "builder", ">= 2.1.2"
s.add_runtime_dependency "savon"
s.add_runtime_dependency "savon", "~> 2.0"
s.add_runtime_dependency "log4r"
end

0 comments on commit 43e0f96

Please sign in to comment.