Class: RetrieveAdvancesearchRequest

Inherits:
RetrieveRequest show all
Defined in:
lib/refworks/retrieve/advancesearch/retrieve_advancesearch_request.rb

Class Method Summary collapse

Methods inherited from RetrieveRequest

call_class, generate_class_params

Methods inherited from Request

generate_signature

Class Method Details

.call_methodObject



3
4
5
# File 'lib/refworks/retrieve/advancesearch/retrieve_advancesearch_request.rb', line 3

def self.call_method
  'advancesearch'
end

.generate_request_info(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/refworks/retrieve/advancesearch/retrieve_advancesearch_request.rb', line 11

def self.generate_request_info(params)

  # get common Retrieve parameters
  class_params = generate_class_params(params)

  # query parameters for the advancesearch call
  method_params = { :method => call_method,
                    :classic => params[:classic] || 'true',
                    :search => params[:search],
  }

  query_string_params = class_params.merge(method_params)
  # advancesearch also has a POST payload

  # construct ParameterList
  parameter_list = "<ParameterList>"
  params[:parameter_list].each do |param|
    connector = param[:connector] || "and"
    field = param[:field] || "ALL"
    searchempty = param[:searchempty] || "false"
    parameter_list << "<Parameter connector=\"#{connector}\" field=\"#{field}\" searchempty=\"#{searchempty}\">#{param[:search]}</Parameter>"
  end
  parameter_list << "</ParameterList>"

  # Folder processing
  folder_list = ""
  if params[:folders]
    folder_list << "<FolderList>"
    params[:folders].each do |f|
      folder_list << "<Folder>#{f}</Folder>"
    end
    folder_list << "</FolderList>"
  end

  message_body = "<AdvancedSearchStrategy>" + parameter_list + folder_list + "</AdvancedSearchStrategy>"

  # return the request info
  {:params => query_string_params, :body => message_body, :headers => {'Content-type' => 'text/xml'}}
end

.http_request_verbObject



7
8
9
# File 'lib/refworks/retrieve/advancesearch/retrieve_advancesearch_request.rb', line 7

def self.http_request_verb
  'POST'
end