Class: Ecfr::RendererService::Origin

Inherits:
Base
  • Object
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

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from ResponseHelper

stubbed_response

Methods inherited from Base

base_url, service_name, service_path

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"

#contentString (readonly)

potentially relevant references, notes, etc from containing levels

Returns:

  • (String)


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

attribute :content,
desc: "potentially relevant references, notes, etc from containing levels"

#currentBoolean (readonly)

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

Returns:

  • (Boolean)


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

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

#hierarchyEcfr::Common::Hierarchy (readonly)



37
38
# File 'lib/ecfr/renderer_service/origin.rb', line 37

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



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

def self.find(date, title_number, params = {})
  supported_params = Ecfr::Constants::Hierarchy::HIERARCHY_LEVELS[1, 8].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