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.
25 26 27 28 |
# File 'lib/enom-ruby/client.rb', line 25 def base_uri subdomain = test? ? 'resellertest' : 'reseller' "https://#{subdomain}.enom.com/interface.asp" end |
.configure {|_self| ... } ⇒ Object
12 13 14 15 |
# File 'lib/enom-ruby/client.rb', line 12 def configure yield self self end |
.default_params ⇒ Object
All requests must contain the UID, PW, and ResponseType query parameters
18 19 20 |
# File 'lib/enom-ruby/client.rb', line 18 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.
33 34 35 36 37 38 39 40 |
# File 'lib/enom-ruby/client.rb', line 33 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 response["interface_response"]["errors"].values.join(", ") end end |