mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 07:34:45 +02:00
REPP: compose success data in new method
This commit is contained in:
parent
7379390827
commit
8755fbdbf4
1 changed files with 13 additions and 13 deletions
|
@ -5,15 +5,12 @@ module Repp
|
||||||
|
|
||||||
## GET /repp/v1/contacts
|
## GET /repp/v1/contacts
|
||||||
def index
|
def index
|
||||||
limit = params[:limit] || 200
|
|
||||||
offset = params[:offset] || 0
|
|
||||||
|
|
||||||
record_count = current_user.registrar.contacts.count
|
record_count = current_user.registrar.contacts.count
|
||||||
show_addresses = Contact.address_processing? && params[:details] == 'true'
|
show_addresses = Contact.address_processing? && params[:details] == 'true'
|
||||||
contacts = showable_contacts(params[:details], limit, offset, show_addresses)
|
contacts = showable_contacts(params[:details], params[:limit] || 200,
|
||||||
|
params[:offset] || 0, show_addresses)
|
||||||
|
|
||||||
resp = { contacts: contacts, total_number_of_records: record_count }
|
render(json: { contacts: contacts, total_number_of_records: record_count }, status: :ok)
|
||||||
render(json: resp, status: :ok)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
## GET /repp/v1/contacts/1
|
## GET /repp/v1/contacts/1
|
||||||
|
@ -31,17 +28,16 @@ module Repp
|
||||||
|
|
||||||
## POST /repp/v1/contacts
|
## POST /repp/v1/contacts
|
||||||
def create
|
def create
|
||||||
@legal_doc = params[:legal_documents]
|
|
||||||
|
|
||||||
@contact = Epp::Contact.new(contact_params_with_address, current_user.registrar, epp: false)
|
@contact = Epp::Contact.new(contact_params_with_address, current_user.registrar, epp: false)
|
||||||
action = Actions::ContactCreate.new(@contact, @legal_doc, contact_ident_params)
|
action = Actions::ContactCreate.new(@contact, params[:legal_documents],
|
||||||
|
contact_ident_params)
|
||||||
|
|
||||||
unless action.call
|
unless action.call
|
||||||
handle_errors(@contact)
|
handle_errors(@contact)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
render_success(code: opt_addr? ? 1100 : nil, data: { contact: { id: @contact.code } },
|
render_success(create_update_success_data)
|
||||||
message: opt_addr? ? I18n.t('epp.contacts.completed_without_address') : nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
## PUT /repp/v1/contacts/1
|
## PUT /repp/v1/contacts/1
|
||||||
|
@ -55,8 +51,7 @@ module Repp
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
render_success(code: opt_addr? ? 1100 : nil, data: { contact: { id: @contact.code } },
|
render_success(create_update_success_data)
|
||||||
message: opt_addr? ? I18n.t('epp.contacts.completed_without_address') : nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def contact_addr_present?
|
def contact_addr_present?
|
||||||
|
@ -65,6 +60,11 @@ module Repp
|
||||||
contact_addr_params[:addr].keys.any?
|
contact_addr_params[:addr].keys.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_update_success_body
|
||||||
|
{ code: opt_addr? ? 1100 : nil, data: { contact: { id: @contact.code } },
|
||||||
|
message: opt_addr? ? I18n.t('epp.contacts.completed_without_address') : nil }
|
||||||
|
end
|
||||||
|
|
||||||
def showable_contacts(details, limit, offset, addresses)
|
def showable_contacts(details, limit, offset, addresses)
|
||||||
contacts = current_user.registrar.contacts.limit(limit).offset(offset)
|
contacts = current_user.registrar.contacts.limit(limit).offset(offset)
|
||||||
unless addresses
|
unless addresses
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue