Class: Levelup::Responses::SuccessPaginated

Inherits:
Success
  • Object
show all
Defined in:
lib/levelup/responses/success_paginated.rb

Overview

Class that encapsulates a successful response from a paginated endpoint of the LevelUp API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Success

#success?

Instance Attribute Details

#next_page=(value) ⇒ Object

Sets the attribute next_page

Parameters:

  • value

    the value to set the attribute next_page to.



5
6
7
# File 'lib/levelup/responses/success_paginated.rb', line 5

def next_page=(value)
  @next_page = value
end

#next_page_request=(value) ⇒ Object

Sets the attribute next_page_request

Parameters:

  • value

    the value to set the attribute next_page_request to.



5
6
7
# File 'lib/levelup/responses/success_paginated.rb', line 5

def next_page_request=(value)
  @next_page_request = value
end

Instance Method Details

#nextObject



11
12
13
14
15
16
17
18
# File 'lib/levelup/responses/success_paginated.rb', line 11

def next
  unless next_page?
    raise Errors::InvalidRequest, 'Attempted to fetch next page at '\
      'final page of list'
  end

  next_page_request.send_to_api(:get, next_page)
end

#next_page?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/levelup/responses/success_paginated.rb', line 7

def next_page?
  !next_page_request.nil? && !next_page.nil?
end