Class: IBMCloudSdkCore::DetailedResponse
- Inherits:
-
Object
- Object
- IBMCloudSdkCore::DetailedResponse
- Defined in:
- lib/ibm_cloud_sdk_core/detailed_response.rb
Overview
Custom class for objects returned from API calls
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status: nil, headers: nil, body: nil, response: nil) ⇒ DetailedResponse
constructor
A new instance of DetailedResponse.
Constructor Details
#initialize(status: nil, headers: nil, body: nil, response: nil) ⇒ DetailedResponse
Returns a new instance of DetailedResponse.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ibm_cloud_sdk_core/detailed_response.rb', line 9 def initialize(status: nil, headers: nil, body: nil, response: nil) if status.nil? || headers.nil? || body.nil? @status = response.code @headers = response.headers.to_h @headers = response.headers.to_hash if response.headers.respond_to?("to_hash") @result = response.body.to_s @result = JSON.parse(response.body.to_s) if !response.body.to_s.empty? && @headers.key?("Content-Type") && @headers["Content-Type"].start_with?("application/json") else @status = status @headers = headers @result = body end end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/ibm_cloud_sdk_core/detailed_response.rb', line 8 def headers @headers end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/ibm_cloud_sdk_core/detailed_response.rb', line 8 def result @result end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/ibm_cloud_sdk_core/detailed_response.rb', line 8 def status @status end |