Class: Qa::LinkedData::AuthorityUrlService

Inherits:
Object
  • Object
show all
Defined in:
app/services/qa/linked_data/authority_url_service.rb

Class Method Summary collapse

Class Method Details

.build_url(action_config:, action:, action_request:, request_header: {}, substitutions: {}, subauthority: nil, language: nil) ⇒ Object

Note:

All parameters after request_header are deprecated and will be removed in the next major release.

Build a url for an authority/subauthority for the specified action.

Parameters:

  • action_config (Qa::Authorities::LinkedData::SearchConfig | Qa::Authorities::LinkedData::TermConfig)

    action configuration for the authority

  • action (Symbol)

    action with valid values :search or :term

  • action_request (String)

    the request the user is making of the authority (e.g. query text or term id/uri)

  • request_header (Hash) (defaults to: {})

    optional attributes that can be appended to the generated URL

  • replacements (Hash)

    a customizable set of options

  • subauthority (Hash) (defaults to: nil)

    a customizable set of options

  • language (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (subauthority:):

  • name (String)

    of a subauthority

Options Hash (language:):

  • languages (Array<Symbol>)

    for filtering returned literals

Returns:

  • a valid URL that submits the action request to the external authority



16
17
18
19
20
21
22
# File 'app/services/qa/linked_data/authority_url_service.rb', line 16

def build_url(action_config:, action:, action_request:, request_header: {}, substitutions: {}, subauthority: nil, language: nil) # rubocop:disable Metrics/ParameterLists
  request_header = build_request_header(substitutions, subauthority, language) if request_header.empty?
  action_validation(action)
  url_config = action_config.url_config
  selected_substitutions = url_config.extract_substitutions(combined_substitutions(action_config, action, action_request, request_header))
  Qa::IriTemplateService.build_url(url_config: url_config, substitutions: selected_substitutions)
end