ReportRequestCriteria   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 25
c 3
b 0
f 0
dl 0
loc 104
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A send() 0 19 2
1
<?php
2
/**
3
 * @link      https://dukt.net/analytics/
4
 * @copyright Copyright (c) 2022, Dukt
5
 * @license   https://github.com/dukt/analytics/blob/master/LICENSE.md
6
 */
7
8
namespace dukt\analytics\models;
9
10
use craft\base\Model;
11
use dukt\analytics\Plugin as Analytics;
12
13
/**
14
 * Class ReportRequestCriteria
15
 *
16
 * @package dukt\analytics\models
17
 */
18
class ReportRequestCriteria extends Model
19
{
20
    // Properties
21
    // =========================================================================
22
23
    /**
24
     * @var string View ID
25
     */
26
    public $viewId;
27
28
    /**
29
     * @var string Google Analytics View ID
30
     */
31
    public $gaViewId;
32
33
    /**
34
     * @var string Start date
35
     */
36
    public $startDate;
37
38
    /**
39
     * @var string End date
40
     */
41
    public $endDate;
42
43
    /**
44
     * @var string Sampling level
45
     */
46
    public $samplingLevel;
47
48
    /**
49
     * @var string Metrics
50
     */
51
    public $metrics;
52
53
    /**
54
     * @var array Dimensions
55
     */
56
    public $dimensions;
57
58
    /**
59
     * @var array Order Bys
60
     */
61
    public $orderBys;
62
63
    /**
64
     * @var int Page size
65
     */
66
    public $pageSize;
67
68
    /**
69
     * @var string A continuation token to get the next page of the results. Adding this to the request will return the rows after the pageToken.
70
     */
71
    public $pageToken;
72
73
    /**
74
     * @var string Filters expression
75
     */
76
    public $filtersExpression;
77
78
    /**
79
     * @var bool If set to false, the response does not include rows if all the retrieved metrics are equal to zero. The default is false which will exclude these rows.
80
     */
81
    public $includeEmptyRows;
82
83
    /**
84
     * @var bool If set to true, hides the total of all metrics for all the matching rows, for every date range. The default false and will return the totals.
85
     */
86
    public $hideTotals;
87
88
    /**
89
     * @var bool If set to true, hides the minimum and maximum across all matching rows. The default is false and the value ranges are returned.
90
     */
91
    public $hideValueRanges;
92
93
    // Public Methods
94
    // =========================================================================
95
96
    /**
97
     * Sends the request
98
     *
99
     * @param bool $toArray
100
     *
101
     * @return array
102
     */
103
    public function send(bool $toArray = false)
104
    {
105
        $response = array(
106
            'success' => false,
107
            'error' => false
108
        );
109
110
        try
111
        {
112
            $response['report'] = Analytics::$plugin->getApis()->getAnalyticsReporting()->getReport($this, $toArray);
113
            $response['success'] = true;
114
        }
115
        catch(\Exception $e)
116
        {
117
            $response['error'] = true;
118
            $response['errorMessage'] = $e->getMessage();
119
        }
120
121
        return $response;
122
    }
123
}