REPP: Serialize domains

This commit is contained in:
Karl Erik Õunapuu 2021-01-27 13:01:59 +02:00
parent 57df268d91
commit e55fc833e7
No known key found for this signature in database
GPG key ID: C9DD647298A34764
2 changed files with 8 additions and 3 deletions

View file

@ -1,4 +1,4 @@
require 'serializers/registrant_api/domain' require 'serializers/repp/domain'
module Repp module Repp
module V1 module V1
class DomainsController < BaseController class DomainsController < BaseController
@ -13,13 +13,17 @@ module Repp
domains = records.limit(limit).offset(offset) domains = records.limit(limit).offset(offset)
domains = domains.pluck(:name) unless index_params[:details] == 'true' domains = domains.pluck(:name) unless index_params[:details] == 'true'
if index_params[:details] == 'true'
domains = domains.map { |d| Serializers::Repp::Domain.new(d).to_json }
end
render_success(data: { domains: domains, total_number_of_records: records.count }) render_success(data: { domains: domains, total_number_of_records: records.count })
end end
api :GET, '/repp/v1/domains/:domain_name' api :GET, '/repp/v1/domains/:domain_name'
desc 'Get a specific domain' desc 'Get a specific domain'
def show def show
render_success(data: { domain: Serializers::RegistrantApi::Domain.new(@domain).to_json }) render_success(data: { domain: Serializers::Repp::Domain.new(@domain).to_json })
end end
api :POST, '/repp/v1/domains' api :POST, '/repp/v1/domains'

View file

@ -29,7 +29,8 @@ module Serializers
def dnssec_keys def dnssec_keys
domain.dnskeys.map do |nssec| domain.dnskeys.map do |nssec|
{ flags: nsec.flags, protocol: nssec.protocol, alg: nssec.alg, public_key: nssec.public_key } { flags: nssec.flags, protocol: nssec.protocol, alg: nssec.alg,
public_key: nssec.public_key }
end end
end end
end end