Skip to content

Commit 1e7ded2

Browse files
Merge pull request #16 from contentstack/contenttype-methods
Api implementation for contenttype information
2 parents 28d6a5d + c4be98b commit 1e7ded2

File tree

3 files changed

+65
-4
lines changed

3 files changed

+65
-4
lines changed

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_modules/*
44
.idea/*
55
reports/*
66
apidocs-templates/*
7-
test/smtpconfig.js
8-
test/config.js
9-
test/sync_config.js
7+
test/smtpconfig.js/*
8+
test/config.js/*
9+
test/sync_config.js/*
10+
test/report.json/*

src/core/modules/entry.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,4 @@ export default class Entry {
289289
console.error("Kindly provide an entry uid. e.g. .Entry('bltsomething123')");
290290
}
291291
}
292-
293292
}

src/core/stack.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,35 @@ export default class Stack {
249249
return Utils.merge(entry, this);
250250
}
251251

252+
/**
253+
* @method fetch
254+
* @memberOf Stack
255+
* @description This method will returns information of a specific content type. It returns the content type schema.
256+
* @example
257+
* let single_contenttype = Stack.ContentType(content_type_uid).fetch()
258+
* single_contenttype
259+
* .then(function(result) {
260+
* // 'result' is a single contentType information.
261+
* }).catch((error) => {
262+
* console.log(error)
263+
* });
264+
* @returns {ContentType}
265+
* @instance
266+
*/
267+
fetch() {
268+
let result = {
269+
method: 'POST',
270+
headers: this.headers,
271+
url: this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version + this.config.urls.content_types + this.content_type_uid,
272+
body: {
273+
_method: 'GET',
274+
environment: this.environment
275+
}
276+
};
277+
return Request(result);
278+
279+
}
280+
252281
/**
253282
* @method Assets
254283
* @memberOf Stack
@@ -309,6 +338,38 @@ export default class Stack {
309338
return Request(query);
310339
}
311340

341+
/**
342+
* @method getContentTypes
343+
* @memberOf Stack
344+
* @description getContentTypes method returns comprehensive information of all the content types available in a particular stack in your account.
345+
* @example Stack.getContentTypes()
346+
* @example
347+
* let data = Stack.getContentTypes()
348+
* data
349+
* .then(function(result) {
350+
* // 'result' is list of contentTypes.
351+
* }, function(error) {
352+
* // error function
353+
* })
354+
* @returns {Stack}
355+
* @instance
356+
*/
357+
getContentTypes() {
358+
let query = {
359+
method: 'POST',
360+
headers: this.headers,
361+
url: this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version + this.config.urls.content_types,
362+
body: {
363+
_method: 'GET',
364+
environment: this.environment
365+
}
366+
};
367+
return Request(query);
368+
}
369+
370+
371+
372+
312373

313374
/**
314375
* @method sync

0 commit comments

Comments
 (0)