def export
CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
csv << [NAME, COUNT, FIRSTNAME, LASTNAME, EMAIL, ORGANIZATIONS, LOCATIONS, ROLES]
@api.resource(:users).call(:index, {:per_page => 999999})['results'].each do |user|
if user['organizations']
organizations = CSV.generate do |column|
column << user['organizations'].collect do |organization|
organization['name']
end
end
organizations.delete!("\n")
end
if user['locations']
locations = CSV.generate do |column|
column << user['locations'].collect do |location|
location['name']
end
end
locations.delete!("\n")
end
if user['roles']
roles = CSV.generate do |column|
column << user['roles'].collect do |role|
role['name']
end
end
roles.delete!("\n")
end
if user['login'] != 'admin' && !user['login'].start_with?('hidden-')
csv << [user['login'], 1, user['firstname'], user['lastname'], user['mail'],
organizations, locations, roles]
end
end
end
end