class UnitHosting::Api::Base
Attributes
api_key[R]
instance_id[R]
server[RW]
Public Class Methods
load(instance_id) { |obj| ... }
click to toggle source
# File lib/unit-hosting/api/base.rb, line 24 def self.load(instance_id) obj = self.new.load(instance_id) yield obj if block_given? obj end
new(instance_id=nil,api_key=nil) { |self| ... }
click to toggle source
# File lib/unit-hosting/api/base.rb, line 13 def initialize(instance_id=nil,api_key=nil) @instance_id = instance_id @api_key = api_key @server = XMLRPC::Client. new_from_uri("https://cloud.unit-hosting.com/xmlrpc",nil,1000) @server.instance_variable_get(:@http). instance_variable_get(:@ssl_context). instance_variable_set(:@verify_mode, OpenSSL::SSL::VERIFY_NONE) yield self if block_given? self end
Public Instance Methods
load(instance_id)
click to toggle source
# File lib/unit-hosting/api/base.rb, line 29 def load(instance_id) load_key(UnitHosting::Api::keypath(instance_id)) end
load_key(file)
click to toggle source
# File lib/unit-hosting/api/base.rb, line 32 def load_key(file) File::open(file) do |f| xml = f.read doc = REXML::Document.new(xml) @instance_id = doc.elements[@instance_id_elm].text @api_key = doc.elements[@api_key_elm].text end self end
server_call(method,param = {})
click to toggle source
# File lib/unit-hosting/api/base.rb, line 41 def server_call(method,param = {}) param["instance_id"] = @instance_id param["api_key"] = @api_key result = @server.call(method,param) # puts @server.http_last_response.body return result end