class Phishin::Api::Response

Attributes

data[R]
http_status[R]
page[R]
total_entries[R]
total_pages[R]
url[R]

Public Class Methods

new(url, response_data) click to toggle source
# File lib/phishin/api/response.rb, line 11
def initialize(url, response_data)
  @url = url
  @success = response_data['success']

  if success?
    @total_entries = response_data['total_entries']
    @total_pages = response_data['total_pages']
    @page = response_data['page']
    @data = response_data['data']
    @data = @data.is_a?(Hash) ? Hashie::Mash.new(@data) : @data.map{ |d| d.is_a?(Hash) ? Hashie::Mash.new(d) : d }
  else
    @message = response_data['message']
    raise Phishin::Client::UnsuccessfulResponseError.new(url, @message)
  end
end

Public Instance Methods

success?() click to toggle source
# File lib/phishin/api/response.rb, line 27
def success?
  return @success == true
end