1: <?php
2:
3: class Mandrill_Urls {
4: public function __construct(Mandrill $master) {
5: $this->master = $master;
6: }
7:
8: /**
9: * Get the 100 most clicked URLs
10: * @return array the 100 most clicked URLs and their stats
11: * - return[] struct the individual URL stats
12: * - url string the URL to be tracked
13: * - sent integer the number of emails that contained the URL
14: * - clicks integer the number of times the URL has been clicked from a tracked email
15: * - unique_clicks integer the number of unique emails that have generated clicks for this URL
16: */
17: public function getList() {
18: $_params = array();
19: return $this->master->call('urls/list', $_params);
20: }
21:
22: /**
23: * Return the 100 most clicked URLs that match the search query given
24: * @param string $q a search query
25: * @return array the 100 most clicked URLs matching the search query
26: * - return[] struct the URL matching the query
27: * - url string the URL to be tracked
28: * - sent integer the number of emails that contained the URL
29: * - clicks integer the number of times the URL has been clicked from a tracked email
30: * - unique_clicks integer the number of unique emails that have generated clicks for this URL
31: */
32: public function search($q) {
33: $_params = array("q" => $q);
34: return $this->master->call('urls/search', $_params);
35: }
36:
37: /**
38: * Return the recent history (hourly stats for the last 30 days) for a url
39: * @param string $url an existing URL
40: * @return array the array of history information
41: * - return[] struct the information for a single hour
42: * - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
43: * - sent integer the number of emails that were sent with the URL during the hour
44: * - clicks integer the number of times the URL was clicked during the hour
45: * - unique_clicks integer the number of unique clicks generated for emails sent with this URL during the hour
46: */
47: public function timeSeries($url) {
48: $_params = array("url" => $url);
49: return $this->master->call('urls/time-series', $_params);
50: }
51:
52: /**
53: * Get the list of tracking domains set up for this account
54: * @return array the tracking domains and their status
55: * - return[] struct the individual tracking domain
56: * - domain string the tracking domain name
57: * - created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
58: * - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
59: * - cname struct details about the domain's CNAME record
60: * - valid boolean whether the domain's CNAME record is valid for use with Mandrill
61: * - valid_after string when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
62: * - error string an error describing the CNAME record, or null if the record is correct
63: * - valid_tracking boolean whether this domain can be used as a tracking domain for email.
64: */
65: public function trackingDomains() {
66: $_params = array();
67: return $this->master->call('urls/tracking-domains', $_params);
68: }
69:
70: /**
71: * Add a tracking domain to your account
72: * @param string $domain a domain name
73: * @return struct information about the domain
74: * - domain string the tracking domain name
75: * - created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
76: * - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
77: * - cname struct details about the domain's CNAME record
78: * - valid boolean whether the domain's CNAME record is valid for use with Mandrill
79: * - valid_after string when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
80: * - error string an error describing the CNAME record, or null if the record is correct
81: * - valid_tracking boolean whether this domain can be used as a tracking domain for email.
82: */
83: public function addTrackingDomain($domain) {
84: $_params = array("domain" => $domain);
85: return $this->master->call('urls/add-tracking-domain', $_params);
86: }
87:
88: /**
89: * Checks the CNAME settings for a tracking domain. The domain must have been added already with the add-tracking-domain call
90: * @param string $domain an existing tracking domain name
91: * @return struct information about the tracking domain
92: * - domain string the tracking domain name
93: * - created_at string the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
94: * - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
95: * - cname struct details about the domain's CNAME record
96: * - valid boolean whether the domain's CNAME record is valid for use with Mandrill
97: * - valid_after string when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
98: * - error string an error describing the CNAME record, or null if the record is correct
99: * - valid_tracking boolean whether this domain can be used as a tracking domain for email.
100: */
101: public function checkTrackingDomain($domain) {
102: $_params = array("domain" => $domain);
103: return $this->master->call('urls/check-tracking-domain', $_params);
104: }
105:
106: }
107:
108:
109: