internetee/registry

View on GitHub
app/controllers/api/v1/accreditation_center/contacts_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
require 'serializers/repp/contact'

module Api
  module V1
    module AccreditationCenter
      class ContactsController < ::Api::V1::AccreditationCenter::BaseController
        def show
          @contact = Contact.find_by(code: params[:id])

          if @contact
            render json: { code: 1000, contact: Serializers::Repp::Contact.new(@contact,
                                                                               show_address: false).to_json },
                   status: :found
          else
            render json: { errors: 'Contact not found' }, status: :not_found
          end
        end
      end
    end
  end
end