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

Mandrill_Subaccounts   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 174
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 174
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 4 1
A resume() 0 4 1
A pause() 0 4 1
A getList() 0 4 1
A add() 0 4 1
A __construct() 0 3 1
A info() 0 4 1
A delete() 0 4 1
1
<?php
2
3
class Mandrill_Subaccounts
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 subaccounts defined for the account, optionally filtered by a prefix
13
     * @param string $q an optional prefix to filter the subaccounts' ids and names
14
     * @return array the subaccounts for the account, up to a maximum of 1,000
15
     *     - return[] struct the individual subaccount info
16
     *         - id string a unique indentifier for the subaccount
17
     *         - name string an optional display name for the subaccount
18
     *         - custom_quota integer an optional manual hourly quota for the subaccount. If not specified, the hourly quota will be managed based on reputation
19
     *         - status string the current sending status of the subaccount, one of "active" or "paused"
20
     *         - reputation integer the subaccount's current reputation on a scale from 0 to 100
21
     *         - created_at string the date and time that the subaccount was created as a UTC string in YYYY-MM-DD HH:MM:SS format
22
     *         - first_sent_at string the date and time that the subaccount first sent as a UTC string in YYYY-MM-DD HH:MM:SS format
23
     *         - sent_weekly integer the number of emails the subaccount has sent so far this week (weeks start on midnight Monday, UTC)
24
     *         - sent_monthly integer the number of emails the subaccount has sent so far this month (months start on midnight of the 1st, UTC)
25
     *         - sent_total integer the number of emails the subaccount has sent since it was created
26
     */
27
    public function getList($q = null)
28
    {
29
        $_params = array("q" => $q);
30
        return $this->master->call('subaccounts/list', $_params);
31
    }
32
33
    /**
34
     * Add a new subaccount
35
     * @param string $id a unique identifier for the subaccount to be used in sending calls
36
     * @param string $name an optional display name to further identify the subaccount
37
     * @param string $notes optional extra text to associate with the subaccount
38
     * @param int $custom_quota an optional manual hourly quota for the subaccount. If not specified, Mandrill will manage this based on reputation
39
     * @return struct the information saved about the new subaccount
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 string a unique indentifier for the subaccount
41
     *     - name string an optional display name for the subaccount
42
     *     - custom_quota integer an optional manual hourly quota for the subaccount. If not specified, the hourly quota will be managed based on reputation
43
     *     - status string the current sending status of the subaccount, one of "active" or "paused"
44
     *     - reputation integer the subaccount's current reputation on a scale from 0 to 100
45
     *     - created_at string the date and time that the subaccount was created as a UTC string in YYYY-MM-DD HH:MM:SS format
46
     *     - first_sent_at string the date and time that the subaccount first sent as a UTC string in YYYY-MM-DD HH:MM:SS format
47
     *     - sent_weekly integer the number of emails the subaccount has sent so far this week (weeks start on midnight Monday, UTC)
48
     *     - sent_monthly integer the number of emails the subaccount has sent so far this month (months start on midnight of the 1st, UTC)
49
     *     - sent_total integer the number of emails the subaccount has sent since it was created
50
     */
51
    public function add($id, $name = null, $notes = null, $custom_quota = null)
52
    {
53
        $_params = array("id" => $id, "name" => $name, "notes" => $notes, "custom_quota" => $custom_quota);
54
        return $this->master->call('subaccounts/add', $_params);
55
    }
