Class: Gandi::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/gandi/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, options = {}) ⇒ Session

Returns a new instance of Session.


308
309
310
311
312
313
314
315
316
# File 'lib/gandi/session.rb', line 308

def initialize(api_key, options = {})
  endpoint = options.is_a?(Hash) ? (ENDPOINT[options[:env]] || ENDPOINT[:production]) : options

  @api_key  = api_key
  @server = XMLRPC::Client.new2(endpoint)
  # fix a bug in ruby 2.0, http://bugs.ruby-lang.org/issues/8182
  @server.http_header_extra = { "accept-encoding" => "identity" }
  @server
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object


330
331
332
# File 'lib/gandi/session.rb', line 330

def method_missing(method, *args)
  ProxyCall.new(@server, self.api_key).send(method, *args)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key


306
307
308
# File 'lib/gandi/session.rb', line 306

def api_key
  @api_key
end

Instance Method Details

#list_methodsObject


318
319
320
# File 'lib/gandi/session.rb', line 318

def list_methods
  server.call('system.listMethods')
end

#method_help(name) ⇒ Object


326
327
328
# File 'lib/gandi/session.rb', line 326

def method_help(name)
  server.call('system.methodHelp', name)
end

#method_signature(name) ⇒ Object


322
323
324
# File 'lib/gandi/session.rb', line 322

def method_signature(name)
  server.call('system.methodSignature', name)
end