|
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 = []) |
|
|
|
|
|
|
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 = []) |
|
|
|
|
|
|
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 = []) |
|
|
|
|
|
|
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 = []) |
|
|
|
|
|
|
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 = []) |
|
|
|
|
|
|
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 = []) |
|
|
|
|
|
|
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 |
|
|
|
|
|
|
133
|
|
|
* @param array $params Array of optional parameters |
|
134
|
|
|
* @return \SevenShores\Hubspot\Http\Response |
|
135
|
|
|
*/ |
|
136
|
|
|
function checkForExistence($objectType, $params = []) |
|
|
|
|
|
|
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
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.