Class: Ecfr::AdminService::Issue

Inherits:
Base show all
Extended by:
ResponseHelper
Defined in:
lib/ecfr/admin_service/issue.rb,
lib/ecfr/admin_service/issue/change.rb,
lib/ecfr/testing/extensions/admin_service/issue_extensions.rb

Defined Under Namespace

Classes: Change

Constant Summary collapse

ISSUES_PATH =
"v1/issues"

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 Ecfr::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

#changes[Change] (readonly)

array of change types and CFR reference data

Returns:



25
26
27
# File 'lib/ecfr/admin_service/issue.rb', line 25

attribute :changes,
type: Array(Change),
desc: "array of change types and CFR reference data"

#descriptionString (readonly)

US standard date description

Returns:

  • (String)


8
9
# File 'lib/ecfr/admin_service/issue.rb', line 8

attribute :description,
desc: "US standard date description"

#end_dateDate (readonly)

end date of issue

Returns:

  • (Date)


15
16
17
# File 'lib/ecfr/admin_service/issue.rb', line 15

attribute :end_date,
type: :date,
desc: "end date of issue"

#issue_dateDate (readonly)

date of issue

Returns:

  • (Date)


18
19
20
# File 'lib/ecfr/admin_service/issue.rb', line 18

attribute :issue_date,
type: :date,
desc: "date of issue"

#nextString? (readonly)

Returns:

  • (String, nil)


32
33
# File 'lib/ecfr/admin_service/issue.rb', line 32

 :next,
desc: "date of next issue in ISO format"

#previousString? (readonly)

Returns:

  • (String, nil)


35
36
# File 'lib/ecfr/admin_service/issue.rb', line 35

 :previous,
desc: "date of previous issue in ISO format"

#start_dateDate (readonly)

start date of issue

Returns:

  • (Date)


21
22
23
# File 'lib/ecfr/admin_service/issue.rb', line 21

attribute :start_date,
type: :date,
desc: "start date of issue"

#titles[:integer] (readonly)

array of CFR title numbers affected in this issue

Returns:

  • ([:integer])


11
12
13
# File 'lib/ecfr/admin_service/issue.rb', line 11

attribute :titles,
type: Array(:integer),
desc: "array of CFR title numbers affected in this issue"

Class Method Details

.all[<Issue>]

Retrieves a summary of all available issues

Returns:

  • ([<Issue>])

    does not include the ‘changes` or `metadata` items



45
46
47
48
49
50
# File 'lib/ecfr/admin_service/issue.rb', line 45

def self.all
  perform(
    :get,
    "#{ISSUES_PATH}.json"
  )
end

.find(date:) ⇒ [<Issue>]

Retrieves detailed issue data for the specified date. If the isssue spans multiple days and date in that timespan will return the issue

Parameters:

  • <Date, (<Date, DateTime, Time, String<'current'>] date the string 'current' can be provided to retrieve the newest issue at time of request)

    DateTime, Time, String<‘current’>] date the string ‘current’ can be provided to retrieve the newest issue at time of request

Returns:

  • ([<Issue>])

    returns array containing single issue for the date provided



60
61
62
63
64
65
# File 'lib/ecfr/admin_service/issue.rb', line 60

def self.find(date:)
  perform(
    :get,
    issues_path(date)
  )
end

.issues_path(date) ⇒ Object



67
68
69
# File 'lib/ecfr/admin_service/issue.rb', line 67

def self.issues_path(date)
  "#{ISSUES_PATH}/#{date_slug_for(date)}"
end

.response_for(issues) ⇒ Object



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

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

  build(
    response: stubbed_response(results)
  )
end