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.



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

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.



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

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



3
4
5
# File 'lib/one_roster/response.rb', line 3

def headers
  @headers
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



3
4
5
# File 'lib/one_roster/response.rb', line 3

def raw_body
  @raw_body
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/one_roster/response.rb', line 3

def status
  @status
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/one_roster/response.rb', line 21

def success?
  @status == 200
end