mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
REPP: Domain info for not-sponsoring registrars
This commit is contained in:
parent
265e135cd0
commit
016c5e802c
2 changed files with 14 additions and 6 deletions
|
@ -5,7 +5,7 @@ module Repp
|
|||
before_action :set_authorized_domain, only: %i[transfer_info destroy]
|
||||
before_action :validate_registrar_authorization, only: %i[transfer_info destroy]
|
||||
before_action :forward_registrar_id, only: %i[create update destroy]
|
||||
before_action :set_domain, only: %i[show update]
|
||||
before_action :set_domain, only: %i[update]
|
||||
|
||||
api :GET, '/repp/v1/domains'
|
||||
desc 'Get all existing domains'
|
||||
|
@ -20,7 +20,10 @@ module Repp
|
|||
api :GET, '/repp/v1/domains/:domain_name'
|
||||
desc 'Get a specific domain'
|
||||
def show
|
||||
render_success(data: { domain: Serializers::Repp::Domain.new(@domain).to_json })
|
||||
@domain = Epp::Domain.find_by!(name: params[:id])
|
||||
sponsored = @domain.registrar == current_user.registrar
|
||||
render_success(data: { domain: Serializers::Repp::Domain.new(@domain,
|
||||
sponsored: sponsored).to_json })
|
||||
end
|
||||
|
||||
api :POST, '/repp/v1/domains'
|
||||
|
|
|
@ -3,8 +3,9 @@ module Serializers
|
|||
class Domain
|
||||
attr_reader :domain
|
||||
|
||||
def initialize(domain)
|
||||
def initialize(domain, sponsored: true)
|
||||
@domain = domain
|
||||
@sponsored = sponsored
|
||||
end
|
||||
|
||||
def to_json(obj = domain)
|
||||
|
@ -12,10 +13,10 @@ module Serializers
|
|||
name: obj.name, registrant: obj.registrant.code, created_at: obj.created_at,
|
||||
updated_at: obj.updated_at, expire_time: obj.expire_time, outzone_at: obj.outzone_at,
|
||||
delete_date: obj.delete_date, force_delete_date: obj.force_delete_date,
|
||||
transfer_code: obj.auth_info, contacts: contacts, nameservers: nameservers,
|
||||
dnssec_keys: dnssec_keys, statuses: obj.statuses
|
||||
contacts: contacts, nameservers: nameservers, dnssec_keys: dnssec_keys,
|
||||
statuses: obj.statuses, registrar: registrar
|
||||
}
|
||||
|
||||
json[:transfer_code] = obj.auth_info if @sponsored
|
||||
json
|
||||
end
|
||||
|
||||
|
@ -33,6 +34,10 @@ module Serializers
|
|||
public_key: nssec.public_key }
|
||||
end
|
||||
end
|
||||
|
||||
def registrar
|
||||
{ name: domain.registrar.name, website: domain.registrar.website }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue