lib/akamai_ccu/response.rb in akamai_ccu-1.5.8 vs lib/akamai_ccu/response.rb in akamai_ccu-1.5.9

- old
+ new

@@ -1,16 +1,14 @@ -require "logger" require "time" module AkamaiCCU class Response BAD_STATUS = 400 attr_reader :body, :title, :status, :detail, :support_id, :purge_id, :decribed_by, :completion_at - def initialize(body: {}, time: Time.now, logger: Logger.new(nil)) - @logger = logger + def initialize(body, time = Time.now) @body = parse(body) @title = @body["title"] @status = @body.fetch("httpStatus") { @body.fetch("status", BAD_STATUS) } @detail = @body["detail"] @support_id = @body.fetch("supportId") { @body["requestId"] } @@ -37,9 +35,9 @@ private def parse(body) return body if body.is_a? Hash JSON.parse(body) rescue JSON::ParserError => e - @logger.error { "reponse parse error: #{e.message}" } + { "detail"=>e.message } end end end