Class: Api::V2::WorkOrderResource

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

Overview

Note:

the below example is currently broken, as work_order_type is a required attribute in the model

Provides a JSON:API representation of WorkOrder for managing work orders within the application.

A Work order groups requests together based on Submission and Asset providing a unified interface for external applications.

This resource can be accessed via the /api/v2/work_orders/ endpoint.

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 to create a new WorkOrder

POST /api/v2/work_orders/
{
  "data": {
    "type": "work_orders",
    "attributes": {
      "state": "pending",
      "work_order_type": "standard"
      // "order_type": "standard"
    },
    "relationships": {
    }
  }
}

GET request to retrieve all work orders

GET /api/v2/work_orders/

GET request to retrieve a specific work order with ID 123

GET /api/v2/work_orders/123/

Constant Summary collapse

IGNORED_METADATA_FIELDS =
%w[id request_id created_at updated_at].freeze

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

#at_riskBoolean

Note:

This attribute is optional.

Indicates whether the customer accepts responsibility

Returns:

  • (Boolean)

    true if customer accepts responsibility, false otherwise.



50
# File 'app/resources/api/v2/work_order_resource.rb', line 50

attribute :at_risk

#optionsObject (readonly)



57
# File 'app/resources/api/v2/work_order_resource.rb', line 57

attribute :options, readonly: true

#order_typeObject



65
# File 'app/resources/api/v2/work_order_resource.rb', line 65

attribute :order_type, write_once: true

#projectProjectResource

Note:

This relationship is write-once and cannot be modified after creation.

The project associated with the work order.

Returns:



94
# File 'app/resources/api/v2/work_order_resource.rb', line 94

has_one :project, write_once: true

#quantityObject



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

attribute :quantity, write_once: true

#samplesArray<SampleResource>

Note:

This relationship is write-once and cannot be modified after creation.

The samples related to the work order.

Returns:



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

has_many :samples, write_once: true

#source_receptaclePolymorphicResource

Note:

This relationship is write-once and cannot be modified after creation.

The source receptacle from which the work order originates.

Returns:

  • (PolymorphicResource)

    The source receptacle related to the work order.



100
# File 'app/resources/api/v2/work_order_resource.rb', line 100

has_one :source_receptacle, write_once: true, polymorphic: true

#state(: state) ⇒ Object

Filters work orders by their state.

Examples:

Use this filter to find work orders in “open” state:

GET /api/v2/work_orders?filter[state]=open


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

attribute :state

#studyStudyResource

Note:

This relationship is write-once and cannot be modified after creation.

The study associated with the work order.

Returns:



88
# File 'app/resources/api/v2/work_order_resource.rb', line 88

has_one :study, write_once: true

Instance Method Details

#project_idObject



152
153
154
# File 'app/resources/api/v2/work_order_resource.rb', line 152

def project_id
  _model.example_request.initial_project_id
end

#source_receptacle_idObject



159
160
161
# File 'app/resources/api/v2/work_order_resource.rb', line 159

def source_receptacle_id
  _model.example_request.asset_id
end

#study_idObject



145
146
147
# File 'app/resources/api/v2/work_order_resource.rb', line 145

def study_id
  _model.example_request.initial_study_id
end