Class: Buzz::Api::ApiBase
- Inherits:
-
Object
- Object
- Buzz::Api::ApiBase
- Defined in:
- lib/buzz/api_base.rb
Instance Method Summary collapse
- #get_key ⇒ Object
-
#initialize(server, username, password) ⇒ ApiBase
constructor
A new instance of ApiBase.
- #make_call(method_name, *args) ⇒ Object
Constructor Details
#initialize(server, username, password) ⇒ ApiBase
Returns a new instance of ApiBase.
8 9 10 11 12 13 |
# File 'lib/buzz/api_base.rb', line 8 def initialize(server, username, password) @server = server @username = username @password = password @spacewalk = XMLRPC::Client.new(@server, "/rpc/api", 80) end |
Instance Method Details
#get_key ⇒ Object
15 16 17 18 |
# File 'lib/buzz/api_base.rb', line 15 def get_key @key = @spacewalk.call("auth.login", @username, @password) unless @key @key end |
#make_call(method_name, *args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/buzz/api_base.rb', line 20 def make_call(method_name, *args) begin if ( args.length == 0 ) response = @spacewalk.call(method_name, get_key ) else args.unshift(get_key) response = @spacewalk.call(method_name, *args ) end response rescue XMLRPC::FaultException => e puts "Error:" puts e.faultCode puts e.faultString end end |