Class: Enom::Client
Class Attribute Summary collapse
-
.password ⇒ Object
Returns the value of attribute password.
-
.test ⇒ Object
(also: test?)
Returns the value of attribute test.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.base_uri ⇒ Object
Enom has a test platform and a production platform.
-
.default_params ⇒ Object
All requests must contain the UID, PW, and ResponseType query parameters.
-
.request(params = {}) ⇒ Object
All requests to Enom are GET requests, even when we“re changing data.
Class Attribute Details
.password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/enom/client.rb', line 7 def password @password end |
.test ⇒ Object Also known as: test?
Returns the value of attribute test.
7 8 9 |
# File 'lib/enom/client.rb', line 7 def test @test end |
.username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/enom/client.rb', line 7 def username @username end |
Class Method Details
.base_uri ⇒ Object
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_params ⇒ Object
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 |