mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Add response to REPP log
This commit is contained in:
parent
7edf48c885
commit
a41abf8176
6 changed files with 24 additions and 30 deletions
|
@ -3,9 +3,9 @@ module Repp
|
|||
class AuctionsController < ActionController::API
|
||||
def index
|
||||
auctions = Auction.started
|
||||
@response = { count: auctions.count, auctions: auctions_to_json(auctions) }
|
||||
|
||||
render json: { count: auctions.count,
|
||||
auctions: auctions_to_json(auctions) }
|
||||
render json: @response
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -24,10 +24,10 @@ module Repp
|
|||
private
|
||||
|
||||
def render_success(code: nil, message: nil, data: nil)
|
||||
resp = { code: code || 1000, message: message || 'Command completed successfully',
|
||||
@response = { code: code || 1000, message: message || 'Command completed successfully',
|
||||
data: data || {} }
|
||||
|
||||
render(json: resp, status: :ok)
|
||||
render(json: @response, status: :ok)
|
||||
end
|
||||
|
||||
def epp_errors
|
||||
|
@ -64,10 +64,8 @@ module Repp
|
|||
@epp_errors ||= []
|
||||
@epp_errors << { code: 2304, msg: 'Command failed' } if data != {}
|
||||
|
||||
render(
|
||||
json: { code: @epp_errors[0][:code].to_i, message: @epp_errors[0][:msg], data: data },
|
||||
status: status
|
||||
)
|
||||
@response = { code: @epp_errors[0][:code].to_i, message: @epp_errors[0][:msg], data: data }
|
||||
render(json: @response, status: status)
|
||||
end
|
||||
|
||||
def basic_token
|
||||
|
@ -85,10 +83,8 @@ module Repp
|
|||
|
||||
raise(ArgumentError)
|
||||
rescue NoMethodError, ArgumentError
|
||||
render(
|
||||
json: { code: 2202, message: 'Invalid authorization information' },
|
||||
status: :unauthorized
|
||||
)
|
||||
@response = { code: 2202, message: 'Invalid authorization information' }
|
||||
render(json: @response, status: :unauthorized)
|
||||
end
|
||||
|
||||
def check_ip_restriction
|
||||
|
@ -96,17 +92,14 @@ module Repp
|
|||
|
||||
return if allowed
|
||||
|
||||
render(
|
||||
json: {
|
||||
code: 2202,
|
||||
message: I18n.t('registrar.authorization.ip_not_allowed', ip: request.ip),
|
||||
},
|
||||
status: :unauthorized
|
||||
)
|
||||
@response = { code: 2202,
|
||||
message: I18n.t('registrar.authorization.ip_not_allowed', ip: request.ip) }
|
||||
render(json: @response, status: :unauthorized)
|
||||
end
|
||||
|
||||
def not_found_error
|
||||
render(json: { code: 2303, message: 'Object does not exist' }, status: :not_found)
|
||||
@response = { code: 2303, message: 'Object does not exist' }
|
||||
render(json: @response, status: :not_found)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,8 +9,8 @@ module Repp
|
|||
record_count = current_user.registrar.contacts.count
|
||||
contacts = showable_contacts(params[:details], params[:limit] || 200,
|
||||
params[:offset] || 0)
|
||||
|
||||
render(json: { contacts: contacts, total_number_of_records: record_count }, status: :ok)
|
||||
@response = { contacts: contacts, total_number_of_records: record_count }
|
||||
render(json: @response, status: :ok)
|
||||
end
|
||||
|
||||
## GET /repp/v1/contacts/1
|
||||
|
|
|
@ -26,8 +26,8 @@ module Repp
|
|||
return handle_errors if @epp_errors.any?
|
||||
|
||||
affected, skipped = TechDomainContact.replace(@current_contact, @new_contact)
|
||||
data = { affected_domains: affected, skipped_domains: skipped }
|
||||
render_success(data: data)
|
||||
@response = { affected_domains: affected, skipped_domains: skipped }
|
||||
render_success(data: @response)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -3,8 +3,9 @@ module Repp
|
|||
class RetainedDomainsController < ActionController::API
|
||||
def index
|
||||
domains = RetainedDomains.new(query_params)
|
||||
@response = { count: domains.count, domains: domains.to_jsonable }
|
||||
|
||||
render json: { count: domains.count, domains: domains.to_jsonable }
|
||||
render json: @response
|
||||
end
|
||||
|
||||
def query_params
|
||||
|
|
|
@ -8,11 +8,11 @@ module Serializers
|
|||
@show_address = show_address
|
||||
end
|
||||
|
||||
def to_json(_obj)
|
||||
json = { id: contact.code, name: contact.name, ident: ident,
|
||||
email: contact.email, phone: contact.phone, fax: contact.fax,
|
||||
auth_info: contact.auth_info, statuses: contact.statuses,
|
||||
disclosed_attributes: contact.disclosed_attributes }
|
||||
def to_json(obj = contact)
|
||||
json = { id: obj.code, name: obj.name, ident: ident,
|
||||
email: obj.email, phone: obj.phone, fax: obj.fax,
|
||||
auth_info: obj.auth_info, statuses: obj.statuses,
|
||||
disclosed_attributes: obj.disclosed_attributes }
|
||||
|
||||
json[:address] = address if @show_address
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue