Class: Webex::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/webex/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response) ⇒ Response

Returns a new instance of Response.

Parameters:

  • faraday_response (Faraday::Response)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/webex/response.rb', line 10

def initialize(faraday_response)
  @status = faraday_response.status
  @body = begin
    JSON.parse(faraday_response.body)
  rescue
    {}
  end
  @success = faraday_response.success?
  @headers = faraday_response.headers.to_h
  @request_headers = faraday_response.env[:request_headers].to_h
  @request_body = faraday_response.env[:request_body]
  @url = faraday_response.env[:url]
  @rate_limiter = RateLimiter.new(headers)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/webex/response.rb', line 5

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/webex/response.rb', line 5

def headers
  @headers
end

#rate_limiterObject

Returns the value of attribute rate_limiter.



7
8
9
# File 'lib/webex/response.rb', line 7

def rate_limiter
  @rate_limiter
end

#request_bodyObject (readonly)

Returns the value of attribute request_body.



6
7
8
# File 'lib/webex/response.rb', line 6

def request_body
  @request_body
end

#request_headersObject (readonly)

Returns the value of attribute request_headers.



6
7
8
# File 'lib/webex/response.rb', line 6

def request_headers
  @request_headers
end

#retry_countObject

Returns the value of attribute retry_count.



7
8
9
# File 'lib/webex/response.rb', line 7

def retry_count
  @retry_count
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/webex/response.rb', line 5

def status
  @status
end

#time_spent_in_msObject

Returns the value of attribute time_spent_in_ms.



7
8
9
# File 'lib/webex/response.rb', line 7

def time_spent_in_ms
  @time_spent_in_ms
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/webex/response.rb', line 6

def url
  @url
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/webex/response.rb', line 25

def success?
  @success
end