Class: Validic::Response

Inherits:
Object
  • Object
show all
Includes:
Validic::REST::Request
Defined in:
lib/validic/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validic::REST::Request

#latest

Constructor Details

#initialize(response, connection = nil) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
14
15
16
17
# File 'lib/validic/response.rb', line 8

def initialize(response, connection = nil)
  @connection = connection
  @summary = summary_object(response)
  case resp = response_object(response)
  when Array
    @records = resp
  when Hash
    @attributes = resp
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/validic/response.rb', line 6

def attributes
  @attributes
end

#recordsObject (readonly)

Returns the value of attribute records.



6
7
8
# File 'lib/validic/response.rb', line 6

def records
  @records
end

#summaryObject (readonly)

Returns the value of attribute summary.



6
7
8
# File 'lib/validic/response.rb', line 6

def summary
  @summary
end

Instance Method Details

#nextObject



19
20
21
22
23
# File 'lib/validic/response.rb', line 19

def next
  return nil unless next_url = summary.next
  resp = get(next_url, {})
  self.class.new(resp, connection)
end

#previousObject



25
26
27
28
29
# File 'lib/validic/response.rb', line 25

def previous
  return nil unless previous_url = summary.previous
  resp = get(previous_url, {})
  self.class.new(resp, connection)
end