Class: Enom::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/enom/client.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/enom/client.rb', line 7

def password
  @password
end

.testObject Also known as: test?

Returns the value of attribute test.



7
8
9
# File 'lib/enom/client.rb', line 7

def test
  @test
end

.usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/enom/client.rb', line 7

def username
  @username
end

Class Method Details

.base_uriObject

Enom has a test platform and a production platform. Both are configured to use HTTPS at all times. Don“t forget to configure permitted IPs (in both environments) or you”ll get InterfaceErrors.



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

def base_uri
  @base_uri = test? ? "https://resellertest.enom.com/interface.asp" : "https://reseller.enom.com/interface.asp"
end

.default_paramsObject

All requests must contain the UID, PW, and ResponseType query parameters



11
12
13
# File 'lib/enom/client.rb', line 11

def default_params
  { "UID" => self.username, "PW" => self.password, "ResponseType" => "xml"}
end

.request(params = {}) ⇒ Object

All requests to Enom are GET requests, even when we“re changing data. Unfortunately, Enom also does not provide HTTP status codes to alert for authentication failures or other helpful statuses – everything comes back as a 200.



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

def request(params = {})
  params.merge!(default_params)
  response = get(base_uri, :query => params)
  case response.code
  when 200
    if response["interface_response"]["ErrCount"] == "0"
      return response
    else
      raise InterfaceError, response["interface_response"]["errors"].values.join(", ")
    end
  end
end