56
57
    /**
58
     * Given the ID of an existing subaccount, return the data about it
59
     * @param string $id the unique identifier of the subaccount to query
60
     * @return struct the information about the subaccount
61
     *     - id string a unique indentifier for the subaccount
62
     *     - name string an optional display name for the subaccount
63
     *     - notes string optional extra text to associate with the subaccount
64
     *     - custom_quota integer an optional manual hourly quota for the subaccount. If not specified, the hourly quota will be managed based on reputation
65
     *     - status string the current sending status of the subaccount, one of "active" or "paused"
66
     *     - reputation integer the subaccount's current reputation on a scale from 0 to 100
67
     *     - created_at string the date and time that the subaccount was created as a UTC string in YYYY-MM-DD HH:MM:SS format
68
     *     - first_sent_at string the date and time that the subaccount first sent as a UTC string in YYYY-MM-DD HH:MM:SS format
69
     *     - sent_weekly integer the number of emails the subaccount has sent so far this week (weeks start on midnight Monday, UTC)
70
     *     - sent_monthly integer the number of emails the subaccount has sent so far this month (months start on midnight of the 1st, UTC)
71
     *     - sent_total integer the number of emails the subaccount has sent since it was created
72
     *     - sent_hourly integer the number of emails the subaccount has sent in the last hour
73
     *     - hourly_quota integer the current hourly quota for the subaccount, either manual or reputation-based
74
     *     - last_30_days struct stats for this subaccount in the last 30 days
75
     *         - sent integer the number of emails sent for this subaccount in the last 30 days
76
     *         - hard_bounces integer the number of emails hard bounced for this subaccount in the last 30 days
77
     *         - soft_bounces integer the number of emails soft bounced for this subaccount in the last 30 days
78
     *         - rejects integer the number of emails rejected for sending this subaccount in the last 30 days
79
     *         - complaints integer the number of spam complaints for this subaccount in the last 30 days
80
     *         - unsubs integer the number of unsbuscribes for this subaccount in the last 30 days
81
     *         - opens integer the number of times emails have been opened for this subaccount in the last 30 days
82
     *         - unique_opens integer the number of unique opens for emails sent for this subaccount in the last 30 days
83
     *         - clicks integer the number of URLs that have been clicked for this subaccount in the last 30 days
84
     *         - unique_clicks integer the number of unique clicks for emails sent for this subaccount in the last 30 days
85
     */
86
    public function info($id)
87
    {
88
        $_params = array("id" => $id);
89
        return $this->master->call('subaccounts/info', $_params);
90
    }
91
92
    /**
93
     * Update an existing subaccount
94
     * @param string $id the unique identifier of the subaccount to update
95
     * @param string $name an optional display name to further identify the subaccount
96
     * @param string $notes optional extra text to associate with the subaccount
97
     * @param int $custom_quota an optional manual hourly quota for the subaccount. If not specified, Mandrill will manage this based on reputation
98
     * @return struct the information for the updated subaccount
99
     *     - id string a unique indentifier for the subaccount
100
     *     - name string an optional display name for the subaccount
101
     *     - custom_quota integer an optional manual hourly quota for the subaccount. If not specified, the hourly quota will be managed based on reputation
102
     *     - status string the current sending status of the subaccount, one of "active" or "paused"
103
     *     - reputation integer the subaccount's current reputation on a scale from 0 to 100
104
     *     - created_at string the date and time that the subaccount was created as a UTC string in YYYY-MM-DD HH:MM:SS format
105
     *     - first_sent_at string the date and time that the subaccount first sent as a UTC string in YYYY-MM-DD HH:MM:SS format
106
     *     - sent_weekly integer the number of emails the subaccount has sent so far this week (weeks start on midnight Monday, UTC)
107
     *     - sent_monthly integer the number of emails the subaccount has sent so far this month (months start on midnight of the 1st, UTC)
108
     *     - sent_total integer the number of emails the subaccount has sent since it was created
109
     */
110
    public function update($id, $name = null, $notes = null, $custom_quota = null)
111
    {
112
        $_params = array("id" => $id, "name" => $name, "notes" => $notes, "custom_quota" => $custom_quota);
113
        return $this->master->call('subaccounts/update', $_params);
114
    }
