Skip to content

Commit d22306b

Browse files
Support the Include snippet schema feature
1 parent a024a28 commit d22306b

File tree

7 files changed

+22
-6
lines changed

7 files changed

+22
-6
lines changed

dist/node/contentstack.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ var Stack = function () {
10391039

10401040
}, {
10411041
key: 'getContentTypes',
1042-
value: function getContentTypes() {
1042+
value: function getContentTypes(param) {
10431043
var query = {
10441044
method: 'POST',
10451045
headers: this.headers,
@@ -1049,6 +1049,11 @@ var Stack = function () {
10491049
environment: this.environment
10501050
}
10511051
};
1052+
if (param && param !== undefined) {
1053+
for (var key in param) {
1054+
query.body[key] = param[key];
1055+
}
1056+
}
10521057
return (0, _request2.default)(query);
10531058
}
10541059

@@ -2000,6 +2005,7 @@ var Entry = function () {
20002005
key: "includeSchema",
20012006
value: function includeSchema() {
20022007
this._query['include_schema'] = true;
2008+
this._query['include_snippet_schema'] = true;
20032009
return this;
20042010
}
20052011

@@ -2041,6 +2047,7 @@ var Entry = function () {
20412047
key: "includeContentType",
20422048
value: function includeContentType() {
20432049
this._query['include_content_type'] = true;
2050+
this._query['include_snippet_schema'] = true;
20442051
return this;
20452052
}
20462053

@@ -2870,6 +2877,7 @@ var Query = function (_Entry) {
28702877
query: this._query
28712878
}
28722879
};
2880+
28732881
return Utils.sendRequest(this);
28742882
}
28752883

examples/node/contentstack-demo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class ContentstackDemo {
2626
*/
2727
getEntries(contentTypeUid) {
2828
contentTypeUid = contentTypeUid || 'source'
29-
return this.Stack.ContentType(contentTypeUid).Query().toJSON().find()
29+
return this.Stack.ContentType('dinu1234').Query().includeSchema().toJSON().find()
30+
//return this.Stack.getContentTypes(contentTypeUid)
3031

3132
}
3233

src/core/lib/request.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ export default function Request(options) {
4242
queryParams = serialize(options.body);
4343
}
4444

45-
4645
fetch(url + '?' + queryParams, {
4746
method: 'GET',
4847
headers: headers
4948
})
50-
.then(function(response) {
49+
.then(function(response) {
5150
if (response.ok && response.status === 200) {
5251
let data = response.json();
5352
resolve(data);

src/core/modules/entry.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export default class Entry {
190190
*/
191191
includeSchema() {
192192
this._query['include_schema'] = true;
193+
this._query['include_snippet_schema'] = true;
193194
return this;
194195
}
195196

@@ -226,6 +227,7 @@ export default class Entry {
226227
*/
227228
includeContentType() {
228229
this._query['include_content_type'] = true;
230+
this._query['include_snippet_schema'] = true;
229231
return this;
230232
}
231233

src/core/modules/query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ export default class Query extends Entry {
652652
query: this._query
653653
}
654654
};
655-
return Utils.sendRequest(this);
655+
return Utils.sendRequest(this);
656656
}
657657

658658
/**

src/core/stack.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export default class Stack {
372372
* @returns {Stack}
373373
* @instance
374374
*/
375-
getContentTypes() {
375+
getContentTypes(param) {
376376
let query = {
377377
method: 'POST',
378378
headers: this.headers,
@@ -382,6 +382,11 @@ export default class Stack {
382382
environment: this.environment
383383
}
384384
};
385+
if(param && param !== undefined) {
386+
for( var key in param) {
387+
query.body[key] = param[key]
388+
}
389+
}
385390
return Request(query);
386391
}
387392

test/report.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)