Class: FlexmlsApi::ApiResponse
- Inherits:
-
Array
- Object
- Array
- FlexmlsApi::ApiResponse
- Includes:
- Response
- Defined in:
- lib/flexmls_api/response.rb
Overview
Nice and handy class wrapper for the api response hash
Constant Summary
Constants included from Response
Instance Method Summary collapse
-
#initialize(d) ⇒ ApiResponse
constructor
A new instance of ApiResponse.
Methods included from Response
Constructor Details
#initialize(d) ⇒ ApiResponse
Returns a new instance of ApiResponse.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/flexmls_api/response.rb', line 51 def initialize(d) begin hash = d["D"] if hash.nil? || hash.empty? raise InvalidResponse, "The server response could not be understood" end self. = hash["Message"] self.code = hash["Code"] self.results = Array(hash["Results"]) self.success = hash["Success"] self.pagination = hash["Pagination"] self.details = hash["Details"] || [] super(results) rescue Exception => e FlexmlsApi.logger.error "Unable to understand the response! #{d}" raise end end |