Class: ReferenceAddcommentRequest

Inherits:
ReferenceRequest show all
Defined in:
lib/refworks/reference/addcomment/reference_addcomment_request.rb

Class Method Summary collapse

Methods inherited from ReferenceRequest

call_class, generate_class_params

Methods inherited from Request

generate_signature

Class Method Details

.call_methodObject



2
3
4
# File 'lib/refworks/reference/addcomment/reference_addcomment_request.rb', line 2

def self.call_method
  'addcomment'
end

.generate_request_info(params) ⇒ Object



10
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
# File 'lib/refworks/reference/addcomment/reference_addcomment_request.rb', line 10

def self.generate_request_info(params)

  # get common Reference parameters
  class_params = generate_class_params(params)

  # query parameters for the addcomment call
  method_params = { :method => call_method,
                    :id => params[:id],
  }

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

  # construct XML payload
  xml_payload = '<RWRequest class="reference" method="addcomment">'
  params[:comments].each do |cmnt|
    title = cmnt[:title]
    name = cmnt[:name]
    inetinfo = cmnt[:inetinfo]
    comment = cmnt[:comment]
    parentid = cmnt[:parentid] || "-1"
    xml_payload << "<comment id=\"\" title=\"#{title}\" name=\"#{name}\" inetinfo=\"#{inetinfo}\" created=\"\" comment=\"#{comment}\" parentid=\"#{parentid}\"/>"
  end

  xml_payload << '</RWRequest>'

  message_body = xml_payload

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

.http_request_verbObject



6
7
8
# File 'lib/refworks/reference/addcomment/reference_addcomment_request.rb', line 6

def self.http_request_verb
  'POST'
end