Class: Api::V2::Heron::TubeRacksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/api/v2/heron/tube_racks_controller.rb

Overview

Endpoint to create TubeRacks inside Sequencescape for Heron

Constant Summary

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Methods included from FlashTruncation

#max_flash_size, #truncate_flash, #truncate_flash_array

Instance Method Details

#createObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/api/v2/heron/tube_racks_controller.rb', line 11

def create
  rack_factory = ::Heron::Factories::TubeRack.new(params_for_tube_rack)
  if rack_factory.valid? && rack_factory.save
    render json: {
             data: {
               attributes: {
                 uuid: rack_factory.tube_rack.uuid,
                 purpose_name: rack_factory.purpose.name,
                 study_names: rack_factory.sample_study_names
               },
               links: {
                 self: api_v2_tube_rack_url(rack_factory.tube_rack)
               }
             }
           },
           status: :created
  else
    render json: { errors: rack_factory.errors.full_messages }, status: :unprocessable_entity
  end
end