mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 03:06:14 +02:00
New contact list for REPP
This commit is contained in:
parent
4453fbe302
commit
2438e1e052
3 changed files with 73 additions and 18 deletions
|
@ -4,11 +4,24 @@ module Repp
|
|||
|
||||
resource :contacts do
|
||||
desc 'Return list of contact'
|
||||
params do
|
||||
optional :limit, type: Integer, values: (1..20).to_a
|
||||
optional :offset, type: Integer
|
||||
end
|
||||
|
||||
get '/' do
|
||||
contacts = current_user.registrar.contacts.page(params[:page])
|
||||
limit = params[:limit] || 20
|
||||
offset = params[:offset] || 0
|
||||
|
||||
if params[:details] == 'true'
|
||||
contacts = current_user.registrar.contacts.limit(limit).offset(offset)
|
||||
else
|
||||
contacts = current_user.registrar.contacts.limit(limit).offset(offset).pluck(:code)
|
||||
end
|
||||
|
||||
@response = {
|
||||
contacts: contacts,
|
||||
total_pages: contacts.total_pages
|
||||
total_number_of_records: current_user.registrar.contacts.count
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue