class Sezame::Response::Generic

generic response, expects the response as returned by the httpclient

Attributes

data[R]
response[R]

Public Class Methods

new(response) click to toggle source
# File lib/sezame-sdk/response.rb, line 14
def initialize(response)
  @response = response
  @data     = response.content
end

Public Instance Methods

get_errors() click to toggle source

return an array of error messages

# File lib/sezame-sdk/response.rb, line 49
def get_errors
  unless @data.has_key?('errors')
    return []
  end

  @data['errors']
end
get_message() click to toggle source

get the error message return by hq if any

# File lib/sezame-sdk/response.rb, line 40
def get_message
  unless @data.has_key?('message')
    return nil
  end

  @data['message']
end
get_status() click to toggle source
# File lib/sezame-sdk/response.rb, line 31
def get_status
  unless @data.has_key?('status')
    return nil
  end

  @data['status']
end
is_empty() click to toggle source
# File lib/sezame-sdk/response.rb, line 19
def is_empty
  [201, 204, 304].include? @response.status
end
is_notfound() click to toggle source
# File lib/sezame-sdk/response.rb, line 27
def is_notfound
  @response.status == 404
end
is_ok() click to toggle source
# File lib/sezame-sdk/response.rb, line 23
def is_ok
  @response.status == 200
end