Module: Gandi

Defined in:
lib/gandi.rb,
lib/gandi/price.rb,
lib/gandi/domain.rb,
lib/gandi/contact.rb,
lib/gandi/version.rb,
lib/gandi/operation.rb,
lib/gandi/zlib_parser_decorator.rb

Defined Under Namespace

Classes: Contact, DataError, Domain, Error, Operation, Price, ServerError, ValidationError, ZlibParserDecorator

Constant Summary collapse

VERSION =
'1.0.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.apikeyObject

Returns the value of attribute apikey.



18
19
20
# File 'lib/gandi.rb', line 18

def apikey
  @apikey
end

.modeObject

Returns the value of attribute mode.



19
20
21
# File 'lib/gandi.rb', line 19

def mode
  @mode
end

Class Method Details

.call(name, *args) ⇒ Object



38
39
40
41
42
# File 'lib/gandi.rb', line 38

def call(name, *args)
  client.call(name, apikey, *args)
rescue XMLRPC::FaultException => e
  raise(e.faultCode < 500000 ? ServerError : DataError, e.faultString)
end

.clientObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gandi.rb', line 25

def client
  @client ||= begin
    XMLRPC::Config.module_eval do
      remove_const(:ENABLE_NIL_PARSER)
      const_set(:ENABLE_NIL_PARSER, true)
    end
    client = XMLRPC::Client.new2(self.endpoint)
    client.http_header_extra = {"Accept-Encoding" => "gzip"}
    client.set_parser ZlibParserDecorator.new(client.send(:parser))
    client
  end
end

.endpointObject



21
22
23
# File 'lib/gandi.rb', line 21

def endpoint
  mode == 'live' ? 'https://rpc.gandi.net/xmlrpc/' : 'https://rpc.ote.gandi.net/xmlrpc/'
end