callpixelsjs-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/callpixelsjs/compile.rb +32 -0
- data/lib/callpixelsjs/rails/version.rb +1 -1
- data/vendor/documentation/javascript/v1/Callpixels.Campaign.html +404 -0
- data/vendor/documentation/javascript/v1/Callpixels.Number.html +1429 -0
- data/vendor/documentation/javascript/v1/campaign.js.html +137 -0
- data/vendor/documentation/javascript/v1/global.html +236 -0
- data/vendor/documentation/javascript/v1/index.html +63 -0
- data/vendor/documentation/javascript/v1/number.js.html +250 -0
- data/vendor/documentation/javascript/v1/scripts/linenumber.js +25 -0
- data/vendor/documentation/javascript/v1/scripts/prettify/Apache-License-2.0.txt +202 -0
- data/vendor/documentation/javascript/v1/scripts/prettify/lang-css.js +2 -0
- data/vendor/documentation/javascript/v1/scripts/prettify/prettify.js +28 -0
- data/vendor/documentation/javascript/v1/styles/jsdoc-default.css +333 -0
- data/vendor/documentation/javascript/v1/styles/prettify-jsdoc.css +111 -0
- data/vendor/documentation/javascript/v1/styles/prettify-tomorrow.css +132 -0
- metadata +29 -1
@@ -0,0 +1,137 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>JSDoc: Source: campaign.js</title>
|
6
|
+
|
7
|
+
<script src="scripts/prettify/prettify.js"> </script>
|
8
|
+
<script src="scripts/prettify/lang-css.js"> </script>
|
9
|
+
<!--[if lt IE 9]>
|
10
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
11
|
+
<![endif]-->
|
12
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14
|
+
</head>
|
15
|
+
|
16
|
+
<body>
|
17
|
+
|
18
|
+
<div id="main">
|
19
|
+
|
20
|
+
<h1 class="page-title">Source: campaign.js</h1>
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<section>
|
27
|
+
<article>
|
28
|
+
<pre class="prettyprint source linenums"><code>(function () {
|
29
|
+
// Dependencies
|
30
|
+
var RequestNumber = Callpixels.Base.RequestNumber;
|
31
|
+
/**
|
32
|
+
* @constructor
|
33
|
+
* @memberOf Callpixels
|
34
|
+
* @param {Object} options
|
35
|
+
* @param {String} options.campaign_key - Campaign key
|
36
|
+
* @example
|
37
|
+
* var campaign = new Callpixels.Campaign({ campaign_key: '67d9fb1917ae8f4eaff36831b41788c3' });
|
38
|
+
*/
|
39
|
+
var Campaign = function (options) {
|
40
|
+
|
41
|
+
function initialize(data) {
|
42
|
+
// initialize data store
|
43
|
+
self.store(data);
|
44
|
+
}
|
45
|
+
|
46
|
+
var self = this;
|
47
|
+
self.type = 'campaigns';
|
48
|
+
self.primary_key('campaign_key');
|
49
|
+
self.numbers = [];
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Fetch a campaign number.
|
53
|
+
* @memberOf Callpixels.Campaign
|
54
|
+
* @function request_number
|
55
|
+
* @instance
|
56
|
+
* @param {Object} tags - A collection of tags as key-value pairs. The number returned will match these tags.
|
57
|
+
* @param {getNumberCallback} callback - Callback fired after the request completes.
|
58
|
+
* @example
|
59
|
+
* campaign.request_number({calling_about: 'support'}, function (number) {
|
60
|
+
* alert(number.get('number'))
|
61
|
+
* });
|
62
|
+
*/
|
63
|
+
self.request_number = function (tags, callback) {
|
64
|
+
// assign the tags (this is important since it runs it through set_number_matching_tags)
|
65
|
+
self.set('number_matching_tags', tags);
|
66
|
+
// request the number
|
67
|
+
new RequestNumber(self.get('campaign_key', 'number_matching_tags')).perform(function (data) {
|
68
|
+
// initialize number
|
69
|
+
var number = new Callpixels.Number(data.number);
|
70
|
+
// call callback
|
71
|
+
callback.apply(self, [number]);
|
72
|
+
});
|
73
|
+
};
|
74
|
+
/**
|
75
|
+
* Callpixels.Campaign#request_number callback fired after the request completes.
|
76
|
+
* @callback getNumberCallback
|
77
|
+
* @param {Callpixels.Number} - The number that was returned
|
78
|
+
*/
|
79
|
+
|
80
|
+
self.numbers = function () {
|
81
|
+
var output = [];
|
82
|
+
if (typeof(Callpixels.Base.Data._store) !== 'undefined') {
|
83
|
+
// get numbers
|
84
|
+
var numbers = Callpixels.Base.Data._store['numbers'];
|
85
|
+
// present?
|
86
|
+
if (typeof(numbers) !== 'undefined') {
|
87
|
+
// collect numbers matching this campaign
|
88
|
+
for (var primary_key in numbers) {
|
89
|
+
var number = numbers[primary_key];
|
90
|
+
if (self.get('campaign_key') == number.campaign_key) {
|
91
|
+
output.push(new Callpixels.Number(number));
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
return output;
|
97
|
+
};
|
98
|
+
|
99
|
+
self.set_number_matching_tags = function (tags) {
|
100
|
+
if (typeof(tags) === 'string') {
|
101
|
+
tags = Callpixels.Number.extract_tags_from_string(tags);
|
102
|
+
}
|
103
|
+
if (tags && (typeof tags === "object") && !(tags instanceof Array)) {
|
104
|
+
return tags
|
105
|
+
}
|
106
|
+
else {
|
107
|
+
throw "ArgumentError: Expected number_matching_tags to be an object. eg: {tag: 'value'}";
|
108
|
+
}
|
109
|
+
};
|
110
|
+
|
111
|
+
initialize(options);
|
112
|
+
};
|
113
|
+
Campaign.prototype = new Callpixels.Base.Model();
|
114
|
+
Callpixels.Campaign = Campaign;
|
115
|
+
})();</code></pre>
|
116
|
+
</article>
|
117
|
+
</section>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
</div>
|
123
|
+
|
124
|
+
<nav>
|
125
|
+
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Callpixels.Campaign.html">Campaign</a></li><li><a href="Callpixels.Number.html">Number</a></li></ul><h3><a href="global.html">Global</a></h3>
|
126
|
+
</nav>
|
127
|
+
|
128
|
+
<br clear="both">
|
129
|
+
|
130
|
+
<footer>
|
131
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 14:51:39 GMT-0400 (EDT)
|
132
|
+
</footer>
|
133
|
+
|
134
|
+
<script> prettyPrint(); </script>
|
135
|
+
<script src="scripts/linenumber.js"> </script>
|
136
|
+
</body>
|
137
|
+
</html>
|
@@ -0,0 +1,236 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>JSDoc: Global</title>
|
6
|
+
|
7
|
+
<script src="scripts/prettify/prettify.js"> </script>
|
8
|
+
<script src="scripts/prettify/lang-css.js"> </script>
|
9
|
+
<!--[if lt IE 9]>
|
10
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
11
|
+
<![endif]-->
|
12
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14
|
+
</head>
|
15
|
+
|
16
|
+
<body>
|
17
|
+
|
18
|
+
<div id="main">
|
19
|
+
|
20
|
+
<h1 class="page-title">Global</h1>
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<section>
|
27
|
+
|
28
|
+
<header>
|
29
|
+
<h2>
|
30
|
+
|
31
|
+
</h2>
|
32
|
+
|
33
|
+
</header>
|
34
|
+
|
35
|
+
<article>
|
36
|
+
<div class="container-overview">
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
<dl class="details">
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
</dl>
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
</div>
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<h3 class="subsection-title">Type Definitions</h3>
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
|
97
|
+
<dt>
|
98
|
+
<h4 class="name" id="getNumberCallback"><span class="type-signature"></span>getNumberCallback<span class="signature">()</span><span class="type-signature"></span></h4>
|
99
|
+
|
100
|
+
|
101
|
+
</dt>
|
102
|
+
<dd>
|
103
|
+
|
104
|
+
|
105
|
+
<div class="description">
|
106
|
+
Callpixels.Campaign#request_number callback fired after the request completes.
|
107
|
+
</div>
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
<h5>Parameters:</h5>
|
116
|
+
|
117
|
+
|
118
|
+
<table class="params">
|
119
|
+
<thead>
|
120
|
+
<tr>
|
121
|
+
|
122
|
+
|
123
|
+
<th>Type</th>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<th class="last">Description</th>
|
130
|
+
</tr>
|
131
|
+
</thead>
|
132
|
+
|
133
|
+
<tbody>
|
134
|
+
|
135
|
+
|
136
|
+
<tr>
|
137
|
+
|
138
|
+
|
139
|
+
<td class="type">
|
140
|
+
|
141
|
+
|
142
|
+
<span class="param-type"><a href="Callpixels.Number.html">Callpixels.Number</a></span>
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
</td>
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
<td class="description last">The number that was returned</td>
|
153
|
+
</tr>
|
154
|
+
|
155
|
+
|
156
|
+
</tbody>
|
157
|
+
</table>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<dl class="details">
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<dt class="tag-source">Source:</dt>
|
182
|
+
<dd class="tag-source"><ul class="dummy"><li>
|
183
|
+
<a href="campaign.js.html">campaign.js</a>, <a href="campaign.js.html#line47">line 47</a>
|
184
|
+
</li></ul></dd>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
</dl>
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
</dd>
|
209
|
+
|
210
|
+
</dl>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
</article>
|
215
|
+
|
216
|
+
</section>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
</div>
|
222
|
+
|
223
|
+
<nav>
|
224
|
+
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Callpixels.Campaign.html">Campaign</a></li><li><a href="Callpixels.Number.html">Number</a></li></ul><h3><a href="global.html">Global</a></h3>
|
225
|
+
</nav>
|
226
|
+
|
227
|
+
<br clear="both">
|
228
|
+
|
229
|
+
<footer>
|
230
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 14:51:39 GMT-0400 (EDT)
|
231
|
+
</footer>
|
232
|
+
|
233
|
+
<script> prettyPrint(); </script>
|
234
|
+
<script src="scripts/linenumber.js"> </script>
|
235
|
+
</body>
|
236
|
+
</html>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>JSDoc: Index</title>
|
6
|
+
|
7
|
+
<script src="scripts/prettify/prettify.js"> </script>
|
8
|
+
<script src="scripts/prettify/lang-css.js"> </script>
|
9
|
+
<!--[if lt IE 9]>
|
10
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
11
|
+
<![endif]-->
|
12
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14
|
+
</head>
|
15
|
+
|
16
|
+
<body>
|
17
|
+
|
18
|
+
<div id="main">
|
19
|
+
|
20
|
+
<h1 class="page-title">Index</h1>
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
<h3> </h3>
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<nav>
|
51
|
+
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Callpixels.Campaign.html">Campaign</a></li><li><a href="Callpixels.Number.html">Number</a></li></ul><h3><a href="global.html">Global</a></h3>
|
52
|
+
</nav>
|
53
|
+
|
54
|
+
<br clear="both">
|
55
|
+
|
56
|
+
<footer>
|
57
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 14:51:39 GMT-0400 (EDT)
|
58
|
+
</footer>
|
59
|
+
|
60
|
+
<script> prettyPrint(); </script>
|
61
|
+
<script src="scripts/linenumber.js"> </script>
|
62
|
+
</body>
|
63
|
+
</html>
|
@@ -0,0 +1,250 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>JSDoc: Source: number.js</title>
|
6
|
+
|
7
|
+
<script src="scripts/prettify/prettify.js"> </script>
|
8
|
+
<script src="scripts/prettify/lang-css.js"> </script>
|
9
|
+
<!--[if lt IE 9]>
|
10
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
11
|
+
<![endif]-->
|
12
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14
|
+
</head>
|
15
|
+
|
16
|
+
<body>
|
17
|
+
|
18
|
+
<div id="main">
|
19
|
+
|
20
|
+
<h1 class="page-title">Source: number.js</h1>
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<section>
|
27
|
+
<article>
|
28
|
+
<pre class="prettyprint source linenums"><code>(function () {
|
29
|
+
// Dependencies
|
30
|
+
var Base = Callpixels.Base;
|
31
|
+
/**
|
32
|
+
* @constructor
|
33
|
+
* @memberOf Callpixels
|
34
|
+
* @param {Object} attributes - Attributes
|
35
|
+
* @property {Object} attributes
|
36
|
+
* @property {Number} attributes.id - The CallPixels internal number ID.
|
37
|
+
* @property {String} attributes.formatted_number - Nationally formatted phone number.
|
38
|
+
* @property {String} attributes.number - E.164 formatted phone number.
|
39
|
+
* @property {String} attributes.plain_number - The unformatted phone number digits.
|
40
|
+
* @property {Boolean} attributes.target_open - Whether there is an open, available target.
|
41
|
+
*/
|
42
|
+
Callpixels.Number = function (options) {
|
43
|
+
|
44
|
+
var self = this;
|
45
|
+
self.type = 'numbers';
|
46
|
+
|
47
|
+
function initialize(data) {
|
48
|
+
self.store(data);
|
49
|
+
self.set('is_active', 'true');
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Add tags to a number.
|
54
|
+
* @memberOf Callpixels.Number
|
55
|
+
* @function add_tags
|
56
|
+
* @instance
|
57
|
+
* @param {Object} tags - A collection of tags {key: 'value', tag2: 'value2'}
|
58
|
+
* @param {Function} callback - Callback that will be fired after request.
|
59
|
+
* @throws Will throw an error if attempting to modify tags on a number that doesn't belong to a number pool
|
60
|
+
* with per-visitor numbers enabled.
|
61
|
+
*/
|
62
|
+
self.add_tags = function (tags, callback) {
|
63
|
+
ensure_is_per_visitor();
|
64
|
+
self.post_data('numbers/tag', tags_payload(tags), callback);
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Remove tags from a number.
|
69
|
+
* @memberOf Callpixels.Number
|
70
|
+
* @function remove_tags
|
71
|
+
* @instance
|
72
|
+
* @param {Object} tags - A collection of tags {key: 'value', tag2: 'value2'}
|
73
|
+
* @param {Function} callback - Callback that will be fired after request.
|
74
|
+
* @throws Will throw an error if attempting to modify tags on a number that doesn't belong to a number pool
|
75
|
+
* with per-visitor numbers enabled.
|
76
|
+
*/
|
77
|
+
self.remove_tags = function (tags, callback) {
|
78
|
+
ensure_is_per_visitor();
|
79
|
+
self.post_data('numbers/untag', tags_payload(tags), callback);
|
80
|
+
};
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Removes all tags with given keys from a number.
|
84
|
+
* @memberOf Callpixels.Number
|
85
|
+
* @function remove_tags_by_keys
|
86
|
+
* @instance
|
87
|
+
* @param {Array} keys - An array of keys to remove. eg: ['key1', 'key2']
|
88
|
+
* @param {Function} callback - Callback that will be fired after request.
|
89
|
+
* @throws Will throw an error if attempting to modify tags on a number that doesn't belong to a number pool
|
90
|
+
* with per-visitor numbers enabled.
|
91
|
+
*/
|
92
|
+
self.remove_tags_by_keys = function (keys, callback) {
|
93
|
+
ensure_is_per_visitor();
|
94
|
+
if (typeof(keys) === 'string') keys = keys.split(',');
|
95
|
+
var payload = {
|
96
|
+
tag_keys: keys,
|
97
|
+
ids: [ get('id') ],
|
98
|
+
campaign_key: get('campaign_key')
|
99
|
+
};
|
100
|
+
self.post_data('numbers/untag/keys', payload, callback);
|
101
|
+
};
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Clear all tags from a number.
|
105
|
+
* @memberOf Callpixels.Number
|
106
|
+
* @function clear_tags
|
107
|
+
* @instance
|
108
|
+
* @param {Function} callback - Callback that will be fired after request.
|
109
|
+
* @throws Will throw an error if attempting to modify tags on a number that doesn't belong to a number pool
|
110
|
+
* with per-visitor numbers enabled.
|
111
|
+
*/
|
112
|
+
self.clear_tags = function (callback) {
|
113
|
+
ensure_is_per_visitor();
|
114
|
+
var payload = {
|
115
|
+
ids: [ get('id') ],
|
116
|
+
campaign_key: get('campaign_key'),
|
117
|
+
all: 'true'
|
118
|
+
};
|
119
|
+
self.post_data('numbers/untag', payload, callback);
|
120
|
+
};
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Release number back to pool.
|
124
|
+
* @memberOf Callpixels.Number
|
125
|
+
* @function release
|
126
|
+
* @instance
|
127
|
+
*/
|
128
|
+
self.release = function () {
|
129
|
+
self.set('is_active', 'false');
|
130
|
+
};
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Start a call immediately by having a campaign target dial the visitor.
|
134
|
+
* @memberOf Callpixels.Number
|
135
|
+
* @function initiate_call
|
136
|
+
* @instance
|
137
|
+
* @param {String} dial - The number to call.
|
138
|
+
* @param {Object} payload - A collection of tags as key-value pairs and optional secure override properties.
|
139
|
+
* @param {string} [payload.target_map] - A string mapping a placeholder number to a phone number.
|
140
|
+
* @param {string} [payload.target_map_cs] - A SHA1 checksum of the target_map concatenated with your CallPixels API
|
141
|
+
* key.
|
142
|
+
* @param {number} [payload.timer_offset] - Number of seconds to offset the "connect" duration timers by.
|
143
|
+
* @param {string} [payload.timer_offset_cs] - An SHA1 checksum of the timer_offset concatenated with your
|
144
|
+
* CallPixels API key.
|
145
|
+
* @param {(string|number)} [payload.*] - Key value pairs treated as tags.
|
146
|
+
* @param {Function} callback - Callback that will be fired after request.
|
147
|
+
* @example
|
148
|
+
* number.initiate_call('4166686980', {company_name: 'CallPixels'}, function (call) {
|
149
|
+
* alert('Call started with UUID ' + call.uuid)
|
150
|
+
* });
|
151
|
+
*/
|
152
|
+
self.initiate_call = function (dial, payload, callback) {
|
153
|
+
if (typeof(payload) === 'undefined') payload = {};
|
154
|
+
// assign dial to payload
|
155
|
+
payload.dial = dial;
|
156
|
+
// merge payload into payload
|
157
|
+
payload = Base.merge(self.get('id', 'campaign_key'), payload);
|
158
|
+
// post the payload
|
159
|
+
self.post_data('numbers/initiate_call', payload, callback);
|
160
|
+
};
|
161
|
+
|
162
|
+
function tags_payload(tags) {
|
163
|
+
if (typeof(tags) === 'string') tags = Callpixels.Number.extract_tags_from_string(tags);
|
164
|
+
return {
|
165
|
+
tag_values: tags,
|
166
|
+
ids: [ get('id') ],
|
167
|
+
campaign_key: get('campaign_key')
|
168
|
+
};
|
169
|
+
}
|
170
|
+
|
171
|
+
function get(key) {
|
172
|
+
return self.get(key);
|
173
|
+
}
|
174
|
+
|
175
|
+
function ensure_is_per_visitor() {
|
176
|
+
if (self.get('is_per_visitor') === false) {
|
177
|
+
throw "Error: Tried to add tags to non per-visitor number.";
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
initialize(options);
|
182
|
+
};
|
183
|
+
|
184
|
+
Callpixels.Number.extract_tags_from_string = function (tags) {
|
185
|
+
var output = {};
|
186
|
+
var tags = tags.split(",");
|
187
|
+
for (var i = 0; i < tags.length; i++) {
|
188
|
+
var tag = tags[i].split(":");
|
189
|
+
output[tag[0]] = tag[1]
|
190
|
+
}
|
191
|
+
return output;
|
192
|
+
};
|
193
|
+
|
194
|
+
Callpixels.Number.prototype = new Callpixels.Base.Model();
|
195
|
+
|
196
|
+
function ping_active_numbers(callback) {
|
197
|
+
if (typeof(Callpixels.Base.Data._store) !== 'undefined') {
|
198
|
+
// get numbers
|
199
|
+
var numbers = Callpixels.Base.Data._store['numbers'];
|
200
|
+
// for each number
|
201
|
+
if (typeof(numbers) !== 'undefined') {
|
202
|
+
// group number_ids by campaign_key
|
203
|
+
var grouped = {};
|
204
|
+
for (var primary_key in numbers) {
|
205
|
+
var number = numbers[primary_key];
|
206
|
+
if (number.is_active === 'true') {
|
207
|
+
if (typeof(grouped[number.campaign_key]) === 'undefined') grouped[number.campaign_key] = [];
|
208
|
+
grouped[number.campaign_key].push(number.id);
|
209
|
+
}
|
210
|
+
}
|
211
|
+
// ping each group of number_ids
|
212
|
+
for (var campaign_key in grouped) {
|
213
|
+
var payload = {
|
214
|
+
campaign_key: campaign_key,
|
215
|
+
ids: grouped[campaign_key]
|
216
|
+
};
|
217
|
+
Callpixels.Base.Request.connection().postJSON('/api/v1/numbers/ping', payload, [Callpixels.Base.Model.update, callback], this);
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
// call recursively
|
222
|
+
setTimeout(ping_active_numbers, 15000);
|
223
|
+
}
|
224
|
+
|
225
|
+
// always ping active numbers
|
226
|
+
ping_active_numbers();
|
227
|
+
|
228
|
+
})();</code></pre>
|
229
|
+
</article>
|
230
|
+
</section>
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
</div>
|
236
|
+
|
237
|
+
<nav>
|
238
|
+
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Callpixels.Campaign.html">Campaign</a></li><li><a href="Callpixels.Number.html">Number</a></li></ul><h3><a href="global.html">Global</a></h3>
|
239
|
+
</nav>
|
240
|
+
|
241
|
+
<br clear="both">
|
242
|
+
|
243
|
+
<footer>
|
244
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 14:51:39 GMT-0400 (EDT)
|
245
|
+
</footer>
|
246
|
+
|
247
|
+
<script> prettyPrint(); </script>
|
248
|
+
<script src="scripts/linenumber.js"> </script>
|
249
|
+
</body>
|
250
|
+
</html>
|