ys-passkit-and-cherrypie-client
Version:
Simple Node.js client for passkit and cherrypie plugin
2,550 lines (603 loc) • 28.5 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: CherryPieClient</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: CherryPieClient</h1>
<section>
<header>
<h2>CherryPieClient</h2>
<div class="class-description">this is CherryPieClient class</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="CherryPieClient"><span class="type-signature"></span>new CherryPieClient<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line39">line 39</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="base64url"><span class="type-signature"></span>base64url<span class="signature">(input)</span><span class="type-signature"> → {*}</span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line133">line 133</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="createCampaign"><span class="type-signature"></span>createCampaign<span class="signature">(data, callback)</span><span class="type-signature"></span></h4>
<div class="description">
Create new campaign in cherry pie
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">Object with campaigns contains these props:
- name {string} (required) Your campaign’s unique identifier. The name must only contain letters, numbers or the underscore character. and cannot contain any spaces (e.g. Happy_birthday_2018). Please note, this identifier cannot be changed after the campaign is created.
- passbookCertId {string} (required) This is the certificate ID that is generated by PassKit when you upload a certificate, you can check which certificates you have uploaded with the list certificates endpoint. Please note, the Certificate ID cannot be changed after the campaign is created.
- status {string} The value must be either ACTIVE, FROZEN, or INVALID. Default is ACTIVE. The campaign status controls whether passes can be issued or not. ACTIVE - Enables passes to be issued.FROZEN - Passes cannot be issued, existing passes are not affected and this value can be changed back to ACTIVE. INVALID - Passes cannot be issued and all existing passes will be set to invalid. Once the INVALID value is set, it cannot be changed.
- displayName {string} This is the human friendly version of your campaign name, this will be displayed to customers when they are looking to download their pass.
- description {string} This is your campaign description. The description will be displayed when customers are downloading their pass. This value should detail the campaign offers and customer benefits.
- startDate {ISO8601 datetime} (required) The campaign start date. Passes cannot be issued before this time and date.
- meta {JSONObject} Metadata to store in campaign level. This data is invisiable to users.
- endDate {ISO8601 datetime} The campaign end date. Passes cannot be issued after this date and time, and all existing passes will be set to voided.
- maxIssue {integer}</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">standart callback function(error,response);</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line275">line 275</a>
</li></ul></dd>
</dl>
<h4 class="name" id="createTemplate"><span class="type-signature"></span>createTemplate<span class="signature">(data, callback)</span><span class="type-signature"></span></h4>
<div class="description">
create template for campaign
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">standart callback function(error,response);</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line368">line 368</a>
</li></ul></dd>
</dl>
<h4 class="name" id="doQuery"><span class="type-signature"></span>doQuery<span class="signature">(http_method, endpoint, req_data, http_options, callback)</span><span class="type-signature"></span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>http_method</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>endpoint</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>req_data</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>http_options</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line184">line 184</a>
</li></ul></dd>
</dl>
<h4 class="name" id="generateJWT"><span class="type-signature"></span>generateJWT<span class="signature">(key, secret)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Generate token from pair key & secret
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>secret</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line72">line 72</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="genTokenSign"><span class="type-signature"></span>genTokenSign<span class="signature">(token, secret)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
generate token sign
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>token</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>secret</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line114">line 114</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="get_default_options"><span class="type-signature"></span>get_default_options<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Function to retrive the default options
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line50">line 50</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getAuthorization"><span class="type-signature"></span>getAuthorization<span class="signature">()</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Returns value for Authorization header
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line172">line 172</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="getBaseUrl"><span class="type-signature"></span>getBaseUrl<span class="signature">()</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Prepare base url for API requests
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line162">line 162</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="getCampaign"><span class="type-signature"></span>getCampaign<span class="signature">(campaigName, callback)</span><span class="type-signature"></span></h4>
<div class="description">
Return campaign
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>campaigName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">campaign name</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">standart callback function(error,response);</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line287">line 287</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getCampaigns"><span class="type-signature"></span>getCampaigns<span class="signature">(callback)</span><span class="type-signature"></span></h4>
<div class="description">
Return all campaigns in Cherry Pie
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">standart callback function(error,response);</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line310">line 310</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getCampaignTemplates"><span class="type-signature"></span>getCampaignTemplates<span class="signature">(campaigName, callback)</span><span class="type-signature"></span></h4>
<div class="description">
Return all templates for campaign with name
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>campaigName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">campaign name</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">standart callback function(error,response);</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line321">line 321</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getCetificates"><span class="type-signature"></span>getCetificates<span class="signature">(callback)</span><span class="type-signature"></span></h4>
<div class="description">
Return all certificates for client
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">standart callback function(error,response);</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line331">line 331</a>
</li></ul></dd>
</dl>
<h4 class="name" id="setOptions"><span class="type-signature"></span>setOptions<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Function to initialize options on Client
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line58">line 58</a>
</li></ul></dd>
</dl>
<h4 class="name" id="updateCampaign"><span class="type-signature"></span>updateCampaign<span class="signature">(campaigName, data, callback)</span><span class="type-signature"></span></h4>
<div class="description">
Update campaign
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>campaigName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">campaign name</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">standart callback function(error,response);</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line300">line 300</a>
</li></ul></dd>
</dl>
<h4 class="name" id="uploadImage"><span class="type-signature"></span>uploadImage<span class="signature">(image, callback)</span><span class="type-signature"></span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>image</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">(required) Your campaign’s unique identifier. The name must only contain letters, numbers or the underscore character. and cannot contain any spaces (e.g. Happy_birthday_2018). Please note, this identifier cannot be changed after the campaign is created.</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">standart callback function(error,response);</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line341">line 341</a>
</li></ul></dd>
</dl>
<h4 class="name" id="urlConvertBase64"><span class="type-signature"></span>urlConvertBase64<span class="signature">(input)</span><span class="type-signature"> → {XML|string|void|*}</span></h4>
<div class="description">
Converts url to Base64
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cherrypie_CherryPieClient.js.html">cherrypie/CherryPieClient.js</a>, <a href="cherrypie_CherryPieClient.js.html#line147">line 147</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">XML</span>
|
<span class="param-type">string</span>
|
<span class="param-type">void</span>
|
<span class="param-type">*</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="CherryPieClient.html">CherryPieClient</a></li><li><a href="PasskitClient.html">PasskitClient</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Sep 28 2016 14:55:30 GMT+0200 (CEST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>