@constructor-io/constructorio-client-javascript 2.29.13 → 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -40,7 +40,7 @@ var constructorio = new ConstructorIOClient({
40
40
  After instantiating an instance of the client, four modules will be exposed as properties to help retrieve data from Constructor.io: `search`, `browse`, `autocomplete`, `recommendations` and `tracker`.
41
41
 
42
42
  #### Dispatched events
43
- The `search`, `browse` and `recommendations` module may dispatch custom events on `window` with response data when a request has been completed. The event name follows the following structure: `cio.client.[moduleName].[methodName].completed`. Example consuming code can be found below:
43
+ The `search`, `browse`, `recommendations` and `autocomplete` modules may dispatch custom events on `window` with response data when a request has been completed. The event name follows the following structure: `cio.client.[moduleName].[methodName].completed`. Example consuming code can be found below:
44
44
 
45
45
  ```javascript
46
46
  window.addEventListener('cio.client.search.getSearchResults.completed', (event) => {
@@ -25,7 +25,9 @@ var EventDispatcher = require('./utils/event-dispatcher');
25
25
  var helpers = require('./utils/helpers');
26
26
 
27
27
  var _require = require('../package.json'),
28
- packageVersion = _require.version; // Compute package version string
28
+ packageVersion = _require.version;
29
+
30
+ var Quizzes = require('./modules/quizzes'); // Compute package version string
29
31
 
30
32
 
31
33
  var computePackageVersion = function computePackageVersion() {
@@ -72,6 +74,7 @@ var ConstructorIO = /*#__PURE__*/function () {
72
74
  * @property {object} autocomplete - Interface to {@link module:autocomplete}
73
75
  * @property {object} recommendations - Interface to {@link module:recommendations}
74
76
  * @property {object} tracker - Interface to {@link module:tracker}
77
+ * @property {object} quizzes - Interface to {@link module:quizzes}
75
78
  * @returns {class}
76
79
  */
77
80
  function ConstructorIO() {
@@ -142,7 +145,8 @@ var ConstructorIO = /*#__PURE__*/function () {
142
145
  this.browse = new Browse(this.options);
143
146
  this.autocomplete = new Autocomplete(this.options);
144
147
  this.recommendations = new Recommendations(this.options);
145
- this.tracker = new Tracker(this.options); // Dispatch initialization event
148
+ this.tracker = new Tracker(this.options);
149
+ this.quizzes = new Quizzes(this.options); // Dispatch initialization event
146
150
 
147
151
  new EventDispatcher(options.eventDispatcher).queue('instantiated', this.options);
148
152
  }
@@ -66,7 +66,7 @@ function createQuizUrl(quizId, parameters, options, path) {
66
66
 
67
67
  if (versionId) {
68
68
  queryParams.version_id = versionId;
69
- } // Pull a from parameters and transform
69
+ } // Pull a (answers) from parameters and transform
70
70
 
71
71
 
72
72
  if (a) {
@@ -103,31 +103,31 @@ var Quizzes = /*#__PURE__*/function () {
103
103
  this.eventDispatcher = new EventDispatcher(options.eventDispatcher);
104
104
  }
105
105
  /**
106
- * Retrieve next quiz from api
106
+ * Retrieve next question from API
107
107
  *
108
- * @function getNextQuiz
109
- * @description Retrieve next quiz from Constructor.io API
110
- * @param {string} id - The id of the quiz
108
+ * @function getNextQuestion
109
+ * @description Retrieve next question from Constructor.io API
110
+ * @param {string} id - The identifier of the quiz
111
111
  * @param {string} [parameters] - Additional parameters to refine result set
112
- * @param {string} [parameters.section] - Section for customer's product catalog (optional)
113
- * @param {array} [parameters.a] - An array for answers in the format [[1,2],[1]]
114
- * @param {string} [parameters.version_id] - Specific version id for the quiz.
112
+ * @param {string} [parameters.section] - Product catalog section
113
+ * @param {array} [parameters.a] - An array of answers in the format [[1,2],[1]]
114
+ * @param {string} [parameters.versionId] - Version identifier for the quiz
115
115
  * @param {object} [networkParameters] - Parameters relevant to the network request
116
116
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
117
117
  * @returns {Promise}
118
- * @see https://quizzes.cnstrc.com/api/#/quizzes/QuizzesController_getNextQuestion
118
+ * @see https://docs.constructor.io/rest_api/quiz/using_quizzes/#answering-a-quiz
119
119
  * @example
120
- * constructorio.search.getNextQuiz('quizId', {
120
+ * constructorio.quizzes.getNextQuestion('quizId', {
121
121
  * a: [[1,2],[1]],
122
- * section: "123",
123
- * version_id: "123"
122
+ * section: '123',
123
+ * versionId: '123'
124
124
  * });
125
125
  */
126
126
 
127
127
 
128
128
  (0, _createClass2["default"])(Quizzes, [{
129
- key: "getNextQuiz",
130
- value: function getNextQuiz(quizId, parameters) {
129
+ key: "getNextQuestion",
130
+ value: function getNextQuestion(quizId, parameters) {
131
131
  var _this = this;
132
132
 
133
133
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -165,30 +165,30 @@ var Quizzes = /*#__PURE__*/function () {
165
165
  });
166
166
  }
167
167
  /**
168
- * Retrieves filter expression and recommendation URL from given answers.
168
+ * Retrieves filter expression and recommendation URL from given answers
169
169
  *
170
- * @function getFinalizeQuiz
170
+ * @function getQuizResults
171
171
  * @description Retrieve quiz recommendation and filter expression from Constructor.io API
172
- * @param {string} id - The id of the quiz
172
+ * @param {string} id - The identifier of the quiz
173
173
  * @param {string} [parameters] - Additional parameters to refine result set
174
- * @param {string} [parameters.section] - Section for customer's product catalog (optional)
175
- * @param {array} [parameters.a] - An array for answers in the format [[1,2],[1]]
176
- * @param {string} [parameters.version_id] - Specific version id for the quiz.
174
+ * @param {string} [parameters.section] - Product catalog section
175
+ * @param {array} [parameters.a] - An array of answers in the format [[1,2],[1]]
176
+ * @param {string} [parameters.versionId] - Specific version identifier for the quiz
177
177
  * @param {object} [networkParameters] - Parameters relevant to the network request
178
178
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
179
179
  * @returns {Promise}
180
- * @see https://quizzes.cnstrc.com/api/#/quizzes/QuizzesController_getQuizResult
180
+ * @see https://docs.constructor.io/rest_api/quiz/using_quizzes/#completing-the-quiz
181
181
  * @example
182
- * constructorio.search.getFinalizeQuiz('quizId', {
182
+ * constructorio.quizzes.getQuizResults('quizId', {
183
183
  * a: [[1,2],[1]],
184
- * section: "123",
185
- * version_id: "123"
184
+ * section: '123',
185
+ * versionId: '123'
186
186
  * });
187
187
  */
188
188
 
189
189
  }, {
190
- key: "getFinalizeQuiz",
191
- value: function getFinalizeQuiz(quizId, parameters) {
190
+ key: "getQuizResults",
191
+ value: function getQuizResults(quizId, parameters) {
192
192
  var _this2 = this;
193
193
 
194
194
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -217,12 +217,12 @@ var Quizzes = /*#__PURE__*/function () {
217
217
  return helpers.throwHttpErrorFromResponse(new Error(), response);
218
218
  }).then(function (json) {
219
219
  if (json.version_id) {
220
- _this2.eventDispatcher.queue('quizzes.getFinalizeQuiz.completed', json);
220
+ _this2.eventDispatcher.queue('quizzes.getQuizResults.completed', json);
221
221
 
222
222
  return json;
223
223
  }
224
224
 
225
- throw new Error('getFinalizeQuiz response data is malformed');
225
+ throw new Error('getQuizResults response data is malformed');
226
226
  });
227
227
  }
228
228
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.29.13",
3
+ "version": "2.30.0",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "scripts": {
package/lib/.DS_Store DELETED
Binary file