Class: Api::V2::LotResource

Inherits:
BaseResource
  • Object
show all
Defined in:
app/resources/api/v2/lot_resource.rb

Overview

Note:

Access this resource via the /api/v2/lots/ endpoint.

Note:

This resource supports retrieval and creation of lots but does not allow modification after creation.

Note:

The below POST example is not currently supported by the API, but is included here for reference.

Provides a JSON:API representation of Lot.

A Lot represents a received batch of consumables (eg. tag plates) that can be assumed to share some level of QC. A lot can be generated from Gatekeeper.

This is because received_at is a required field in the model, but is not included in the JSON:API request.

For more information about JSON:API, see the JSON:API Specifications or the JSONAPI::Resources package for Sequencescape's implementation of the JSON:API standard.

Examples:

GET request to fetch all lots

GET /api/v2/lots/

GET request to fetch a specific lot by ID

GET /api/v2/lots/123/

POST request to create a new lot

POST /api/v2/lots/

POST request to create a new lot

POST /api/v2/lots/
{
  "data": {
    "type": "lots",
    "attributes": {
      "lot_number": "ABC123"
      // "received_at": "11"
    },
    "relationships": {
      "lot_type": {
        "data": { "type": "lot_types", "id": "1" }
      },
      "user": {
        "data": { "type": "users", "id": "1" }
      },
      "template": {
        "data": { "type": "tag_layout_templates", "id": "3" }
      }
      // "tag_layout_template": {
      //     "data": { "type": "tag_layout_templates", "id": "1"}
      // }
    }
  }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseResource

apply_includes, creatable_fields, default_includes, #fetchable_fields, inclusions, resolve_relationship_names_to_relations, updatable_fields

Instance Attribute Details

#lot_numberString

Note:

This field is required when creating a lot.

Returns The lot number.

Returns:

  • (String)

    The lot number.



69
# File 'app/resources/api/v2/lot_resource.rb', line 69

attribute :lot_number, write_once: true

#lot_typeLotTypeResource

Note:

This relationship is required when creating a lot.

The type of lot, which governs the behaviour of a Lot.

Returns:



79
# File 'app/resources/api/v2/lot_resource.rb', line 79

has_one :lot_type

#tag_layout_templateTagLayoutTemplateResource (readonly)

Note:

This relationship is loaded only when explicitly included.

A tag layout template associated with this lot, used for specific processing workflows.

Returns:



98
# File 'app/resources/api/v2/lot_resource.rb', line 98

has_one :tag_layout_template, eager_load_on_include: false

#templateTemplateResource

Note:

This relationship is required when creating a lot.

The template associated with this lot, which may vary depending on the lot type. This is a polymorphic relationship, meaning it can be linked to different types of templates.

Returns:



92
# File 'app/resources/api/v2/lot_resource.rb', line 92

has_one :template, polymorphic: true

#userUserResource

Note:

This relationship is required when creating a lot.

The user who created or registered this lot.

Returns:



85
# File 'app/resources/api/v2/lot_resource.rb', line 85

has_one :user

#uuidString (readonly)

Note:

This identifier is automatically assigned upon creation and cannot be modified.

Returns The universally unique identifier (UUID) of the lot.

Returns:

  • (String)

    The universally unique identifier (UUID) of the lot.



64
# File 'app/resources/api/v2/lot_resource.rb', line 64

attribute :uuid, readonly: true

Instance Method Details

#tag_layout_template_idString?

Retrieves the template ID for the associated tag layout template.

Returns:

  • (String, nil)

    The template ID, or nil if no template is set.



107
108
109
# File 'app/resources/api/v2/lot_resource.rb', line 107

def tag_layout_template_id
  template_id
end