Passed
Push — master ( d156dd...acd975 )
by Thomas
04:20 queued 01:05
created

Mandrill_Webhooks::info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
class Mandrill_Webhooks
4
{
5
6
    public function __construct(Mandrill $master)
7
    {
8
        $this->master = $master;
0 ignored issues
show
Bug Best Practice introduced by
The property master does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
9
    }
10
11
    /**
12
     * Get the list of all webhooks defined on the account
13
     * @return array the webhooks associated with the account
14
     *     - return[] struct the individual webhook info
15
     *         - id integer a unique integer indentifier for the webhook
16
     *         - url string The URL that the event data will be posted to
17
     *         - description string a description of the webhook
18
     *         - auth_key string the key used to requests for this webhook
19
     *         - events array The message events that will be posted to the hook
20
     *             - events[] string the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
21
     *         - created_at string the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
22
     *         - last_sent_at string the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
23
     *         - batches_sent integer the number of event batches that have ever been sent to this webhook
24
     *         - events_sent integer the total number of events that have ever been sent to this webhook
25
     *         - last_error string if we've ever gotten an error trying to post to this webhook, the last error that we've seen
26
     */
27
    public function getList()
28
    {
29
        $_params = array();
30
        return $this->master->call('webhooks/list', $_params);
31
    }
32
33
    /**
34
     * Add a new webhook
35
     * @param string $url the URL to POST batches of events
36
     * @param string $description an optional description of the webhook
37
     * @param array $events an optional list of events that will be posted to the webhook
38
     *     - events[] string the individual event to listen for
39
     * @return struct the information saved about the new webhook
0 ignored issues
show
Bug introduced by
The type struct was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
     *     - id integer a unique integer indentifier for the webhook
41
     *     - url string The URL that the event data will be posted to
42
     *     - description string a description of the webhook
43
     *     - auth_key string the key used to requests for this webhook
44
     *     - events array The message events that will be posted to the hook
45
     *         - events[] string the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
46
     *     - created_at string the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
47
     *     - last_sent_at string the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
48
     *     - batches_sent integer the number of event batches that have ever been sent to this webhook
49
     *     - events_sent integer the total number of events that have ever been sent to this webhook
50
     *     - last_error string if we've ever gotten an error trying to post to this webhook, the last error that we've seen
51
     */
52
    public function add($url, $description = null, $events = array())
53
    {
54
        $_params = array("url" => $url, "description" => $description, "events" => $events);
55
        return $this->master->call('webhooks/add', $_params);
56
    }
57
58
    /**
59
     * Given the ID of an existing webhook, return the data about it
60
     * @param int $id the unique identifier of a webhook belonging to this account
61
     * @return struct the information about the webhook
62
     *     - id integer a unique integer indentifier for the webhook
63
     *     - url string The URL that the event data will be posted to
64
     *     - description string a description of the webhook
65
     *     - auth_key string the key used to requests for this webhook
66
     *     - events array The message events that will be posted to the hook
67
     *         - events[] string the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
68
     *     - created_at string the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
69
     *     - last_sent_at string the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
70
     *     - batches_sent integer the number of event batches that have ever been sent to this webhook
71
     *     - events_sent integer the total number of events that have ever been sent to this webhook
72
     *     - last_error string if we've ever gotten an error trying to post to this webhook, the last error that we've seen
73
     */
74
    public function info($id)
75
    {
76
        $_params = array("id" => $id);
77
        return $this->master->call('webhooks/info', $_params);
78
    }
79
80
    /**
81
     * Update an existing webhook
82
     * @param int $id the unique identifier of a webhook belonging to this account
83
     * @param string $url the URL to POST batches of events
84
     * @param string $description an optional description of the webhook
85
     * @param array $events an optional list of events that will be posted to the webhook
86
     *     - events[] string the individual event to listen for
87
     * @return struct the information for the updated webhook
88
     *     - id integer a unique integer indentifier for the webhook
89
     *     - url string The URL that the event data will be posted to
90
     *     - description string a description of the webhook
91
     *     - auth_key string the key used to requests for this webhook
92
     *     - events array The message events that will be posted to the hook
93
     *         - events[] string the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
94
     *     - created_at string the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
95
     *     - last_sent_at string the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
96
     *     - batches_sent integer the number of event batches that have ever been sent to this webhook
97
     *     - events_sent integer the total number of events that have ever been sent to this webhook
98
     *     - last_error string if we've ever gotten an error trying to post to this webhook, the last error that we've seen
99
     */
100
    public function update($id, $url, $description = null, $events = array())
101
    {
102
        $_params = array("id" => $id, "url" => $url, "description" => $description, "events" => $events);
103
        return $this->master->call('webhooks/update', $_params);
104
    }
105
106
    /**
107
     * Delete an existing webhook
108
     * @param int $id the unique identifier of a webhook belonging to this account
109
     * @return struct the information for the deleted webhook
110
     *     - id integer a unique integer indentifier for the webhook
111
     *     - url string The URL that the event data will be posted to
112
     *     - description string a description of the webhook
113
     *     - auth_key string the key used to requests for this webhook
114
     *     - events array The message events that will be posted to the hook
115
     *         - events[] string the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
116
     *     - created_at string the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
117
     *     - last_sent_at string the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
118
     *     - batches_sent integer the number of event batches that have ever been sent to this webhook
119
     *     - events_sent integer the total number of events that have ever been sent to this webhook
120
     *     - last_error string if we've ever gotten an error trying to post to this webhook, the last error that we've seen
121
     */
122
    public function delete($id)
123
    {
124
        $_params = array("id" => $id);
125
        return $this->master->call('webhooks/delete', $_params);
126
    }
127
}
128