Method: Dnsimple::Client#execute

Defined in:
lib/dnsimple/client.rb

#execute(method, path, data = nil, options = {}) ⇒ HTTParty::Response

Executes a request, validates and returns the response.

Parameters:

  • method (String)

    The HTTP method

  • path (String)

    The path, relative to #base_url

  • data (Hash) (defaults to: nil)

    The body for the request

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

    The query and header params for the request

Returns:

  • (HTTParty::Response)

Raises:



163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/dnsimple/client.rb', line 163

def execute(method, path, data = nil, options = {})
  response = request(method, path, data, options)

  case response.code
  when 200..299
    response
  when 401
    raise AuthenticationFailed, response["message"]
  when 404
    raise NotFoundError, response
  else
    raise RequestError, response
  end
end