Class: Api::V2::RequestResource

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

Overview

TODO:

This documentation does not yet include a detailed description of what this resource 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/requests/ endpoint.

Provides a JSON:API representation of Request.

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.

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

#library_typeObject



67
68
69
# File 'app/resources/api/v2/request_resource.rb', line 67

def library_type
  _model.try(:library_type)
end

#optionsObject

Field Methods



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/resources/api/v2/request_resource.rb', line 42

def options # rubocop:todo Metrics/AbcSize
  # We need to pass in the attribute details here, as eager loading the metadata just instantiates
  # Request::Metadata
  # TODO: Nuke the separate metadata classes and metaprogramming
  {}.tap do |attrs|
    _model
      .
      .attribute_value_pairs(_model.class::Metadata.attribute_details)
      .each { |attribute, value| attrs[attribute.name.to_s] = value unless value.nil? }
    _model
      .
      .association_value_pairs(_model.class::Metadata.association_details)
      .each { |association, value| attrs[association.name.to_s] = value unless value.nil? }
  end
end

#pre_capture_pool_idObject



63
64
65
# File 'app/resources/api/v2/request_resource.rb', line 63

def pre_capture_pool_id
  _model.pooled_request&.pre_capture_pool_id
end

#primer_panel_idObject

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



59
60
61
# File 'app/resources/api/v2/request_resource.rb', line 59

def primer_panel_id
  _model..primer_panel_id
end