@ -139,7 +139,7 @@ sub next_page {
my ( $ self , $ uri ) = @ _ ;
my ( $ self , $ uri ) = @ _ ;
my $ collection_url ;
my $ collection_url ;
if ( $ self - > { _collection_ url } ) {
if ( $ self - > { _collection_ iter } ) {
$ collection_url = $ self - > { _collection_url } ;
$ collection_url = $ self - > { _collection_url } ;
} else {
} else {
$ collection_url = $ self - > _get_url ( $ uri ) ;
$ collection_url = $ self - > _get_url ( $ uri ) ;
@ -150,11 +150,16 @@ sub next_page {
$ collection_url - > query_form ( \ % params ) ;
$ collection_url - > query_form ( \ % params ) ;
$ self - > { _collection_url } = $ collection_url ;
$ self - > { _collection_url } = $ collection_url ;
$ self - > { _collection_iter } = 1 ;
}
}
return unless $ self - > { _collection_url } ;
my $ req = $ self - > _create_req ( 'GET' , $ collection_url ) ;
my $ req = $ self - > _create_req ( 'GET' , $ collection_url ) ;
my $ res = NGCP::API::Client::Result - > new ( $ self - > { _ua } - > request ( $ req ) ) ;
my $ res = NGCP::API::Client::Result - > new ( $ self - > { _ua } - > request ( $ req ) ) ;
undef $ self - > { _collection_url } ;
my $ data = $ res - > as_hash ( ) ;
my $ data = $ res - > as_hash ( ) ;
if ( $ data && ref ( $ data ) eq 'HASH' ) {
if ( $ data && ref ( $ data ) eq 'HASH' ) {
my $ new_url = URI - > new ( $ data - > { _links } - > { next } - > { href } ) ;
my $ new_url = URI - > new ( $ data - > { _links } - > { next } - > { href } ) ;
@ -166,8 +171,6 @@ sub next_page {
$ new_url - > query_form ( \ % params ) ;
$ new_url - > query_form ( \ % params ) ;
$ self - > { _collection_url } = $ self - > _get_url ( $ new_url - > canonical ) ;
$ self - > { _collection_url } = $ self - > _get_url ( $ new_url - > canonical ) ;
} else {
undef $ self - > { _collection_url } ;
}
}
return $ res ;
return $ res ;
@ -178,6 +181,7 @@ sub set_page_rows {
$ self - > { _opts } { page_rows } = $ rows ;
$ self - > { _opts } { page_rows } = $ rows ;
undef $ self - > { _collection_url } ;
undef $ self - > { _collection_url } ;
undef $ self - > { _collection_iter } ;
return ;
return ;
}
}