Module: Sem4r::ReportDefinitionAccountExtension

Included in:
Account
Defined in:
lib/sem4r/report_definition/report_definition_account_extension.rb

Instance Method Summary collapse

Instance Method Details

#p_report_definitions(refresh = false) ⇒ Object

Prints on stdout the list of report definition contained into account

Parameters:

  • true (bool)

    if the list must be refreshed

Returns:

  • self



95
96
97
98
99
100
# File 'lib/sem4r/report_definition/report_definition_account_extension.rb', line 95

def p_report_definitions(refresh = false)
  report_definitions(refresh).each do |report_definition|
    puts report_definition.to_s
  end
  self
end

#report_definition { ... } ⇒ ReportDefinition

Create a new report definition

Examples:

account.report_definition do
  name "MyReport"
  ...
end

Yields:

  • report definition DSL

Returns:



86
87
88
# File 'lib/sem4r/report_definition/report_definition_account_extension.rb', line 86

def report_definition(&block)
  ReportDefinition.new(self, &block)
end

#report_definition_delete(repdef_or_id) ⇒ Object

Delete a report definition

@param[ReportDefinition, Number]



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sem4r/report_definition/report_definition_account_extension.rb', line 47

def report_definition_delete(repdef_or_id)
  if repdef_or_id.class == ReportDefinition
    report_definition = repdef_or_id
  else
    report_definition = ReportDefinition.new(self)
    report_definition.instance_eval { @id = repdef_or_id }
  end

  op           = ReportDefinitionOperation.remove(report_definition)
  soap_message = service.report_definition.mutate(credentials, op.to_xml)
  add_counters(soap_message.counters)

  unless @report_definitions
    @report_definition.delete_if { |repdef| repdef == report_definition.id }
  end
  report_definition.instance_eval { @id = -1 } # repdef status invalid/deleted
  self
end

#report_definition_delete_allObject

Delete all report definition



69
70
71
72
73
# File 'lib/sem4r/report_definition/report_definition_account_extension.rb', line 69

def report_definition_delete_all
  report_definitions.each do |repdef|
    repdef.delete
  end
end

#report_definitions(refresh = false) ⇒ Array of ReportDefinition

Returns an array of ReportDefinition

Parameters:

  • true (bool)

    if the list must be refreshed

Returns:



107
108
109
110
# File 'lib/sem4r/report_definition/report_definition_account_extension.rb', line 107

def report_definitions(refresh = false)
  _report_definitions unless @report_definitions and !refresh
  @report_definitions
end

#report_fields(report_type) ⇒ Object

Query the list of field for a report type

Parameters:

  • a (ReportDefinition::ReportTypes)

    value of



33
34
35
36
37
38
39
40
# File 'lib/sem4r/report_definition/report_definition_account_extension.rb', line 33

def report_fields(report_type)
  soap_message = service.report_definition.report_fields(credentials, report_type)
  add_counters(soap_message.counters)
  els = soap_message.response.xpath("//getReportFieldsResponse/rval")
  els.map do |el|
    ReportField.from_element(el)
  end
end