class Smarteru::Response

Attributes

data[R]
hash[R]
opts[R]

Public Class Methods

new(res, opts = {}) click to toggle source

Initializes an API response

Attributes

  • resp - RestClient response from the API

# File lib/smarteru/response.rb, line 9
def initialize(res, opts = {})
  @data = res
  opts[:parser] ||= Nori.new(
    parser:          :rexml,
    convert_tags_to: lambda { |tag| tag.snakecase.to_sym }
  )
  @opts = opts
end

Public Instance Methods

error() click to toggle source
# File lib/smarteru/response.rb, line 34
def error
  errors = hash[:smarter_u][:errors]
  errors.is_a?(Hash) ? errors : nil
end
result() click to toggle source
# File lib/smarteru/response.rb, line 30
def result
  hash[:smarter_u][:info]
end
success?() click to toggle source

Return true/false based on the API response status

# File lib/smarteru/response.rb, line 24
def success?
  hash[:smarter_u][:result] == 'Success'
rescue
  false
end