Class: Ecfr::RendererService::Origin

Inherits:
Base show all
Extended by:
ResponseHelper
Defined in:
lib/ecfr/renderer_service/origin.rb,
lib/ecfr/testing/extensions/renderer_service/origin_extensions.rb

Overview

The Origin API endpoint returns metadata about Source and Authority for the requested hierachy. This metadata is provided for each part in the requested hierarchy as well as any subpart and section/appendix if there are any specific to those levels.

Constant Summary collapse

ORIGIN_PATH =
"v1/origin"

Constants inherited from Base

Base::HTML_PATH

Constants inherited from Base

Base::SUPPORTED_ARRAY_ACCESSORS

Instance Attribute Summary collapse

Attributes inherited from Base

#metadata, #request_data, #response_status, #results

Class Method Summary collapse

Methods included from ResponseHelper

stubbed_response

Methods inherited from Base

base_url, service_name, service_path

Methods inherited from Base

basic_auth_client_options, #each, #initialize, metadata, metadata_key, result_key

Methods included from Extensible

#inherited

Methods included from AttributeMethodDefinition

included, #initialize

Methods inherited from Client

build, cache_key, client, client_pool, delete, execute, get, handle_response, perform, post, purge

Methods included from ParallelClient

included

Constructor Details

This class inherits a constructor from Ecfr::Base

Instance Attribute Details

#authority[:string] (readonly)

the Authority content for the level

Returns:

  • ([:string])


24
25
26
# File 'lib/ecfr/renderer_service/origin.rb', line 24

attribute :authority,
type: Array(:string),
desc: "the Authority content for the level"

#currentBoolean (readonly)

whether this is the hierarchy level requested (instead of an ancestor or descendant)

Returns:

  • (Boolean)


31
32
33
# File 'lib/ecfr/renderer_service/origin.rb', line 31

attribute :current,
type: :boolean,
desc: "whether this is the hierarchy level requested (instead of an ancestor or descendant)"

#hierarchyEcfr::Common::Hierarchy (readonly)



35
36
# File 'lib/ecfr/renderer_service/origin.rb', line 35

attribute :hierarchy,
type: Ecfr::Common::Hierarchy

#identifierString (readonly)

the identifier portion of the level (ex. ‘121’)

Returns:

  • (String)


13
14
# File 'lib/ecfr/renderer_service/origin.rb', line 13

attribute :identifier,
desc: "the identifier portion of the level (ex. '121')"

#label_levelString (readonly)

the full identifier and label (ex. ‘Part 121’)

Returns:

  • (String)


15
16
# File 'lib/ecfr/renderer_service/origin.rb', line 15

attribute :label_level,
desc: "the full identifier and label (ex. 'Part 121')"

#levelString (readonly)

the level being represented (ex. ‘part’)

Returns:

  • (String)


17
18
# File 'lib/ecfr/renderer_service/origin.rb', line 17

attribute :level,
desc: "the level being represented (ex. 'part')"

the path portion of a link to the content for the hierarchy provided

Returns:

  • (String)


19
20
# File 'lib/ecfr/renderer_service/origin.rb', line 19

attribute :link,
desc: "the path portion of a link to the content for the hierarchy provided"

#source[:string] (readonly)

the Source content for the level

Returns:

  • ([:string])


27
28
29
# File 'lib/ecfr/renderer_service/origin.rb', line 27

attribute :source,
type: Array(:string),
desc: "the Source content for the level"

#titleString (readonly)

the description of the level

Returns:

  • (String)


21
22
# File 'lib/ecfr/renderer_service/origin.rb', line 21

attribute :title,
desc: "the description of the level"

Class Method Details

.find(date, title_number, params = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ecfr/renderer_service/origin.rb', line 40

def self.find(date, title_number, params = {})
  supported_params = (
    Ecfr::Constants::Hierarchy::HIERARCHY_LEVELS[1, 8] +
      [:build_id]
  ).map(&:to_sym)

  perform(
    :get,
    origin_path(date, title_number),
    params: params.slice(*supported_params)
  )
end

.response_for(origins) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/ecfr/testing/extensions/renderer_service/origin_extensions.rb', line 4

def self.response_for(origins)
  results = {
    origins: origins.is_a?(Array) ? origins : [origins]
  }

  build(
    response: stubbed_response(results.to_json)
  )
end