Class: Wavefront::Type::Status
- Inherits:
-
Object
- Object
- Wavefront::Type::Status
- Defined in:
- lib/wavefront-sdk/types/status.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.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#result ⇒ OK, ERROR
readonly
A string telling us how the request went.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(response, status) ⇒ Status
constructor
A new instance of Status.
- #to_s ⇒ Object
Constructor Details
#initialize(response, status) ⇒ Status
Returns a new instance of Status.
28 29 30 31 |
# File 'lib/wavefront-sdk/types/status.rb', line 28 def initialize(response, status) @obj = response.fetch(:status, response) @status = status end |
Instance Attribute Details
#code ⇒ Integer (readonly)
Returns the HTTP response code from the API request.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/wavefront-sdk/types/status.rb', line 22 class Status attr_reader :obj, :status # @param response [Hash] the API response, turned into a hash # @param status [Integer] HTTP status code # def initialize(response, status) @obj = response.fetch(:status, response) @status = status end def to_s obj.inspect.to_s end def obj[:message] || nil end def code obj[:code] || status end def result return obj[:result] if obj[:result] return 'OK' if status.between?(200, 299) 'ERROR' end end |
#message ⇒ String (readonly)
Returns Any informational message from the API.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/wavefront-sdk/types/status.rb', line 22 class Status attr_reader :obj, :status # @param response [Hash] the API response, turned into a hash # @param status [Integer] HTTP status code # def initialize(response, status) @obj = response.fetch(:status, response) @status = status end def to_s obj.inspect.to_s end def obj[:message] || nil end def code obj[:code] || status end def result return obj[:result] if obj[:result] return 'OK' if status.between?(200, 299) 'ERROR' end end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
23 24 25 |
# File 'lib/wavefront-sdk/types/status.rb', line 23 def obj @obj end |
#result ⇒ OK, ERROR (readonly)
Returns a string telling us how the request went.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/wavefront-sdk/types/status.rb', line 22 class Status attr_reader :obj, :status # @param response [Hash] the API response, turned into a hash # @param status [Integer] HTTP status code # def initialize(response, status) @obj = response.fetch(:status, response) @status = status end def to_s obj.inspect.to_s end def obj[:message] || nil end def code obj[:code] || status end def result return obj[:result] if obj[:result] return 'OK' if status.between?(200, 299) 'ERROR' end end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
23 24 25 |
# File 'lib/wavefront-sdk/types/status.rb', line 23 def status @status end |
Instance Method Details
#to_s ⇒ Object
33 34 35 |
# File 'lib/wavefront-sdk/types/status.rb', line 33 def to_s obj.inspect.to_s end |