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

Commit

Permalink
Added parameter to set the safe_mode flag for the session
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier committed Dec 18, 2009
1 parent 8decfc3 commit 2c465c4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/gandi/session.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
module Gandi

class Session
HOST = "https://api.gandi.net/xmlrpc/"

attr_reader :handler, :session_id

def initialize(login, password, host)
@login = login
@password = password
@host = host
def initialize(login, password, host, safe_mode = true)
@login = login
@password = password
@host = host
@safe_mode = safe_mode
end

def connect
@handler = XMLRPC::Client.new2(@host)
@session_id = call("login", @login, @password)
@session_id = call("login", @login, @password, @safe_mode)
end
alias login connect

Expand All @@ -30,13 +32,15 @@ def method_missing(method, *args)
raise NoMethodError, "method #{method} is not available in the GANDI API."
end
end


# Accepted arguments are:
# :host, :login, :password and :safe_mode (defaults to true)
def self.connect(*args)
config = { :host => HOST }.merge(args.extract_options!)
config = { :host => HOST, :safe_mode => true }.merge(args.extract_options!)
unless config[:login] && config[:password]
raise ArgumentError, "login and password needed"
end
client = self.new(config[:login], config[:password], config[:host])
client = self.new(config[:login], config[:password], config[:host], config[:safe_mode])
client.connect
return client
end
Expand Down

0 comments on commit 2c465c4

Please sign in to comment.