REPP: Ditch _id from registrant / registrar attributes

This commit is contained in:
Karl Erik Õunapuu 2021-03-22 15:28:23 +02:00
parent 83bfc493bb
commit d6b266459b
No known key found for this signature in database
GPG key ID: C9DD647298A34764
5 changed files with 15 additions and 15 deletions

View file

@ -27,7 +27,7 @@ module Repp
desc 'Create a new domain' desc 'Create a new domain'
param :domain, Hash, required: true, desc: 'Parameters for new domain' do param :domain, Hash, required: true, desc: 'Parameters for new domain' do
param :name, String, required: true, desc: 'Domain name to be registered' param :name, String, required: true, desc: 'Domain name to be registered'
param :registrant_id, String, required: true, desc: 'Registrant contact code' param :registrant, String, required: true, desc: 'Registrant contact code'
param :period, Integer, required: true, desc: 'Registration period in months or years' param :period, Integer, required: true, desc: 'Registration period in months or years'
param :period_unit, String, required: true, desc: 'Period type (month m) or (year y)' param :period_unit, String, required: true, desc: 'Period type (month m) or (year y)'
param :nameservers_attributes, Array, required: false, desc: 'Domain nameservers' do param :nameservers_attributes, Array, required: false, desc: 'Domain nameservers' do
@ -170,7 +170,7 @@ module Repp
def forward_registrar_id def forward_registrar_id
return unless params[:domain] return unless params[:domain]
params[:domain][:registrar_id] = current_user.registrar.id params[:domain][:registrar] = current_user.registrar.id
end end
def set_domain def set_domain
@ -216,7 +216,7 @@ module Repp
end end
def domain_create_params def domain_create_params
params.require(:domain).permit(:name, :registrant_id, :period, :period_unit, :registrar_id, params.require(:domain).permit(:name, :registrant, :period, :period_unit, :registrar,
dnskeys_attributes: [%i[flags alg protocol public_key]], dnskeys_attributes: [%i[flags alg protocol public_key]],
nameservers_attributes: [[:hostname, ipv4: [], ipv6: []]], nameservers_attributes: [[:hostname, ipv4: [], ipv6: []]],
admin_contacts: [], admin_contacts: [],

View file

@ -66,16 +66,16 @@ module Actions
end end
def assign_registrant def assign_registrant
unless params[:registrant_id] unless params[:registrant]
domain.add_epp_error('2306', nil, nil, %i[registrant cannot_be_missing]) domain.add_epp_error('2306', nil, nil, %i[registrant cannot_be_missing])
return return
end end
regt = Registrant.find_by(code: params[:registrant_id]) regt = Registrant.find_by(code: params[:registrant])
if regt if regt
domain.registrant = regt domain.registrant = regt
else else
domain.add_epp_error('2303', 'registrant', params[:registrant_id], %i[registrant not_found]) domain.add_epp_error('2303', 'registrant', params[:registrant], %i[registrant not_found])
end end
end end
@ -207,7 +207,7 @@ module Actions
end end
def current_registrar def current_registrar
Registrar.find(params[:registrar_id]) Registrar.find(params[:registrar])
end end
end end
end end

View file

@ -49,7 +49,7 @@ module Actions
regt = Registrant.find_by(code: params[:registrant][:code]) regt = Registrant.find_by(code: params[:registrant][:code])
unless regt unless regt
domain.add_epp_error('2303', 'registrant', params[:registrant_id], %i[registrant not_found]) domain.add_epp_error('2303', 'registrant', params[:registrant], %i[registrant not_found])
return return
end end
@ -234,7 +234,7 @@ module Actions
def ask_registrant_verification def ask_registrant_verification
if verify_registrant_change? && !bypass_verify && if verify_registrant_change? && !bypass_verify &&
Setting.request_confirmation_on_registrant_change_enabled Setting.request_confirmation_on_registrant_change_enabled
domain.registrant_verification_asked!(params, params[:registrar_id]) domain.registrant_verification_asked!(params, params[:registrar])
end end
end end

View file

@ -11,8 +11,8 @@ module Deserializers
def call def call
attributes = { attributes = {
name: if_present('name'), name: if_present('name'),
registrar_id: registrar, registrar: registrar,
registrant_id: if_present('registrant'), registrant: if_present('registrant'),
reserved_pw: if_present('reserved > pw'), reserved_pw: if_present('reserved > pw'),
} }

View file

@ -17,7 +17,7 @@ class ReppV1DomainsCreateTest < ActionDispatch::IntegrationTest
payload = { payload = {
domain: { domain: {
name: 'domeener.test', name: 'domeener.test',
registrant_id: contact.code, registrant: contact.code,
period: 1, period: 1,
period_unit: 'y' period_unit: 'y'
} }
@ -39,7 +39,7 @@ class ReppV1DomainsCreateTest < ActionDispatch::IntegrationTest
payload = { payload = {
domain: { domain: {
name: 'domeener.test', name: 'domeener.test',
registrant_id: contact.code, registrant: contact.code,
period: 3, period: 3,
period_unit: 'y' period_unit: 'y'
} }
@ -61,7 +61,7 @@ class ReppV1DomainsCreateTest < ActionDispatch::IntegrationTest
payload = { payload = {
domain: { domain: {
name: 'domeener.test', name: 'domeener.test',
registrant_id: contact.code, registrant: contact.code,
period: 1, period: 1,
period_unit: 'y', period_unit: 'y',
nameservers_attributes: [ nameservers_attributes: [
@ -91,7 +91,7 @@ class ReppV1DomainsCreateTest < ActionDispatch::IntegrationTest
payload = { payload = {
domain: { domain: {
name: 'domeener.test', name: 'domeener.test',
registrant_id: contact.code, registrant: contact.code,
period: 1, period: 1,
period_unit: 'y', period_unit: 'y',
admin_contacts: [ admin_contact.code ], admin_contacts: [ admin_contact.code ],