Class: OneRoster::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response) ⇒ Response

Returns a new instance of Response.



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

def initialize(faraday_response)
  @status = faraday_response.status
  @raw_body = faraday_response.body
  @type = resource_type(faraday_response)

  return unless faraday_response.body

  @body = faraday_response.body[@type]

  return unless faraday_response.headers

  @headers = faraday_response.headers
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



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

def headers
  @headers
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



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

def raw_body
  @raw_body
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/one_roster/response.rb', line 23

def success?
  @status == 200
end