Class: Api::V2::LotResource

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

Overview

TODO:

The below POST example is not currently supported by the API, but is included here for reference. This is because received_at is a required field in the model, but is not included in the resource. See Y25-236.

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.

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.

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/
{
  "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.



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

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:



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

has_one :lot_type

#lot_type_nameString? (readonly)

Retrieves the name of the lot type associated with this lot.

e.g. 'Pre Stamped Tags'

Returns:

  • (String, nil)

    The name of the lot type, or nil if no lot type is set.



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

attribute :lot_type_name, readonly: true

#lot_type_uuid=(value) ⇒ Object (writeonly)

This is declared for convenience where the LotType is not available to set as a relationship.

Parameters:

  • value (String)

    The UUID of the LotType related to this lot.



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

attribute :lot_type_uuid, writeonly: true

#qcablesArray<QcableResource>

Returns the Qcable resources related to this lot.

Returns:



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

has_many :qcables

#received_atDateTime

Note:

This field is required when creating a lot.

Returns The date and time when the lot was received.

Returns:

  • (DateTime)

    The date and time when the lot was received.



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

attribute :received_at, write_once: true

#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. This represents the same entity as template above, but is only relevant when template_type is TagLayoutTemplate.

Returns:



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

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 entity types (TagLayoutTemplate, Tag2LayoutTemplate and Labware/PlateTemplate at time of writing).

Returns:



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

has_one :template, polymorphic: true

#template_idString

Note:

This field is required when creating a lot. It enables setting the polymorphic template relationship.

Returns The template_id.

Returns:

  • (String)

    The template_id.



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

attribute :template_id

#template_nameString? (readonly)

Retrieves the name of the template associated with this lot. See template association below for more details.

e.g. 'TSsc384-PCR2-nCoV-2019/V3/B'

Returns:

  • (String, nil)

    The name of the template, or nil if no template is set.



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

attribute :template_name, readonly: true

#template_typeString

Note:

This field is required when creating a lot. It enables setting the polymorphic template relationship.

Returns The template_type.

Returns:

  • (String)

    The template_type.



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

attribute :template_type

#userUserResource

Note:

This relationship is required when creating a lot.

The user who created or registered this lot.

Returns:



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

has_one :user

#user_uuid=(value) ⇒ Void (writeonly)

Deprecated.

Use the user relationship instead. See Y25-236.

This is declared for convenience where the User is not available to set as a relationship. Setting this attribute alongside the user relationship will prefer the relationship value.

Parameters:

  • value (String)

    The UUID of the User who initiated this work completion.

Returns:

  • (Void)

See Also:



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

attribute :user_uuid, writeonly: true

#uuidObject (readonly)

A filter to return only lots with the given UUID.

Examples:

Filtering lots by UUID

GET /api/v2/lots?filter[uuid]=11111111-2222-3333-4444-555555666666


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

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.



144
145
146
# File 'app/resources/api/v2/lot_resource.rb', line 144

def tag_layout_template_id
  template_id
end