forked from contentstack/contentstack-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentstack-demo.js
More file actions
executable file
·118 lines (101 loc) · 4.07 KB
/
contentstack-demo.js
File metadata and controls
executable file
·118 lines (101 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
'use strict'
/*!
* module dependencies
*/
const Contentstack = require('../../dist/node/contentstack.js');
/*
* Example ContentstackDemo Class
* */
class ContentstackDemo {
constructor(config) {
config = config || { 'api_key': 'blt123something', 'access_token': 'blt123something', 'environment': 'development', }
// Initialize the Contentstackstack
//console.log("datattatata", Contentstack.Region.EUROPE)
this.Stack = Contentstack.Stack(config);
}
/**
* getEntries
* @description : getEntries is used to get the entries of the specified entries
* @params : contentTypeUid {string} - Content-Type from which entries to be retrieved
* @return : Result {Promise}
*/
getEntries(contentTypeUid) {
contentTypeUid = contentTypeUid || 'source'
return this.Stack.ContentType('test').Query().includeContentType().toJSON().find()
//return this.Stack.getContentTypes(contentTypeUid)
}
/**
* getEntries
* @description : getEntries is used to get the entries of the specified entries
* @params : contentTypeUid {string} - Content-Type from which entries to be retrieved
* @return : Result {Promise}
*/
getLastActivities() {
//contentTypeUid = contentTypeUid || 'source'
return this.Stack.getLastActivities()
}
/**
* getEntries
* @description : getEntries is used to get the entries of the specified entries
* @params : contentTypeUid {string} - Content-Type from which entries to be retrieved
* @return : Result {Promise}
*/
getContentTypedemo() {
contentTypeUid = contentTypeUid || 'source'
return this.Stack.ContentType(contentTypeUid).fetch()
// return this.Stack.ContentType('event_list').Entry('blt5d40c608567844d4').toJSON().fetch()
}
/**
* getEntries
* @description : getEntries is used to get the entries of the specified entries
* @params : contentTypeUid {string} - Content-Type from which entries to be retrieved
* @return : Result {Promise}
*/
getContentType(uid) {
//contentTypeUid = contentTypeUid || 'source'
// return this.Stack.getContentType(uid)
// return this.Stack.ContentType(uid).Entry("blta07130f8b344b260").includeReferenceContentTypeUID().includeSchema().toJSON().fetch()
//return this.Stack.getContentTypes({"include_global_field_schema": true})
}
/**
* fetchEntry
* @description : fetchEntry is used to get the specified uid entry
* @params : contentTypeUid {string} - Content-Type from which entry to be fetched
* entryUid {string} - Specified entry to be fetched
* @return : Result {Promise}
*/
getEntry(contentTypeUid, entryUid) {
contentTypeUid = contentTypeUid || 'source'
entryUid = entryUid || 'blt123something'
return this.Stack.ContentType(contentTypeUid).Entry(entryUid).language('ja-jp').fetch()
}
/**
* getAssets
* @description : getAssets is used to get the assets
* @return : Result {Promise}
*/
getAssets() {
return this.Stack.Assets().Query().toJSON().find()
}
/**
* fetchAsset
* @description : fetchAsset is used to get the specified uid asset
* @params : assetUid {string} - Specified Asset uid to be fetched
* @return : Result {Promise}
*/
getAsset(assetUid) {
assetUid = assetUid || 'blt123something'
return this.Stack.Assets(assetUid).addParam('include_dimension', 'true').fetch()
}
/**
* fetchAsset
* @description : fetchAsset is used to get the specified uid asset
* @params : assetUid {string} - Specified Asset uid to be fetched
* @return : Result {Promise}
*/
getSyncApi(params) {
params = params || 'blt123something'
return this.Stack.sync(params);
}
}
module.exports = ContentstackDemo