Refactor hardcoded protocol_source in SearchService

This commit is contained in:
Jure Grabnar 2019-06-28 02:26:31 +02:00
parent 9be4fc2470
commit bc4b07cc0f
3 changed files with 4 additions and 2 deletions

View file

@ -7,7 +7,8 @@ class ExternalProtocolsController < ApplicationController
# GET list_external_protocols
def index
service_call = ProtocolImporters::SearchProtocolsService
.call(protocol_source: 'protocolsio/v3', query_params: index_params)
.call(protocol_source: index_params[:protocol_source],
query_params: index_params)
if service_call.succeed?
render json: {

View file

@ -11,7 +11,7 @@ module ProtocolImporters
def initialize(protocol_source:, query_params: {})
@protocol_source = protocol_source
@query_params = query_params
@query_params = query_params.except(:protocol_source)
@errors = Hash.new { |h, k| h[k] = {} }
end

View file

@ -9,6 +9,7 @@
<%= image_tag 'external_protocols/protocolsio_logo.png',
class: 'protocolsio-logo' %>
<span class='protocolsio-title'><%= t('protocols.index.external_protocols.protocolsio_title') %></span>
<%= hidden_field_tag 'protocol_source', 'protocolsio/v3' %>
</div>
<div class='input-group'>