Method: ApimaticCalculator::APIHelper.map_response
- Defined in:
- lib/apimatic_calculator/api_helper.rb
.map_response(obj, keys) ⇒ Object
Retrieves a field from a Hash/Array based on an Array of keys/indexes
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/apimatic_calculator/api_helper.rb', line 259 def self.map_response(obj, keys) val = obj begin keys.each do |key| val = if val.is_a? Array if key.to_i.to_s == key val[key.to_i] else val = nil end else val.fetch(key.to_sym) end end rescue NoMethodError, TypeError, IndexError val = nil end val end |