Method: SparkApi::ApiResponse#initialize
- Defined in:
- lib/spark_api/response.rb
#initialize(d, request_id = nil) ⇒ ApiResponse
Returns a new instance of ApiResponse.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/spark_api/response.rb', line 23 def initialize d, request_id=nil begin self.d = d[MAGIC_D] if self.d.nil? || self.d.empty? raise InvalidResponse, "The server response could not be understood" end self. = self.d[MESSAGE] self.code = self.d[CODE] self.results = Array(self.d[RESULTS]) self.success = self.d[SUCCESS] self.pagination = self.d[PAGINATION] self.details = self.d[DETAILS] || [] self.errors = self.d[ERRORS] self.sparkql_errors = self.d[SPARKQL_ERRORS] self.request_id = request_id super(results) rescue Exception => e SparkApi.logger.error "Unable to understand the response! #{d}" raise end end |