class OneRoster::Response

Attributes

body[RW]
headers[R]
raw_body[R]
status[R]

Public Class Methods

new(faraday_response) click to toggle source
# 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

Public Instance Methods

success?() click to toggle source
# File lib/one_roster/response.rb, line 23
def success?
  @status == 200
end

Private Instance Methods

resource_type(faraday_response) click to toggle source
# File lib/one_roster/response.rb, line 29
def resource_type(faraday_response)
  RESPONSE_TYPE_MAP[faraday_response.env.url.path.split('/').last]
end