Class: Wavefront::Type::Status
- Inherits:
-
Object
- Object
- Wavefront::Type::Status
- Defined in:
- lib/wavefront-sdk/response.rb
Overview
An object which provides information about whether the request was successful or not. Ordinarily this is easy to construct from the API’s JSON response, but some classes, for instance Wavefront::Write fake it by constructing their own.
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
The HTTP response code from the API request.
-
#message ⇒ String
readonly
Any informational message from the API.
-
#result ⇒ OK, ERROR
readonly
A string telling us how the request went.
Instance Method Summary collapse
-
#initialize(raw, status) ⇒ Status
constructor
A new instance of Status.
Constructor Details
#initialize(raw, status) ⇒ Status
Returns a new instance of Status.
75 76 77 78 79 80 81 |
# File 'lib/wavefront-sdk/response.rb', line 75 def initialize(raw, status) obj = raw.key?(:status) ? raw[:status] : raw @result = obj[:result] || nil @message = obj[:message] || nil @code = obj[:code] || status end |
Instance Attribute Details
#code ⇒ Integer (readonly)
Returns the HTTP response code from the API request.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/wavefront-sdk/response.rb', line 69 class Status attr_reader :result, :message, :code # @param raw [Hash] the API response, turned into a hash # @param status [Integer] HTTP status code # def initialize(raw, status) obj = raw.key?(:status) ? raw[:status] : raw @result = obj[:result] || nil @message = obj[:message] || nil @code = obj[:code] || status end end |
#message ⇒ String (readonly)
Returns Any informational message from the API.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/wavefront-sdk/response.rb', line 69 class Status attr_reader :result, :message, :code # @param raw [Hash] the API response, turned into a hash # @param status [Integer] HTTP status code # def initialize(raw, status) obj = raw.key?(:status) ? raw[:status] : raw @result = obj[:result] || nil @message = obj[:message] || nil @code = obj[:code] || status end end |
#result ⇒ OK, ERROR (readonly)
Returns a string telling us how the request went.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/wavefront-sdk/response.rb', line 69 class Status attr_reader :result, :message, :code # @param raw [Hash] the API response, turned into a hash # @param status [Integer] HTTP status code # def initialize(raw, status) obj = raw.key?(:status) ? raw[:status] : raw @result = obj[:result] || nil @message = obj[:message] || nil @code = obj[:code] || status end end |