Completed
Push — master ( ccf14c...6dc88d )
by Ryan
01:33
created

Analytics::getByCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 5
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace SevenShores\Hubspot\Resources;
4
5
class Analytics extends Resource
6
{
7
    /**
8
     * Get analytics data broken down by the specified category.
9
     *
10
     * @see https://developers.hubspot.com/docs/methods/analytics/get-analytics-data-breakdowns
11
     *
12
     * @param string $breakdown_by
13
     * @param string $time_period
14
     * @param string $startDate (YYYYMMDD)
15
     * @param string $endDate (YYYYMMDD)
16
     * @param array $params Array of optional parameters ['filterId', 'sort', 'sortDir','limit', 'offset']
17
     * @return \SevenShores\Hubspot\Http\Response
18
     */
19
    function getByCategory($breakdown_by, $time_period, $startDate, $endDate, $params = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
20
    {
21
        $endpoint = "https://api.hubapi.com/analytics/v2/reports/{$breakdown_by}/{$time_period}";
22
        $params = array_merge(compact('startDate', 'endDate'), $params);
23
24
        $queryString = build_query_string($params);
25
26
        return $this->client->request('get', $endpoint, [], $queryString);
27
    }
28
29
    /**
30
     * Get analytics data for specific objects, based on the type of object.
31
     *
32
     * @see https://developers.hubspot.com/docs/methods/analytics/get-analytics-data-by-object
33
     *
34
     * @param string $object_type
35
     * @param string $time_period
36
     * @param string $startDate (YYYYMMDD)
37
     * @param string $endDate (YYYYMMDD)
38
     * @param array $params Array of optional parameters ['filterId', 'sort', 'sortDir','limit', 'offset']
39
     * @return \SevenShores\Hubspot\Http\Response
40
     */
41
    function getByType($object_type, $time_period, $startDate, $endDate, $params = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
42
    {
43
        $endpoint = "https://api.hubapi.com/analytics/v2/reports/{$object_type}/{$time_period}";
44
        $params = array_merge(compact('startDate', 'endDate'), $params);
45
46
        $queryString = build_query_string($params);
47
48
        return $this->client->request('get', $endpoint, [], $queryString);
49
    }
50
51
    /**
52
     * Get analytics data for your HubSpot hosted content.
53
     *
54
     * @see https://developers.hubspot.com/docs/methods/analytics/get-data-for-hubspot-content
55
     *
56
     * @param string $content_type
57
     * @param string $time_period
58
     * @param string $startDate (YYYYMMDD)
59
     * @param string $endDate (YYYYMMDD)
60
     * @param array $params Array of optional parameters ['filterId', 'sort', 'sortDir','limit', 'offset']
61
     * @return \SevenShores\Hubspot\Http\Response
62
     */
63
    function getHosted($content_type, $time_period, $startDate, $endDate, $params = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
64
    {
65
        $endpoint = "https://api.hubapi.com/analytics/v2/reports/{$content_type}/{$time_period}";
66
        $params = array_merge(compact('startDate', 'endDate'), $params);
67
68
        $queryString = build_query_string($params);
69
70
        return $this->client->request('get', $endpoint, [], $queryString);
71
    }
72
73
    /**
74
     * Get Events.
75
     *
76
     * @see https://developers.hubspot.com/docs/methods/events/get_events
77
     *
78
     * @param array $params Array of optional parameters ['includeDeletes']
79
     * @return \SevenShores\Hubspot\Http\Response
80
     */
81
    function getEvents($params = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
82
    {
83
        $endpoint = "https://api.hubapi.com/reports/v2/events";
84
85
        $queryString = build_query_string($params);
86
87
        return $this->client->request('get', $endpoint, [], $queryString);
88
    }
89
90
    /**
91
     * Get all analytics views
92
     *
93
     * @see https://developers.hubspot.com/docs/methods/analytics-views/get-views
94
     *
95
     * @param array $params Array of optional parameters
96
     * @return \SevenShores\Hubspot\Http\Response
97
     */
98
    function getViews($params = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
99
    {
100
        $endpoint = "https://api.hubapi.com/analytics/v2/views";
101
102
        $queryString = build_query_string($params);
103
104
        return $this->client->request('get', $endpoint, [], $queryString);
105
    }
106
107
    /**
108
     * Get a Group of Events by ID
109
     *
110
     * @see https://developers.hubspot.com/docs/methods/events/get_events_by_id
111
     *
112
     * @param string $id Can be included multiple times to pull multiple events.
113
     * @param array $params Array of optional parameters ['includeDeletes']
114
     * @return \SevenShores\Hubspot\Http\Response
115
     */
116
    function getEventsById($id, $params = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
117
    {
118
        $endpoint = "https://api.hubapi.com/analytics/v2/views";
119
120
        $queryString = build_query_string($params);
121
122
        $params['id'] = $id;
123
124
        return $this->client->request('get', $endpoint, [], $queryString);
125
    }
126
127
    /**
128
     * Check for the existence of analytics data for an object type
129
     *
130
     * @see https://developers.hubspot.com/docs/methods/analytics/check_for_analytics_data_existence
131
     *
132
     * @param string $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
133
     * @param array $params Array of optional parameters
134
     * @return \SevenShores\Hubspot\Http\Response
135
     */
136
    function checkForExistence($objectType, $params = [])
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
137
    {
138
        $endpoint = "https://api.hubapi.com/analytics/v2/reports/{$objectType}/exists";
139
140
        $queryString = build_query_string($params);
141
142
        return $this->client->request('get', $endpoint, [], $queryString);
143
    }
144
}
145