mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 12:47:29 +02:00
REPP: Specific domain transfer action
This commit is contained in:
parent
1d9850fb98
commit
06088e33c5
4 changed files with 45 additions and 7 deletions
38
app/controllers/repp/v1/domains/transfers_controller.rb
Normal file
38
app/controllers/repp/v1/domains/transfers_controller.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
module Repp
|
||||
module V1
|
||||
module Domains
|
||||
class TransfersController < BaseController
|
||||
before_action :set_domain, only: [:create]
|
||||
|
||||
api :POST, 'repp/v1/domains/:domain_name/transfer'
|
||||
desc 'Transfer a specific domain'
|
||||
param :transfer, Hash, required: true, desc: 'Renew parameters' do
|
||||
param :transfer_code, String, required: true, desc: 'Renew period. Month (m) or year (y)'
|
||||
end
|
||||
def create
|
||||
action = Actions::DomainTransfer.new(@domain, transfer_params[:transfer][:transfer_code],
|
||||
current_user.registrar)
|
||||
|
||||
unless action.call
|
||||
handle_errors(@domain)
|
||||
return
|
||||
end
|
||||
|
||||
render_success(data: { domain: { name: @domain.name, type: 'domain_transfer' } })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
h = {}
|
||||
h[transfer_params[:domain_id].match?(/\A[0-9]+\z/) ? :id : :name] = transfer_params[:domain_id]
|
||||
@domain = Epp::Domain.find_by!(h)
|
||||
end
|
||||
|
||||
def transfer_params
|
||||
params.permit!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -99,8 +99,8 @@ module Repp
|
|||
render_success(data: data)
|
||||
end
|
||||
|
||||
api :POST, '/repp/v1/domains/:domain_name/transfer'
|
||||
desc 'Transfer specific domain'
|
||||
api :POST, '/repp/v1/domains/transfer'
|
||||
desc 'Transfer multiple domains'
|
||||
def transfer
|
||||
@errors ||= []
|
||||
@successful = []
|
||||
|
@ -112,8 +112,6 @@ module Repp
|
|||
render_success(data: { success: @successful, failed: @errors })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def initiate_transfer(transfer)
|
||||
domain = Epp::Domain.find_or_initialize_by(name: transfer[:domain_name])
|
||||
action = Actions::DomainTransfer.new(domain, transfer[:transfer_code],
|
||||
|
@ -127,6 +125,8 @@ module Repp
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def transfer_params
|
||||
params.require(:data).require(:domain_transfers).each do |t|
|
||||
t.require(:domain_name)
|
||||
|
|
|
@ -11,10 +11,9 @@ module Domains
|
|||
def execute
|
||||
return domain_pricelist.price.amount if domain_pricelist.try(:price)
|
||||
|
||||
errors.add(:domain, I18n.t(:active_price_missing_for_operation_with_domain,
|
||||
domain: domain.name))
|
||||
|
||||
domain.add_epp_error(2104, nil, nil, I18n.t(:active_price_missing_for_this_operation))
|
||||
errors.add(:domain, I18n.t(:active_price_missing_for_operation_with_domain,
|
||||
domain: domain.name))
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ Rails.application.routes.draw do
|
|||
resources :dnssec, only: %i[index create], constraints: { id: /.*/ }, controller: 'domains/dnssec'
|
||||
resources :contacts, only: %i[index create], constraints: { id: /.*/ }, controller: 'domains/contacts'
|
||||
resources :renew, only: %i[create], constraints: { id: /.*/ }, controller: 'domains/renews'
|
||||
resources :transfer, only: %i[create], constraints: { id: /.*/ }, controller: 'domains/transfers'
|
||||
match "dnssec", to: "domains/dnssec#destroy", via: "delete", defaults: { id: nil }
|
||||
match "contacts", to: "domains/contacts#destroy", via: "delete", defaults: { id: nil }
|
||||
collection do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue