Method: App42::User::UserService#get_all_users_by_paging

Defined in:
lib/user/UserService.rb

#get_all_users_by_paging(max, offset) ⇒ Object

Gets All users By Paging

Parameters:

  • max
    • Maximum number of records to be fetched

  • offset
    • From where the records are to be fetched

Returns:

  • Returns User Information

Raises:

  • App42Exception



574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# File 'lib/user/UserService.rb', line 574

def get_all_users_by_paging(max, offset)
  puts "getAllUsersByPaging Called "
  puts "Base url #{@base_url}"
  response, usr = nil
  user_list, util = User.new, Util.new
  util.validateMax(max)
  util.throwExceptionIfNullOrBlank(max, "Max")
  util.throwExceptionIfNullOrBlank(offset, "Offset")
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    query_params = {}
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("max", "" + (max.to_i).to_s)
    params.store("offset", "" + (offset.to_i).to_s)
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}/paging/#{(max.to_i).to_s}/#{(offset.to_i).to_s}"
    response = connection.get(signature, resource_url, query_params)
    user = UserResponseBuilder.new
    user_list = user.buildArrayResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return user_list
end