Sha256: 352369cabb1944bb39bf427d0743f3118cec728795e1c633fae406101754dcdd
Contents?: true
Size: 517 Bytes
Versions: 3
Compression:
Stored size: 517 Bytes
Contents
# ApiClient::Parser provides a method to parse the request response. module ApiClient::Parser # Parse the JSON response. # # @param [HTTP] response HTTP object for the request. # @return [Array] the code and the body parsed. def _response(response) begin body = JSON.parse(response.body) root_node = name.split('::').last.downcase object = body.key?(root_node) ? body[root_node] : body rescue JSON::ParserError object = nil end return response.code, object end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
api-client-1.4.1 | lib/api-client/parser.rb |
api-client-1.4.0 | lib/api-client/parser.rb |
api-client-1.3.0 | lib/api-client/parser.rb |