115
116
    /**
117
     * Delete an existing subaccount. Any email related to the subaccount will be saved, but stats will be removed and any future sending calls to this subaccount will fail.
118
     * @param string $id the unique identifier of the subaccount to delete
119
     * @return struct the information for the deleted subaccount
120
     *     - id string a unique indentifier for the subaccount
121
     *     - name string an optional display name for the subaccount
122
     *     - custom_quota integer an optional manual hourly quota for the subaccount. If not specified, the hourly quota will be managed based on reputation
123
     *     - status string the current sending status of the subaccount, one of "active" or "paused"
124
     *     - reputation integer the subaccount's current reputation on a scale from 0 to 100
125
     *     - created_at string the date and time that the subaccount was created as a UTC string in YYYY-MM-DD HH:MM:SS format
126
     *     - first_sent_at string the date and time that the subaccount first sent as a UTC string in YYYY-MM-DD HH:MM:SS format
127
     *     - sent_weekly integer the number of emails the subaccount has sent so far this week (weeks start on midnight Monday, UTC)
128
     *     - sent_monthly integer the number of emails the subaccount has sent so far this month (months start on midnight of the 1st, UTC)
129
     *     - sent_total integer the number of emails the subaccount has sent since it was created
130
     */
131
    public function delete($id)
132
    {
133
        $_params = array("id" => $id);
134
        return $this->master->call('subaccounts/delete', $_params);
135
    }
136
137
    /**
138
     * Pause a subaccount's sending. Any future emails delivered to this subaccount will be queued for a maximum of 3 days until the subaccount is resumed.
139
     * @param string $id the unique identifier of the subaccount to pause
140
     * @return struct the information for the paused subaccount
141
     *     - id string a unique indentifier for the subaccount
142
     *     - name string an optional display name for the subaccount
143
     *     - custom_quota integer an optional manual hourly quota for the subaccount. If not specified, the hourly quota will be managed based on reputation
144
     *     - status string the current sending status of the subaccount, one of "active" or "paused"
145
     *     - reputation integer the subaccount's current reputation on a scale from 0 to 100
146
     *     - created_at string the date and time that the subaccount was created as a UTC string in YYYY-MM-DD HH:MM:SS format
147
     *     - first_sent_at string the date and time that the subaccount first sent as a UTC string in YYYY-MM-DD HH:MM:SS format
148
     *     - sent_weekly integer the number of emails the subaccount has sent so far this week (weeks start on midnight Monday, UTC)
149
     *     - sent_monthly integer the number of emails the subaccount has sent so far this month (months start on midnight of the 1st, UTC)
150
     *     - sent_total integer the number of emails the subaccount has sent since it was created
151
     */
152
    public function pause($id)
153
    {
154
        $_params = array("id" => $id);
155
        return $this->master->call('subaccounts/pause', $_params);
156
    }
157
158
    /**
159
     * Resume a paused subaccount's sending
160
     * @param string $id the unique identifier of the subaccount to resume
161
     * @return struct the information for the resumed subaccount
162
     *     - id string a unique indentifier for the subaccount
163
     *     - name string an optional display name for the subaccount
164
     *     - custom_quota integer an optional manual hourly quota for the subaccount. If not specified, the hourly quota will be managed based on reputation
165
     *     - status string the current sending status of the subaccount, one of "active" or "paused"
166
     *     - reputation integer the subaccount's current reputation on a scale from 0 to 100
167
     *     - created_at string the date and time that the subaccount was created as a UTC string in YYYY-MM-DD HH:MM:SS format
168
     *     - first_sent_at string the date and time that the subaccount first sent as a UTC string in YYYY-MM-DD HH:MM:SS format
169
     *     - sent_weekly integer the number of emails the subaccount has sent so far this week (weeks start on midnight Monday, UTC)
170
     *     - sent_monthly integer the number of emails the subaccount has sent so far this month (months start on midnight of the 1st, UTC)
171
     *     - sent_total integer the number of emails the subaccount has sent since it was created
172
     */
173
    public function resume($id)
174
    {
175
        $_params = array("id" => $id);
176
        return $this->master->call('subaccounts/resume', $_params);
177
    }
178
}
179