lib/wcc/contentful/simple_client/response.rb in wcc-contentful-1.2.0 vs lib/wcc/contentful/simple_client/response.rb in wcc-contentful-1.2.1
- old
+ new
@@ -4,13 +4,11 @@
class WCC::Contentful::SimpleClient
class Response
include ::WCC::Contentful::Instrumentation
- attr_reader :raw_response
- attr_reader :client
- attr_reader :request
+ attr_reader :raw_response, :client, :request
delegate :status, to: :raw_response
alias_method :code, :status
delegate :headers, to: :raw_response
@@ -24,11 +22,11 @@
alias_method :to_json, :raw
def error_message
parsed_message =
begin
- raw.dig('message')
+ raw['message']
rescue JSON::ParserError
nil
end
parsed_message || "#{code}: #{raw_response.body}"
end
@@ -103,10 +101,10 @@
page_items.first
end
def includes
@includes ||=
- raw.dig('includes')&.each_with_object({}) do |(_t, entries), h|
+ raw['includes']&.each_with_object({}) do |(_t, entries), h|
entries.each { |e| h[e.dig('sys', 'id')] = e }
end || {}
end
end