Class: EnomRuby::Client
- Inherits:
-
Object
- Object
- EnomRuby::Client
- Includes:
- HTTParty
- Defined in:
- lib/enom-ruby/client.rb
Class Attribute Summary collapse
-
.password ⇒ Object
Returns the value of attribute password.
-
.test_mode ⇒ Object
(also: test?)
Returns the value of attribute test_mode.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.base_uri ⇒ Object
Enom has a test platform and a production platform.
- .configure {|_self| ... } ⇒ Object
-
.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.
9 10 11 |
# File 'lib/enom-ruby/client.rb', line 9 def password @password end |
.test_mode ⇒ Object Also known as: test?
Returns the value of attribute test_mode.
9 10 11 |
# File 'lib/enom-ruby/client.rb', line 9 def test_mode @test_mode end |
.username ⇒ Object
Returns the value of attribute username.
9 10 11 |
# File 'lib/enom-ruby/client.rb', line 9 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.
24 25 26 27 |
# File 'lib/enom-ruby/client.rb', line 24 def base_uri subdomain = test? ? 'resellertest' : 'reseller' "https://#{subdomain}.enom.com/interface.asp" end |
.configure {|_self| ... } ⇒ Object
12 13 14 |
# File 'lib/enom-ruby/client.rb', line 12 def configure yield self end |
.default_params ⇒ Object
All requests must contain the UID, PW, and ResponseType query parameters
17 18 19 |
# File 'lib/enom-ruby/client.rb', line 17 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.
32 33 34 35 36 37 38 39 |
# File 'lib/enom-ruby/client.rb', line 32 def request(params = {}) response = get(base_uri, query: params.merge(default_params)) if Integer(response["interface_response"]["ErrCount"]).zero? return response["interface_response"] else raise InterfaceError, response["interface_response"]["errors"].values.join(", ") end end |