class Passworks::Response
Attributes
client[R]
data[R]
response[R]
Public Class Methods
new(client, response)
click to toggle source
# File lib/passworks/response.rb, line 6 def initialize(client, response) @client = client @response = response @data = response.body end
Public Instance Methods
headers()
click to toggle source
# File lib/passworks/response.rb, line 44 def headers @response.env[:response_headers] || {} end
http_status()
click to toggle source
# File lib/passworks/response.rb, line 32 def http_status @response.status end
next_page()
click to toggle source
# File lib/passworks/response.rb, line 20 def next_page headers['x-next-page'].to_i if next_page? end
next_page?()
click to toggle source
# File lib/passworks/response.rb, line 16 def next_page? !headers['x-next-page'].nil? end
next_page_url()
click to toggle source
# File lib/passworks/response.rb, line 54 def next_page_url return nil unless next_page? params = { page: next_page } end
ok?()
click to toggle source
# File lib/passworks/response.rb, line 40 def ok? @response.success? end
paginated?()
click to toggle source
# File lib/passworks/response.rb, line 12 def paginated? (!headers['x-total-pages'].nil?) && (headers['x-total-pages'].to_i > 1) end
previous_page()
click to toggle source
# File lib/passworks/response.rb, line 28 def previous_page headers['x-prev-page'].to_i if previous_page? end
previous_page?()
click to toggle source
# File lib/passworks/response.rb, line 24 def previous_page? !headers['x-prev-page'].nil? end
size()
click to toggle source
# File lib/passworks/response.rb, line 48 def size return headers['x-total'].to_i unless headers['x-total'].nil? return data.size if data.is_a?(Array) return 0 end