Completed
Pull Request — master (#98)
by
unknown
05:09
created

Events::trigger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 5
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace SevenShores\Hubspot\Resources;
4
5
class Events extends Resource
6
{
7
    /**
8
     * Trigger a custom event.
9
     *
10
     * This only works for enterprise accounts.
11
     *
12
     * @param  string $hubId               Your HubSpot portal ID ("Hub ID"). You can find your Hub ID in the
13
     *                                     footer of the HubSpot UI, or in the URL. For example, in this URL:
14
     *                                     "https://app.hubspot.com/reports/56043/events/" your Hub ID is "56043".
15
     * @param  string $eventId
16
     * @param  string $contactEmail        Contact email triggering the event.
17
     * @param  float  $contactRevenue      Optional - the monetary value this event means to you.
18
     * @param  array  $contactProperties   Optional - array of new contact properties.
19
     * @return \SevenShores\Hubspot\Http\Response
20
     */
21
    function trigger(
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...
22
        $hubId,
23
        $eventId,
24
        $contactEmail = null,
25
        $contactRevenue = null,
26
        $contactProperties = []
27
    ) {
28
        $endpoint = "http://track.hubspot.com/v1/event";
29
30
        $required['_a'] = $hubId;
31
        $required['_n'] = $eventId;
32
        $required['email'] = $contactEmail;
33
34
        $parameters = array_merge(
35
          $required,
36
          ['_m' => $contactRevenue]
37
          $contactProperties
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_VARIABLE, expecting ',' or ')'
Loading history...
38
        );
39
40
        $query_string = build_query_string($parameters);
41
42
        return $this->client->request('get', $endpoint, [], $query_string);
43
    }
44
}
45