Class: Api::V2::OrderResource

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

Overview

Note:

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

Note:

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

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

Examples:

POST request to create an order

POST /api/v2/orders/
{
  "data": {
    "type": "orders",
    "attributes": {
      "submission_template_uuid": "9daf8d28-7cdf-11ef-b4cc-000000000000",
      "submission_template_attributes": {
        "asset_uuids": ["e9580eea-fe6b-11ef-ba74-000000000000"],
        "autodetect_projects": true,
        "autodetect_studies": false,
        "request_options": {
          "library_type": "Chromium single cell 3 prime v3",
          "fragment_size_required_from": "200",
          "fragment_size_required_to": "800"
        },
        "user_uuid": "d8c22e20-f45d-11ef-8842-000000000000"
      }
    }
  }
}

GET request for all Order resources

GET /api/v2/orders/

GET request for a specific Order with ID 123

GET /api/v2/orders/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

#order_typeString (readonly)

Returns The Single Table Inheritance (STI) type of the Order.

Returns:

  • (String)

    The Single Table Inheritance (STI) type of the Order.



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

attribute :order_type, delegate: :sti_type, readonly: true

#projectProjectResource (readonly)

Note:

This can only be set once upon creation.

Returns The project associated with this Order.

Returns:



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

has_one :project, readonly: true

#request_optionsHash (readonly)

Note:

These can only be set upon creation.

Returns Request options for the Order.

Returns:

  • (Hash)

    Request options for the Order.



67
# File 'app/resources/api/v2/order_resource.rb', line 67

attribute :request_options, readonly: true

#request_typesArray<Integer> (readonly)

Note:

These can only be set upon creation.

Returns The IDs of request types associated with this Order.

Returns:

  • (Array<Integer>)

    The IDs of request types associated with this Order.



72
# File 'app/resources/api/v2/order_resource.rb', line 72

attribute :request_types, readonly: true

#studyStudyResource (readonly)

Note:

This can only be set once upon creation.

Returns The study associated with this Order.

Returns:



90
# File 'app/resources/api/v2/order_resource.rb', line 90

has_one :study, readonly: true

#submission_template_attributes=(value) ⇒ Object (writeonly)

Not stored, consumed by OrderProcessor.



124
# File 'app/resources/api/v2/order_resource.rb', line 124

attribute :submission_template_attributes, writeonly: true

#submission_template_uuid=(value) ⇒ Object (writeonly)

Not stored, consumed by OrderProcessor.



104
# File 'app/resources/api/v2/order_resource.rb', line 104

attribute :submission_template_uuid, writeonly: true

#userUserResource (readonly)

Note:

This can only be set once upon creation.

Returns The user who created this Order.

Returns:



95
# File 'app/resources/api/v2/order_resource.rb', line 95

has_one :user, readonly: true

#uuidString (readonly)

Returns The UUID of this Order.

Returns:

  • (String)

    The UUID of this Order.



76
# File 'app/resources/api/v2/order_resource.rb', line 76

attribute :uuid, readonly: true

Class Method Details

.create(context) ⇒ OrderResource

Handles the creation of an Order using the specified template.

Parameters:

  • context (Hash)

    The context containing template information.

Returns:



131
132
133
134
135
136
# File 'app/resources/api/v2/order_resource.rb', line 131

def self.create(context)
  return super if context[:template].nil?

  order = context[:template].create_order!(context[:template_attributes])
  new(order, context)
end