Class: DOF::Responses::RequestResponse
- Inherits:
-
Object
- Object
- DOF::Responses::RequestResponse
- Defined in:
- lib/DOF/responses/request_response.rb
Constant Summary collapse
- NO_ERROR_CODE =
200
Instance Attribute Summary collapse
-
#indicators ⇒ Object
readonly
Returns the value of attribute indicators.
-
#response_code ⇒ Object
readonly
Returns the value of attribute response_code.
-
#response_status ⇒ Object
readonly
Returns the value of attribute response_status.
-
#total_indicators ⇒ Object
readonly
Returns the value of attribute total_indicators.
Instance Method Summary collapse
- #build_indicator(data) ⇒ Object
-
#initialize(response) ⇒ RequestResponse
constructor
A new instance of RequestResponse.
- #parse_response(response) ⇒ Object
- #successful? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ RequestResponse
Returns a new instance of RequestResponse.
11 12 13 |
# File 'lib/DOF/responses/request_response.rb', line 11 def initialize(response) parse_response(response) end |
Instance Attribute Details
#indicators ⇒ Object (readonly)
Returns the value of attribute indicators.
6 7 8 |
# File 'lib/DOF/responses/request_response.rb', line 6 def indicators @indicators end |
#response_code ⇒ Object (readonly)
Returns the value of attribute response_code.
7 8 9 |
# File 'lib/DOF/responses/request_response.rb', line 7 def response_code @response_code end |
#response_status ⇒ Object (readonly)
Returns the value of attribute response_status.
8 9 10 |
# File 'lib/DOF/responses/request_response.rb', line 8 def response_status @response_status end |
#total_indicators ⇒ Object (readonly)
Returns the value of attribute total_indicators.
9 10 11 |
# File 'lib/DOF/responses/request_response.rb', line 9 def total_indicators @total_indicators end |
Instance Method Details
#build_indicator(data) ⇒ Object
24 25 26 27 28 |
# File 'lib/DOF/responses/request_response.rb', line 24 def build_indicator(data) data.each do |indicator| @indicators << Responses::IndicatorResponse.new(indicator) end end |
#parse_response(response) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/DOF/responses/request_response.rb', line 15 def parse_response(response) @response_code = response["messageCode"] @response_status = response["response"] @total_indicators = response["TotalIndicadores"] @indicators = [] build_indicator(response["ListaIndicadores"]) end |
#successful? ⇒ Boolean
30 31 32 |
# File 'lib/DOF/responses/request_response.rb', line 30 def successful? @response_code == NO_ERROR_CODE end |