class AkamaiCCU::Response
Constants
- BAD_STATUS
Attributes
body[R]
completion_at[R]
decribed_by[R]
detail[R]
purge_id[R]
status[R]
support_id[R]
title[R]
Public Class Methods
new(body, time = Time.now)
click to toggle source
# File lib/akamai_ccu/response.rb, line 9 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"] } @purge_id = @body["purgeId"] @described_by = @body.fetch("describedBy") { @body["type"] } @estimated_secs = @body["estimatedSeconds"] @completion_at = time + @estimated_secs.to_i if @estimated_secs end
Public Instance Methods
successful?()
click to toggle source
# File lib/akamai_ccu/response.rb, line 21 def successful? (@status.to_i / 100) == 2 end
to_s()
click to toggle source
# File lib/akamai_ccu/response.rb, line 25 def to_s %W[status=#{@status}].tap do |a| a << "title=#{@title}" if @title a << "detail=#{@detail}" if @detail a << "support_id=#{@support_id}" if @support_id a << "purge_id=#{@purge_id}" if @purge_id a << "described_by=#{@described_by}" if @described_by a << "copletion_at=#{@completion_at}" if @completion_at end.join("; ") end
Private Instance Methods
parse(body)
click to toggle source
# File lib/akamai_ccu/response.rb, line 36 def parse(body) return body if body.is_a? Hash JSON.parse(body) rescue JSON::ParserError => e { "detail"=>e.message } end