From 39c6d204134375fd04765c1b10b4ce11402a2779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Fri, 9 Oct 2020 09:34:59 +0300 Subject: [PATCH] Repp: Add contacts/check action --- .../repp/v1/contacts_controller.rb | 20 ++++++++++++++++++- config/routes.rb | 7 ++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/controllers/repp/v1/contacts_controller.rb b/app/controllers/repp/v1/contacts_controller.rb index 70bf91297..1d2dbd441 100644 --- a/app/controllers/repp/v1/contacts_controller.rb +++ b/app/controllers/repp/v1/contacts_controller.rb @@ -1,7 +1,7 @@ module Repp module V1 class ContactsController < BaseController - before_action :find_contact, only: [:update] + before_action :find_contact, only: %i[show update] ## GET /repp/v1/contacts def index @@ -20,6 +20,24 @@ module Repp render(json: resp, status: :ok) end + ## GET /repp/v1/contacts/1 + def show + render(json: @contact.as_json, status: :ok) + end + + ## GET /repp/v1/contacts/check/1 + def check + contact = Epp::Contact.find_by(code: params[:id]) + + render json: { + code: 1000, message: I18n.t('epp.contacts.completed'), + data: { contact: { + id: params[:id], + available: contact.nil? + } } + }, status: :ok + end + ## POST /repp/v1/contacts def create @legal_doc = params[:legal_documents] diff --git a/config/routes.rb b/config/routes.rb index 5c518a533..634b40e31 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,7 +39,12 @@ Rails.application.routes.draw do namespace :repp do namespace :v1 do - resources :contacts + resources :contacts do + collection do + get 'check/:id', to: 'contacts#check' + end + end + resources :accounts do collection do get 'balance'