class SalsaLabs::AuthenticationResponse

Public Class Methods

new(faraday_response) click to toggle source

@param [Faraday::Response] faraday_response

# File lib/salsa_labs/authentication_response.rb, line 7
def initialize(faraday_response)
  @response = faraday_response
end

Public Instance Methods

body() click to toggle source

@return [Nokogiri::XML] the full xml returned by the API,

parsed by +Nokogiri+ (memoized)
# File lib/salsa_labs/authentication_response.rb, line 23
def body
  @body ||= ::Nokogiri::XML(@response.body)
end
error_message() click to toggle source

@return [String] the error message returned by the API @return [nil] if there was no error message returned by the API

# File lib/salsa_labs/authentication_response.rb, line 29
def error_message
  err = body.xpath('//data/error').text
  err == '' ? nil : err
end
session_cookies() click to toggle source

@return [String]

# File lib/salsa_labs/authentication_response.rb, line 12
def session_cookies
  returned_cookies if successful?
end
successful?() click to toggle source

@return [Boolean] true if no error message was returned

# File lib/salsa_labs/authentication_response.rb, line 17
def successful?
  !error_message && session_cookie_exists?
end

Private Instance Methods

returned_cookies() click to toggle source
# File lib/salsa_labs/authentication_response.rb, line 40
def returned_cookies
  @response.headers['set-cookie']
end