Class: Files::Response

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

#http_bodyObject

Returns the value of attribute http_body.



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

def http_body
  @http_body
end

#http_headersObject

Returns the value of attribute http_headers.



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

def http_headers
  @http_headers
end

#http_statusObject

Returns the value of attribute http_status.



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

def http_status
  @http_status
end

Class Method Details

.from_faraday_hash(http_resp) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/files.com/response.rb', line 7

def self.from_faraday_hash(http_resp)
  resp = new
  resp.data = JSON.parse(http_resp[:body], symbolize_names: true) if http_resp[:status] != 204
  resp.http_body = http_resp[:body]
  resp.http_headers = http_resp[:headers]
  resp.http_status = http_resp[:status]
  resp
end

.from_faraday_response(http_resp) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/files.com/response.rb', line 16

def self.from_faraday_response(http_resp)
  resp = new
  resp.data = JSON.parse(http_resp.body, symbolize_names: true) if http_resp.status != 204
  resp.http_body = http_resp.body
  resp.http_headers = http_resp.headers
  resp.http_status = http_resp.status
  resp
end