Class: Api::V2::WorkOrderResource

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

Overview

TODO:

This documentation does not yet include a detailed description of what this resource (really) represents.

TODO:

This documentation does not yet include detailed descriptions for relationships, attributes and filters.

TODO:

This documentation does not yet include any example usage of the API via cURL or similar.

Note:

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

Provides a JSON:API representation of WorkOrder. Work orders provide an abstraction of requests for exposure to external applications. They are intended to allow us to update the internal representation, while maintaining an external interface.

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.

Constant Summary collapse

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

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 Method Details

#optionsObject



70
71
72
73
74
# File 'app/resources/api/v2/work_order_resource.rb', line 70

def options
  _model.example_request..attributes.reject do |key, value|
    IGNORED_METADATA_FIELDS.include?(key) || value.blank?
  end
end

#order_typeObject



66
67
68
# File 'app/resources/api/v2/work_order_resource.rb', line 66

def order_type
  _model.work_order_type.name
end

#project_idObject

JSONAPI::Resource doesn’t support has_one through relationships by default



58
59
60
# File 'app/resources/api/v2/work_order_resource.rb', line 58

def project_id
  _model.example_request.initial_project_id
end

#quantityObject

Field Methods



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

def quantity
  { number: _model.quantity_value, unit_of_measurement: _model.quantity_units }
end

#source_receptacle_idObject



62
63
64
# File 'app/resources/api/v2/work_order_resource.rb', line 62

def source_receptacle_id
  _model.example_request.asset_id
end

#study_idObject

JSONAPI::Resource doesn’t support has_one through relationships by default



53
54
55
# File 'app/resources/api/v2/work_order_resource.rb', line 53

def study_id
  _model.example_request.initial_study_id
end