Class: Velocify::Report

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/velocify/report.rb

Class Method Summary collapse

Methods included from Model

included

Class Method Details

.find_all(destruct: false, return_array: false) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/velocify/report.rb', line 8

def find_all destruct: false, return_array: false
  verify_credentials!

  request do
    destruct_response? destruct
    operation :get_reports
    authenticate? true
    transform do |resp|
      if return_array
        arrayify resp[:reports][:report]
      else
        resp
      end
    end
  end
end

.find_results(report_id:, template_values: [], destruct: false, return_array: false) ⇒ Object

Note:

The template_values option must contain an array of filter items. Filter items are objects that must respond to #field_title and #value.

Retrieves report results with or without a filter

Examples:

Including a filter item for retrieving report results with a last status change date filter

require 'ostruct'

item = OpenStruct.new field_title: 'Last Status Change Date', value: '4/12/2016 12:00:00'
Velocify::Report.find_results report_id: 123, template_values: [ item ]

Parameters:

  • report_id (Number)

    The id of the report

  • template_values (Array<#field_title, #value>) (defaults to: [])

    (Optional) A list of filter items



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/velocify/report.rb', line 39

def find_results report_id:, template_values: [], destruct: false, return_array: false
  verify_credentials!

  request do
    destruct_response? destruct
    operation :get_report_results
    authenticate? true
    xml GetReportResultsPayload.new(report_id, template_values)
    transform do |resp|
      if return_array
        if template_values.empty?
          arrayify resp[:report_results][:result]
        else
          arrayify resp[:report_results]
        end
      else
        resp
      end
    end
  end
end