Class: Arclight::Requests::AeonExternalRequest

Inherits:
Object
  • Object
show all
Defined in:
app/models/arclight/requests/aeon_external_request.rb

Overview

This class should be used to turn configuration into a URL and POST form specifically aimed at Aeon’s external request endpoint (support.atlas-sys.com/hc/en-us/articles/360011820054-External-Request-Endpoint)

Instance Method Summary collapse

Constructor Details

#initialize(document, presenter) ⇒ AeonExternalRequest

Returns a new instance of AeonExternalRequest.



10
11
12
13
# File 'app/models/arclight/requests/aeon_external_request.rb', line 10

def initialize(document, presenter)
  @document = document
  @presenter = presenter
end

Instance Method Details

#configObject



15
16
17
# File 'app/models/arclight/requests/aeon_external_request.rb', line 15

def config
  @config ||= @document.repository_config.request_config_for_type('aeon_external_request_endpoint')
end

#dynamic_mappingsObject



31
32
33
34
35
# File 'app/models/arclight/requests/aeon_external_request.rb', line 31

def dynamic_mappings
  config['request_mappings']['accessor'].transform_values do |v|
    @document.public_send(v.to_sym)
  end
end

#form_mappingObject



23
24
25
# File 'app/models/arclight/requests/aeon_external_request.rb', line 23

def form_mapping
  static_mappings.merge(dynamic_mappings)
end

#static_mappingsObject



27
28
29
# File 'app/models/arclight/requests/aeon_external_request.rb', line 27

def static_mappings
  config['request_mappings']['static']
end

#urlObject



19
20
21
# File 'app/models/arclight/requests/aeon_external_request.rb', line 19

def url
  "#{config['request_url']}?#{url_params}"
end

#url_paramsObject



37
38
39
# File 'app/models/arclight/requests/aeon_external_request.rb', line 37

def url_params
  config['request_mappings']['url_params'].to_query
end