Repp: Add contacts/check action

This commit is contained in:
Karl Erik Õunapuu 2020-10-09 09:34:59 +03:00
parent 1686c352bc
commit 39c6d20413
No known key found for this signature in database
GPG key ID: C9DD647298A34764
2 changed files with 25 additions and 2 deletions

View file

@ -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]