* Return contacts inside domain object
* Return registrant uuid and name inside domain object
This commit is contained in:
Maciej Szlosarczyk 2018-10-04 09:54:52 +03:00
parent b6cc22dbfc
commit f551140a0d
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
6 changed files with 484 additions and 255 deletions

View file

@ -9,49 +9,71 @@ module Serializers
def to_json
{
id: @domain.uuid,
name: @domain.name,
id: domain.uuid,
name: domain.name,
registrar: {
name: @domain.registrar.name,
website: @domain.registrar.website,
name: domain.registrar.name,
website: domain.registrar.website,
},
registered_at: @domain.registered_at,
valid_to: @domain.valid_to,
created_at: @domain.created_at,
updated_at: @domain.updated_at,
registrant: @domain.registrant_name,
transfer_code: @domain.transfer_code,
name_dirty: @domain.name_dirty,
name_puny: @domain.name_puny,
period: @domain.period,
period_unit: @domain.period_unit,
creator_str: @domain.creator_str,
updator_str: @domain.updator_str,
legacy_id: @domain.legacy_id,
legacy_registrar_id: @domain.legacy_registrar_id,
legacy_registrant_id: @domain.legacy_registrant_id,
outzone_at: @domain.outzone_at,
delete_at: @domain.delete_at,
registrant_verification_asked_at: @domain.registrant_verification_asked_at,
registrant_verification_token: @domain.registrant_verification_token,
pending_json: @domain.pending_json,
force_delete_at: @domain.force_delete_at,
statuses: @domain.statuses,
locked_by_registrant_at: @domain.locked_by_registrant_at,
reserved: @domain.reserved,
status_notes: @domain.status_notes,
registered_at: domain.registered_at,
valid_to: domain.valid_to,
created_at: domain.created_at,
updated_at: domain.updated_at,
registrant: {
name: domain.registrant.name,
id: domain.registrant.uuid,
},
tech_contacts: contacts(:tech),
admin_contacts: contacts(:admin),
transfer_code: domain.transfer_code,
name_dirty: domain.name_dirty,
name_puny: domain.name_puny,
period: domain.period,
period_unit: domain.period_unit,
creator_str: domain.creator_str,
updator_str: domain.updator_str,
legacy_id: domain.legacy_id,
legacy_registrar_id: domain.legacy_registrar_id,
legacy_registrant_id: domain.legacy_registrant_id,
outzone_at: domain.outzone_at,
delete_at: domain.delete_at,
registrant_verification_asked_at: domain.registrant_verification_asked_at,
registrant_verification_token: domain.registrant_verification_token,
pending_json: domain.pending_json,
force_delete_at: domain.force_delete_at,
statuses: domain.statuses,
locked_by_registrant_at: domain.locked_by_registrant_at,
reserved: domain.reserved,
status_notes: domain.status_notes,
nameservers: nameservers,
}
end
private
def nameservers
array_of_nameservers = Array.new
def contacts(type)
contact_pool = begin
if type == :tech
domain.tech_contacts
elsif type == :admin
domain.admin_contacts
end
end
@domain.nameservers.map do |nameserver|
array_of_nameservers.push({ hostname: nameserver.hostname, ipv4: nameserver.ipv4,
ipv6: nameserver.ipv6 })
array_of_contacts = []
contact_pool.map do |contact|
array_of_contacts.push(name: contact.name, id: contact.uuid)
end
array_of_contacts
end
def nameservers
array_of_nameservers = []
domain.nameservers.map do |nameserver|
array_of_nameservers.push(hostname: nameserver.hostname, ipv4: nameserver.ipv4,
ipv6: nameserver.ipv6)
end
array_of_nameservers