Skip to content

Commit

Permalink
preparing release
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault Poncelet committed May 8, 2012
1 parent 5558975 commit 9f84168
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/ovh_savoni/soapi.rb
@@ -1,10 +1,12 @@
class OvhSavoni::SoAPI
# Store WDSL path and soap client as class instance methods
@wsdl_path = File.expand_path("../../soapi-re-1.35.wsdl" , __FILE__)
# Provide class accessors
class << self; attr_accessor :wsdl_path,:soap; end
class << self
attr_accessor :wsdl_path, :soap
end
# Initialize soap connection
@soap = Savon::Client.new{ wsdl.document = OvhSavoni::SoAPI.wsdl_path }
# Store WDSL path and soap client as class instance variable
@wsdl_path = File.expand_path("../../soapi-re-1.35.wsdl" , __FILE__)

# Initialize the class structure on the basis of the WSDL file
# Meta definition of one method for each action
Expand All @@ -19,7 +21,6 @@ class << self; attr_accessor :wsdl_path,:soap; end
rescue Savon::SOAP::Fault => e
raise OvhSavoni::Error.new(e.message)
end

OvhSavoni::ResponseBuilder.build(r,action)
end
end
Expand All @@ -31,6 +32,7 @@ def initialize(logins, lang=:en)
@sms_account = logins[:sms_account]
@sms_user = logins[:sms_user]
@sms_password= logins[:sms_password]
#Connect if login infos provided
if @nichandle && @password
@session = self.login(:nic=>@nichandle,:password=>@password,:lang=>lang.to_s)
end
Expand All @@ -41,7 +43,6 @@ def initialize(logins, lang=:en)
def request(method, params,second=false)
begin
opts = set_opts(method,params,second)

params.each do |k, v|
opts[k] = v
if v.is_a?(Array)
Expand All @@ -67,7 +68,7 @@ def request(method, params,second=false)
# Set default ops with ones defined at instanciation
def set_opts(method,params,wrong_order=false)
opts={}
if !@session.nil?
if params[:session].nil? && !@session.nil?
opts[:session] = @session
end
if params[:sms_account].nil? && !@sms_account.nil? && sms_request(method)
Expand All @@ -77,7 +78,7 @@ def set_opts(method,params,wrong_order=false)
if params[:login].nil? && !@sms_user.nil?
opts[:login] = @sms_user
end
if params[:password].nil? && !@sms_password.nil? && sms_user_request(method)
if params[:password].nil? && !@sms_password.nil?
opts[:password] = @sms_password
end
# Monkey patch to handle different order of parameters in smsUser methods
Expand Down

0 comments on commit 9f84168

Please sign in to comment.