Class: Api::V2::QcableResource

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

Overview

TODO:

The below POST example is currently broken, as qcable_creator is required in the model but it is not included in the resource.

Note:

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

Provides a JSON:API representation of Qcable which represents an element of a lot which needs to be approved by QC before it can be used.

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

Examples:

POST request to create a Qcable.

POST /api/v2/qcables/
{
  "data": {
    "type": "qcables",
    "attributes": {
    },
    "relationships": {
      "labware": {
        "data": { "type": "labware", "id": 57 }
      },
      "lot": {
        "data": { "type": "lots", "id": 1 }
      }
    }
  }
}

PATCH request to change the Asset of a Qcable.

PATCH /api/v2/qcables/
{
  "data": {
    "type": "qc_files",
    "id": 123
    "relationships": {
      "asset": {
        "data": {
          "type": "labware",
          "id": 456
        }
      }
    }
  }
}

GET request for all Qcable resources

GET /api/v2/qcables/

GET request for a Qcable with ID 123

GET /api/v2/qcables/123/

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

#assetLabwareResource

Deprecated.

Use the #labware relationship instead.

Returns the Labware resource associated with this Qcable.

Returns:



102
# File 'app/resources/api/v2/qcable_resource.rb', line 102

has_one :asset

#labwareLabwareResource

Returns the Labware resource associated with this Qcable.

Returns:



106
# File 'app/resources/api/v2/qcable_resource.rb', line 106

has_one :labware, relation_name: 'asset', foreign_key: :asset_id

#labware_barcodeHash (readonly)

Returns the barcodes of the labware associated with this Qcable. This includes the EAN13 barcode, the machine barcode and the human barcode. Note however that some of these barcodes may be nil.

Returns:

  • (Hash)

    the barcodes of the labware associated with this Qcable. This includes the EAN13 barcode, the machine barcode and the human barcode. Note however that some of these barcodes may be nil.



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

attribute :labware_barcode, readonly: true

#lotLotResource

Returns the Lot resource associated with this Qcable.

Returns:



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

has_one :lot

#stateString (readonly)

Returns a string representation of the state this Qcable is in. The state is changed by a state machine via events that occur as the Qcable is processed. The possible states are: - created - pending - failed - passed - available - destroyed - qc_in_progress - exhausted.

Returns:

  • (String)

    a string representation of the state this Qcable is in. The state is changed by a state machine via events that occur as the Qcable is processed. The possible states are: - created - pending - failed - passed - available - destroyed - qc_in_progress - exhausted.



89
# File 'app/resources/api/v2/qcable_resource.rb', line 89

attribute :state, readonly: true

#uuidString (readonly)

Returns the UUID of this Qcable.

Returns:

  • (String)

    the UUID of this Qcable.



93
# File 'app/resources/api/v2/qcable_resource.rb', line 93

attribute :uuid, readonly: true

Instance Method Details

#filter_barcodeObject

Apply a filter across all Qcable resource , matching by barcode.

Examples:

Get all Qcable resources with a specific barcode.

/api/v2/qcables?filter[barcode]=1234567890123


120
# File 'app/resources/api/v2/qcable_resource.rb', line 120

filter :barcode, apply: ->(records, value, _options) { records.with_barcode(value) }

#filter_uuidObject

Apply a filter across all Qcable resources, matching by UUID.

Examples:

Get all Qcable resources with a specific UUID.

/api/v2/qcables?filter[uuid]=12345678-1234-1234-1234-123456789012


126
# File 'app/resources/api/v2/qcable_resource.rb', line 126

filter :uuid, apply: ->(records, value, _options) { records.with_uuid(value) }