Class: Velocify::GetReportResultsPayload

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/velocify/payload.rb

Instance Method Summary collapse

Constructor Details

#initialize(report_id, filter_items) ⇒ GetReportResultsPayload

Returns a new instance of GetReportResultsPayload.



52
53
54
55
56
# File 'lib/velocify/payload.rb', line 52

def initialize report_id, filter_items
  @filter_items = filter_items
  @report_id = report_id
  @credentials = {}
end

Instance Method Details

#authenticate(username:, password:) ⇒ Hash

Stores credentials for making an authenticated request

Parameters:

  • username (String)
  • password (String)

Returns:

  • (Hash)


63
64
65
# File 'lib/velocify/payload.rb', line 63

def authenticate username:, password:
  @credentials = Hash[:username, username, :password, password]
end

#renderString

Returns The XML payload to send to Velocify’s GetReportResults operation.

Returns:

  • (String)

    The XML payload to send to Velocify’s GetReportResults operation



68
69
70
71
72
73
74
75
# File 'lib/velocify/payload.rb', line 68

def render
  relative_path = File.join '..', '..', 'templates', 'get_report_results.xml.erb'
  current_dir = File.dirname(__FILE__)
  path = File.expand_path relative_path, current_dir
  template = File.read(path)
  xml_str = ERB.new(template).result binding
  { xml: xml_str.gsub(/[\n\t]*/, '').gsub(/[ ]{2,}/, '') }
end