class OSvCRuby::AnalyticsReportResults
Attributes
filters[RW]
id[RW]
lookupName[RW]
Public Class Methods
new(**args)
click to toggle source
# File lib/osvc_ruby/classes/analytics_report_results.rb, line 14 def initialize(**args) @lookupName = args[:lookupName] @id = args[:id] @filters = [] end
Public Instance Methods
run(client)
click to toggle source
# File lib/osvc_ruby/classes/analytics_report_results.rb, line 22 def run(client) json_data = convert_to_json(self) ValidationsModule::check_client(client) response = OSvCRuby::Connect.post_or_patch(client,'analyticsReportResults',json_data) check_and_parse_response(response) end
Private Instance Methods
check_and_parse_response(response)
click to toggle source
# File lib/osvc_ruby/classes/analytics_report_results.rb, line 54 def check_and_parse_response(response) if response.code.to_i != 200 puts JSON.pretty_generate(response.body) response.body else body = JSON.parse(response.body) NormalizeModule.iterate_through_rows(body) end end
check_for_id_and_name(s)
click to toggle source
# File lib/osvc_ruby/classes/analytics_report_results.rb, line 48 def check_for_id_and_name(s) if s.lookupName.nil? && s.id.nil? raise ArgumentError, "AnalyticsReportResults must have an id or lookupName set" end end
convert_to_json(s)
click to toggle source
# File lib/osvc_ruby/classes/analytics_report_results.rb, line 37 def convert_to_json(s) json_data = {} check_for_id_and_name(s) s.instance_variables.each do|iv| key = iv.to_s.delete("@") value = instance_variable_get iv json_data[key] = value unless value.nil? end json_data end