Class: AkamaiApi::CLI::CCU::PurgeRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/akamai_api/cli/ccu/purge_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ PurgeRenderer

Returns a new instance of PurgeRenderer.



5
6
7
# File 'lib/akamai_api/cli/ccu/purge_renderer.rb', line 5

def initialize response
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/akamai_api/cli/ccu/purge_renderer.rb', line 3

def response
  @response
end

Instance Method Details

#renderObject



9
10
11
12
13
14
15
# File 'lib/akamai_api/cli/ccu/purge_renderer.rb', line 9

def render
  [
    "----------",
    render_response,
    "----------"
  ].join "\n"
end

#render_error_responseObject



25
26
27
28
29
30
31
# File 'lib/akamai_api/cli/ccu/purge_renderer.rb', line 25

def render_error_response
  [
    "There was an error processing your request:",
    "\t* Result: #{response.code} - #{response.title} (#{response.message})",
    "\t* Described by: #{response.described_by}"
  ]
end

#render_responseObject



17
18
19
20
21
22
23
# File 'lib/akamai_api/cli/ccu/purge_renderer.rb', line 17

def render_response
  if response.code == 201
    render_successful_response
  else
    render_error_response
  end
end

#render_successful_responseObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/akamai_api/cli/ccu/purge_renderer.rb', line 33

def render_successful_response
  result = [
    "Purge request successfully submitted:",
    "\t* Result: #{response.code} - #{response.message}",
    "\t* Purge ID: #{response.purge_id} | Support ID: #{response.support_id}",
    "\t* Estimated time: #{response.estimated_time} secs.",
    "\t* Progress URI: #{response.uri}",
    "\t* Time to wait before check: #{response.time_to_wait} secs."
  ]

  result
end