Class: Api::V2::TransferResource

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

Overview

Note:

TransferRequestCollection is preferred, as it allows the client applications to control the transfer behaviour.

Note:

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

Note:

This resource cannot be modified after creation: its endpoint will not accept PATCH requests.

Provides a JSON:API representation of Transfer.

A transfer handles the transfer of material from one piece of labware to another. Different classes are used to determine exactly how the transfers are performed. For more information about JSON:API see the JSON:API Specifications or refer to the JSONAPI::Resources package for Sequencescape's implementation of the JSON:API standard.

Examples:

POST request for creating a new transfer with source and destination specified by UUID (deprecated)

POST /api/v2/transfers/
{
  "data": {
    "type": "transfers",
    "attributes": {
      "source_uuid": "11111111-2222-3333-4444-555555666666",
      "destination_uuid": "33333333-4444-5555-6666-777777888888",
      "user_uuid": "99999999-0000-1111-2222-333333444444"
    }
  }
}

POST request for creating a transfer with source and destination specified by relationships

POST /api/v2/transfers/
{
  "data": {
    "type": "transfers",
    "attributes": {
      "transfer_template_uuid": "9ab465da-7cdf-11ef-b4cc-000000000000"
    },
    "relationships": {
      "source": { "data": { "type": "labware", "id": 1 } },
      "destination": { "data": { "type": "labware", "id": 2 } },
      "user": { "data": { "type": "users", "id": "789" } }
    }
  }
}

GET request for retrieving all transfers

GET /api/v2/transfers/

GET request for a specific transfer with ID 123

GET /api/v2/transfers/123/

Instance Attribute Summary collapse

Class 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

#destinationLabwareResource, Void

The destination labware for the transfer. Setting this relationship alongside the destination_uuid attribute will override the attribute value.

Returns:



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

has_one :destination

#destination_uuidString, Void

Deprecated.

Use the destination relationship instead.

This attribute allows the user to specify the destination labware by UUID. Setting this attribute alongside the destination relationship will prefer the relationship value.

Returns:

  • (String, Void)

    the UUID of the destination labware.

See Also:



111
# File 'app/resources/api/v2/transfer_resource.rb', line 111

attribute :destination_uuid

#sourceLabwareResource

Note:

This relationship is required.

The source labware for the transfer. The type of the labware varies by the transfer type. Setting this relationship alongside the source_uuid attribute will override the attribute value.

Returns:



177
# File 'app/resources/api/v2/transfer_resource.rb', line 177

has_one :source, class_name: 'Labware'

#source_uuidVoid

Deprecated.

Use the source relationship instead.

This attribute allows the user to specify the source labware by UUID. Setting this attribute alongside the source relationship will prefer the relationship value.

Returns:

  • (Void)

See Also:



127
# File 'app/resources/api/v2/transfer_resource.rb', line 127

attribute :source_uuid

#transfer_template_uuid=(value) ⇒ Object (writeonly)

This is consumed by the transfers_controller and not stored in the model.



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

attribute :transfer_template_uuid, writeonly: true

#transfer_typeObject (readonly)

A filter to restrict the type of transfer to retrieve. Example usage: GET /api/v2/transfers?filter=Transfer::BetweenPlates One of the following types: - 'Transfer::BetweenPlateAndTubes' - 'Transfer::BetweenPlatesBySubmission' - 'Transfer::BetweenPlates' - 'Transfer::BetweenSpecificTubes' - 'Transfer::BetweenTubesBySubmission' - 'Transfer::FromPlateToSpecificTubesByPool' - 'Transfer::FromPlateToSpecificTubes' - 'Transfer::FromPlateToTubeByMultiplex' - 'Transfer::FromPlateToTubeBySubmission' - 'Transfer::FromPlateToTube'



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

attribute :transfer_type, delegate: :sti_type, readonly: true

#transfersHash

A hash of transfers made, usually populated by a TransferTemplate used during the creation of the Transfer. This method varies depending on the type of transfer being performed.

Returns:

  • (Hash)

    A hash of transfer details.



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

attribute :transfers

#userUserResource

Note:

This relationship is required.

The user who requested the transfer. Setting this relationship alongside the user_uuid attribute will override the attribute value.

Returns:



184
# File 'app/resources/api/v2/transfer_resource.rb', line 184

has_one :user

#user_uuidObject

Note:

Some old records may not have a User relationship, even though it's required for new records.



143
# File 'app/resources/api/v2/transfer_resource.rb', line 143

attribute :user_uuid, write_once: true

#uuidString (readonly)

Note:

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

The UUID of the transfer.

Returns:

  • (String)

    The UUID of the transfer.



62
# File 'app/resources/api/v2/transfer_resource.rb', line 62

attribute :uuid, readonly: true

Class Method Details

.create(context) ⇒ Object

Custom Methods for Creation



158
159
160
# File 'app/resources/api/v2/transfer_resource.rb', line 158

def self.create(context)
  new(context[:model_type].new, context)
end