Class: EnomAPI::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/enom-api/interface.rb

Overview

Interface proxy for the eNom Reseller API

Constant Summary collapse

VERSION =

Version of the Interface class, sent with the HTTP requests

'0.1.0'

Instance Method Summary collapse

Constructor Details

#initialize(user, passwd, server = 'reseller.enom.com') ⇒ Interface

Returns a new instance of Interface.

Parameters:

  • user (String)

    eNom Account Login ID

  • passwd (String)

    eNom Account Password

  • server (String) (defaults to: 'reseller.enom.com')

    Server to connect to



12
13
14
15
# File 'lib/enom-api/interface.rb', line 12

def initialize(user, passwd, server = 'reseller.enom.com')
  @user, @passwd = user, passwd
  @uri = URI.parse('https://%s/interface.asp' % server)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, options = {}) ⇒ String

Returns XML Body of the response.

Parameters:

  • meth (Symbol)

    API command to execute

  • options (Hash) (defaults to: {})

    POST data to send to the API

Returns:

  • (String)

    XML Body of the response



28
29
30
# File 'lib/enom-api/interface.rb', line 28

def method_missing(meth, options = {})
  send_request(options.merge(:command => meth.to_s, :responseType => 'xml'))
end

Instance Method Details

#search {|q| ... } ⇒ String

Returns XML Body of the Search Query results.

Yields:

  • (q)

    Search query block

Yield Parameters:

Returns:

  • (String)

    XML Body of the Search Query results



20
21
22
23
# File 'lib/enom-api/interface.rb', line 20

def search
  q = yield SearchQuery.new
  send_request(q.to_post_data)
end