REPP API changes

This commit is contained in:
Martin Lensment 2015-03-27 18:31:24 +02:00
parent 822b325bc0
commit ccd34ed4a9
5 changed files with 62 additions and 12 deletions

View file

@ -8,10 +8,10 @@ module Repp
end
before do
next if Rails.env.test?
next if Rails.env.test? || Rails.env.development?
message = 'Certificate mismatch! Cert common name should be:'
request_name = env['HTTP_SSL_CLIENT_S_DN_CN']
if request.ip == ENV['webclient_ip']
webclient_cert_name = ENV['webclient_cert_common_name'] || 'webclient'
error! "Webclient #{message} #{webclient_cert_name}", 401 if webclient_cert_name != request_name

View file

@ -4,11 +4,22 @@ module Repp
resource :domains do
desc 'Return list of domains'
params do
optional :limit, type: Integer, values: (1..20).to_a
end
get '/' do
domains = current_user.registrar.domains.page(params[:page])
limit = params[:limit] || 20
if params[:details] == 'true'
domains = current_user.registrar.domains.limit(limit)
else
domains = current_user.registrar.domains.limit(limit).pluck(:name)
end
@response = {
domains: domains,
total_pages: domains.total_pages
total_number_of_records: current_user.registrar.domains.count
}
end
end