Class: MxHero::API::Response

Inherits:
Struct
  • Object
show all
Defined in:
lib/response.rb

Overview

The class that contains the response information

The code represent the HTTP code of the response.

The msg represent a hash with the response information. Example:

{ status: 500, code: 500,
  developerMessage: "rules.already.exists.for.component",
  moreInfoUrl: "mailto:[email protected]" }

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



16
17
18
# File 'lib/response.rb', line 16

def code
  @code
end

#msgObject Also known as: content

Returns the value of attribute msg

Returns:

  • (Object)

    the current value of msg



16
17
18
# File 'lib/response.rb', line 16

def msg
  @msg
end

Instance Method Details

#errorString

Returns the error message.

Returns:

  • (String)

    the error message



24
25
26
# File 'lib/response.rb', line 24

def error
  content[:developerMessage] if content.is_a? Hash
end

#success?Boolean

Response is successful? Based in HTTP status code

Returns:

  • (Boolean)


19
20
21
# File 'lib/response.rb', line 19

def success?
  code.to_i == 200 || code.to_i == 201
end