Skip to content

Commit

Permalink
Auto set marketing fields in newCustomer. Updated docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcguyer committed Nov 9, 2010
1 parent 09ed257 commit a2dfc47
Show file tree
Hide file tree
Showing 16 changed files with 222 additions and 73 deletions.
52 changes: 51 additions & 1 deletion Client.php
Expand Up @@ -40,6 +40,12 @@ class CheddarGetter_Client {
*/
private $_productId;

/**
* @var string Name to use for the marketing cookie
* @see setMarketingCookie
*/
private $_marketingCookieName = 'CGMK';

/**
* If you don't use Zend Framework, it's ok, the client will fallback to curl (so you need curl).
*
Expand Down Expand Up @@ -165,6 +171,28 @@ public function getProductId() {
return $this->_productId;
}

/**
* Set name for marketing metrics cookie
*
* @see setMarketingCookie
* @param $name string
* @return CheddarGetter_Client
*/
public function setMarketingCookieName($name) {
$this->_marketingCookieName = $name;
return $this;
}

/**
* Get marketing cookie name
*
* @see setMarketingCookie
* @return string
*/
public function getMarketingCookieName() {
return $this->_marketingCookieName;
}

/**
* Magic method wrapper
*
Expand Down Expand Up @@ -331,11 +359,33 @@ public function getAllCustomers(array $filters = null) {
* Create new customer
*
* @link https://cheddargetter.com/developers#add-customer
* @see setMarketingCookie
* @param array|null $data {@link https://cheddargetter.com/developers#add-customer}
* @return CheddarGetter_Response
* @throws CheddarGetter_Response_Exception
*/
public function newCustomer(array $data) {

if (isset($_COOKIE[$this->getMarketingCookieName()])) {
// if there's marketing cookie information, add it to the data
$marketingFields = array(
'firstContactDatetime',
'referer',
'campaignTerm',
'campaignName',
'campaignSource',
'campaignMedium',
'campaignContent'
);
$intersect = array_intersect($marketingFields, array_keys($data));
if (empty($intersect)) {
$cookieData = json_decode($_COOKIE[$this->getMarketingCookieName()]);
foreach ($marketingFields as $f) {
$data[$f] = $cookieData->{$f};
}
}
}

return new CheddarGetter_Response($this->request('/customers/new', $data));
}

Expand Down Expand Up @@ -678,7 +728,7 @@ private function _requireIdentifier($code, $id) {
* {@link http://support.cheddargetter.com/faqs/marketing-metrics/marketing-metrics More about CheddarGetter's marketing metrics tracking }
*
* @see newCustomer
* @param string $name
* @param string $cookieName
* @param int $expire
* @param string $path
* @param string $domain
Expand Down
171 changes: 119 additions & 52 deletions docs/CheddarGetter/CheddarGetter_Client.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/CheddarGetter/CheddarGetter_Client_Exception.html
Expand Up @@ -304,7 +304,7 @@ <h4>Inherited Methods</h4>
</div>

<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:18 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:57 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/CheddarGetter/CheddarGetter_Response.html
Expand Up @@ -1161,7 +1161,7 @@ <h4>Inherited Methods</h4>


<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:18 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:57 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/CheddarGetter/CheddarGetter_Response_Exception.html
Expand Up @@ -592,7 +592,7 @@ <h4>Inherited Methods</h4>
</div>

<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:18 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:57 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/CheddarGetter/_Client---Exception.php.html
Expand Up @@ -60,7 +60,7 @@ <h2 class="file-name"><img src="../media/images/Page_logo.png" alt="File" style=


<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:18 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:57 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/CheddarGetter/_Client.php.html
Expand Up @@ -60,7 +60,7 @@ <h2 class="file-name"><img src="../media/images/Page_logo.png" alt="File" style=


<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:17 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:56 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/CheddarGetter/_Response---Exception.php.html
Expand Up @@ -60,7 +60,7 @@ <h2 class="file-name"><img src="../media/images/Page_logo.png" alt="File" style=


<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:18 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:57 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/CheddarGetter/_Response.php.html
Expand Up @@ -60,7 +60,7 @@ <h2 class="file-name"><img src="../media/images/Page_logo.png" alt="File" style=


<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:18 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:57 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</div></body>
</html>
Expand Up @@ -145,7 +145,7 @@ <h1>example</h1>
</ol></div>
</div>
<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:18 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:56 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/classtrees_CheddarGetter.html
Expand Up @@ -26,7 +26,7 @@ <h2>Root class Exception</h2>
<li><a href="CheddarGetter/CheddarGetter_Client_Exception.html">CheddarGetter_Client_Exception</a></li><li><a href="CheddarGetter/CheddarGetter_Response_Exception.html">CheddarGetter_Response_Exception</a></li></ul>

<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:17 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:56 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</body>
</html>
24 changes: 20 additions & 4 deletions docs/elementindex.html
Expand Up @@ -237,16 +237,16 @@ <h3>Package indexes</h3>
<span class="method-title">getCustomer</span>
</dt>
<dd class="index-item-body">
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Response.html#methodgetCustomer">CheddarGetter_Response::getCustomer()</a> in Response.php</div>
<div class="index-item-description">Get an array representation of a single customer node</div>
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Client.html#methodgetCustomer">CheddarGetter_Client::getCustomer()</a> in Client.php</div>
<div class="index-item-description">Get a single customer</div>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">getCustomer</span>
</dt>
<dd class="index-item-body">
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Client.html#methodgetCustomer">CheddarGetter_Client::getCustomer()</a> in Client.php</div>
<div class="index-item-description">Get a single customer</div>
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Response.html#methodgetCustomer">CheddarGetter_Response::getCustomer()</a> in Response.php</div>
<div class="index-item-description">Get an array representation of a single customer node</div>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
Expand Down Expand Up @@ -385,6 +385,14 @@ <h3>Package indexes</h3>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">getMarketingCookieName</span>
</dt>
<dd class="index-item-body">
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Client.html#methodgetMarketingCookieName">CheddarGetter_Client::getMarketingCookieName()</a> in Client.php</div>
<div class="index-item-description">Get marketing cookie name</div>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">getPlan</span>
</dt>
<dd class="index-item-body">
Expand Down Expand Up @@ -654,6 +662,14 @@ <h3>Package indexes</h3>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">setMarketingCookieName</span>
</dt>
<dd class="index-item-body">
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Client.html#methodsetMarketingCookieName">CheddarGetter_Client::setMarketingCookieName()</a> in Client.php</div>
<div class="index-item-description">Set name for marketing metrics cookie</div>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">setPassword</span>
</dt>
<dd class="index-item-body">
Expand Down
24 changes: 20 additions & 4 deletions docs/elementindex_CheddarGetter.html
Expand Up @@ -288,16 +288,16 @@ <h2>[CheddarGetter] element index</h2>
<span class="method-title">getCustomer</span>
</dt>
<dd class="index-item-body">
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Response.html#methodgetCustomer">CheddarGetter_Response::getCustomer()</a> in Response.php</div>
<div class="index-item-description">Get an array representation of a single customer node</div>
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Client.html#methodgetCustomer">CheddarGetter_Client::getCustomer()</a> in Client.php</div>
<div class="index-item-description">Get a single customer</div>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">getCustomer</span>
</dt>
<dd class="index-item-body">
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Client.html#methodgetCustomer">CheddarGetter_Client::getCustomer()</a> in Client.php</div>
<div class="index-item-description">Get a single customer</div>
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Response.html#methodgetCustomer">CheddarGetter_Response::getCustomer()</a> in Response.php</div>
<div class="index-item-description">Get an array representation of a single customer node</div>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
Expand Down Expand Up @@ -436,6 +436,14 @@ <h2>[CheddarGetter] element index</h2>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">getMarketingCookieName</span>
</dt>
<dd class="index-item-body">
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Client.html#methodgetMarketingCookieName">CheddarGetter_Client::getMarketingCookieName()</a> in Client.php</div>
<div class="index-item-description">Get marketing cookie name</div>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">getPlan</span>
</dt>
<dd class="index-item-body">
Expand Down Expand Up @@ -705,6 +713,14 @@ <h2>[CheddarGetter] element index</h2>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">setMarketingCookieName</span>
</dt>
<dd class="index-item-body">
<div class="index-item-details"><a href="CheddarGetter/CheddarGetter_Client.html#methodsetMarketingCookieName">CheddarGetter_Client::setMarketingCookieName()</a> in Client.php</div>
<div class="index-item-description">Set name for marketing metrics cookie</div>
</dd>
<dt class="field">
<img src="media/images/Method.png" alt="Method" title="Method" />
<span class="method-title">setPassword</span>
</dt>
<dd class="index-item-body">
Expand Down
2 changes: 1 addition & 1 deletion docs/errors.html
Expand Up @@ -19,7 +19,7 @@ <h1>example.php</h1>
<h2>Warnings:</h2><br>
<b>Warning on line 131</b> - File "/home/marcguyer/cheddargetter/library/CheddarGetter/example/example.php" has no page-level DocBlock, use @package in the first DocBlock to create one<br>
<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:18 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:57 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -4,7 +4,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- Generated by phpDocumentor on Tue, 09 Nov 2010 21:13:17 +0000 -->
<!-- Generated by phpDocumentor on Tue, 09 Nov 2010 21:39:56 +0000 -->
<title>Generated Documentation</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
</head>
Expand Down
2 changes: 1 addition & 1 deletion docs/ric_README.html
Expand Up @@ -52,7 +52,7 @@

</pre>
<p class="notes" id="credit">
Documentation generated on Tue, 09 Nov 2010 21:13:17 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
Documentation generated on Tue, 09 Nov 2010 21:39:56 +0000 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</body>
</html>

0 comments on commit a2dfc47

Please sign in to comment.