1 <?php
2 namespace MailChimp\Automations;
3
4 use MailChimp\MailChimp as MailChimp;
5
6 class Automations extends MailChimp
7 {
8
9 /**
10 * Get a summary of an account’s Automations.
11 *
12 * array["fields"] array list of strings of response fields to return
13 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
14 *
15 * @param array $query (See Above) OPTIONAL associative array of query parameters.
16 * @return object
17 */
18 public function getAutomations(array $query = [])
19 {
20 return self::execute("GET", "automations/", $query);
21 }
22
23 /**
24 * Get a summary of an individual Automation workflow’s settings and content.
25 *
26 * array["fields"] array list of strings of response fields to return
27 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
28 * @param string $workflow_id
29 * @param array $query (See Above) OPTIONAL associative array of query parameters.
30 * @return object
31 */
32 public function getAutomation($workflow_id, array $query = [])
33 {
34 return self::execute("GET", "automations/{$workflow_id}", $query);
35 }
36
37 /**
38 * Start all emails in an Automation workflow.
39 *
40 * @param string $workflow_id
41 */
42 public function startAutomation($workflow_id)
43 {
44 return self::execute("POST", "automations/{$workflow_id}/actions/start-all-emails");
45 }
46
47 /**
48 * Pause all emails in an Automation workflow.
49 *
50 * @param string $workflow_id
51 */
52 public function pauseAutomation($workflow_id)
53 {
54 return self::execute("POST", "automations/{$workflow_id}/actions/pause-all-emails");
55 }
56
57 /**
58 * Get a list of automated emails in a workflow
59 *
60 * array["fields"] array list of strings of response fields to return
61 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
62 * @param string $workflow_id
63 * @param array $query (See Above) OPTIONAL associative array of query parameters.
64 * @return object
65 */
66 public function getWorkflowEmails($workflow_id, array $query = [])
67 {
68 return self::execute("GET", "automations/{$workflow_id}/emails", $query);
69 }
70
71 /**
72 * Get information about a specific workflow email
73 *
74 * array["fields"] array list of strings of response fields to return
75 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
76 * @param string $workflow_id
77 * @param string $workflow_email_id
78 * @param array $query (See Above) OPTIONAL associative array of query parameters.
79 * @return object
80 */
81 public function getWorkflowEmail($workflow_id, $workflow_email_id, array $query = [])
82 {
83 return self::execute("GET", "automations/{$workflow_id}/emails/{$workflow_email_id}", $query);
84 }
85
86 /**
87 * Start an automated email
88 *
89 * @param string $workflow_id
90 * @param string $workflow_email_id
91 */
92 public function startWorkflowEmail($workflow_id,$workflow_email_id)
93 {
94 return self::execute("POST", "automations/{$workflow_id}/emails/{$workflow_email_id}/actions/start-all-emails");
95 }
96
97 /**
98 * Pause an automated email
99 *
100 * @param string $workflow_id
101 * @param string $workflow_email_id
102 */
103 public function pauseWorkflowEmail($workflow_id,$workflow_email_id)
104 {
105 return self::execute("POST", "automations/{$workflow_id}/emails/{$workflow_email_id}/actions/pause-all-emails");
106 }
107
108 /**
109 * View queued subscribers for an automated email
110 *
111 * array["fields"] array list of strings of response fields to return
112 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
113 * @param string $workflow_id
114 * @param string $workflow_email_id
115 * @param array $query (See Above) OPTIONAL associative array of query parameters.
116 * @return object
117 */
118 public function getWorkflowEmailQueue($workflow_id, $workflow_email_id, array $query = [])
119 {
120 return self::execute("GET", "automations/{$workflow_id}/emails/{$workflow_email_id}/queue", $query);
121 }
122
123 /**
124 * View specific subscriber in email queue
125 *
126 * array["fields"] array list of strings of response fields to return
127 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
128 * @param string $workflow_id
129 * @param string $workflow_email_id
130 * @param string $email_address
131 * @param array $query (See Above) OPTIONAL associative array of query parameters.
132 * @return object
133 */
134 public function getWorkflowEmailSubscriber($workflow_id, $workflow_email_id, $email_address, array $query = [])
135 {
136 $hash = self::getMemberHash($email_address);
137 return self::execute("GET", "automations/{$workflow_id}/emails/{$workflow_idEmailId}/queue/{$hash}", $query);
138 }
139
140 /**
141 * Add a subscriber to a workflow email
142 *
143 * @param string $workflow_id
144 * @param string $workflow_email_id
145 * @param string $email_address
146 */
147 public function addWorkflowEmailSubscriber($workflow_id, $workflow_email_id, $email_address)
148 {
149 $data = [ "email_address" => $email_address];
150 return self::execute("POST", "automations/{$workflow_id}/email/{$workflow_email_id}/queue", $data);
151 }
152
153 /**
154 * View all subscribers removed from a workflow
155 *
156 * array["fields"] array list of strings of response fields to return
157 * array["exclude_fields"] array list of strings of response fields to exclude (not to be used with "fields")
158 * @param string $workflow_id
159 */
160 public function getRemovedWorkflowSubscribers($workflow_id, array $query = [])
161 {
162 return self::execute("GET", "automations/{$workflow_id}/removed-subscribers", $query);
163 }
164
165 /**
166 * Remove subscriber from a workflow
167 *
168 * @param string $workflow_id
169 * @param string $workflow_email_id
170 * @param string $email_address
171 */
172 public function removeWorkflowSubscriber($workflow_id, $email_address)
173 {
174 $data = ["email_address" => $email_address];
175 return self::execute("POST", "automations/{$workflow_id}/removed-subscribers", $data);
176 }
177
178 }
179