Workflows::enrollmentsForContact()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SevenShores\Hubspot\Resources;
4
5
class Workflows extends Resource
6
{
7
    /**
8
     * Get all workflows.
9
     *
10
     * @return \SevenShores\Hubspot\Http\Response
11
     */
12
    function all()
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...
13
    {
14
        $endpoint = "https://api.hubapi.com/automation/v2/workflows";
15
16
        return $this->client->request('get', $endpoint);
17
    }
18
19
    /**
20
     * Get a specific workflow.
21
     *
22
     * @param int $id
23
     * @return \SevenShores\Hubspot\Http\Response
24
     */
25
    function getById($id)
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...
26
    {
27
        $endpoint = "https://api.hubapi.com/automation/v2/workflows/{$id}";
28
29
        return $this->client->request('get', $endpoint);
30
    }
31
32
    /**
33
     * Enroll a contact in a workflow.
34
     *
35
     * @param int    $workflow_id
36
     * @param string $email
37
     * @return \SevenShores\Hubspot\Http\Response
38
     */
39
    function enrollContact($workflow_id, $email)
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...
40
    {
41
        $endpoint = "https://api.hubapi.com/automation/v2/workflows/{$workflow_id}/enrollments/contacts/{$email}";
42
43
        return $this->client->request('post', $endpoint);
44
    }
45
46
    /**
47
     * Unenroll a contact from a workflow.
48
     *
49
     * @param int    $workflow_id
50
     * @param string $email
51
     * @return \SevenShores\Hubspot\Http\Response
52
     */
53
    function unenrollContact($workflow_id, $email)
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...
54
    {
55
        $endpoint = "https://api.hubapi.com/automation/v2/workflows/{$workflow_id}/enrollments/contacts/{$email}";
56
57
        return $this->client->request('delete', $endpoint);
58
    }
59
60
    /**
61
     * Create a new workflow.
62
     *
63
     * @param array $workflow The workflow properties
64
     * @return \SevenShores\Hubspot\Http\Response
65
     */
66
    function create($workflow)
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...
67
    {
68
        $endpoint = "https://api.hubapi.com/automation/v2/workflows";
69
70
        $options['json'] = $workflow;
71
72
        return $this->client->request('post', $endpoint, $options);
73
    }
74
75
    /**
76
     * Delete a workflow.
77
     *
78
     * @param int $id
79
     * @return \SevenShores\Hubspot\Http\Response
80
     */
81
    function delete($id)
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/automation/v2/workflows/{$id}";
84
85
        $queryString = build_query_string(['updatedAt' => time()]);
86
87
        return $this->client->request('delete', $endpoint, [], $queryString);
88
    }
89
90
    /**
91
     * Get current enrollments for a contact.
92
     *
93
     * @param int $contact_id
94
     * @return \SevenShores\Hubspot\Http\Response
95
     */
96
    function enrollmentsForContact($contact_id)
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...
97
    {
98
        $endpoint = "https://api.hubapi.com/automation/v2/workflows/enrollments/contacts/{$contact_id}";
99
100
        return $this->client->request('get', $endpoint);
101
    }
102
103
    /**
104
     * Get past events for contact from a workflow.
105
     *
106
     * @param int   $workflow_id
107
     * @param int   $contact_id
108
     * @param array $params Optional parameters.
109
     * @return \SevenShores\Hubspot\Http\Response
110
     */
111
    function pastEventsForContact($workflow_id, $contact_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...
112
    {
113
        $endpoint = " /automation/v2/workflows/{$workflow_id}/logevents/contacts/{$contact_id}/past";
114
115
        $queryString = build_query_string($params);
116
117
        return $this->client->request('get', $endpoint, [], $queryString);
118
    }
119
120
    /**
121
     * Get upcoming (scheduled) events for a contact in a workflow.
122
     *
123
     * @param int   $workflow_id
124
     * @param int   $contact_id
125
     * @param array $params
126
     * @return \SevenShores\Hubspot\Http\Response
127
     */
128
    function upcomingEventsForContact($workflow_id, $contact_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...
129
    {
130
        $endpoint = "https://api.hubapi.com/automation/v2/workflows/{$workflow_id}/logevents/contacts/{$contact_id}/upcoming";
131
132
        $queryString = build_query_string($params);
133
134
        return $this->client->request('get', $endpoint, [], $queryString);
135
    }
136
137
}
138