File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ export function Organization (http, data) {
107107 */
108108 this . addUser = async ( data ) => {
109109 try {
110- const response = await http . post ( `${ this . urlPath } /share` , { share : { data } } )
110+ const response = await http . post ( `${ this . urlPath } /share` , { share : { ... data } } )
111111 if ( response . data ) {
112112 return new ContentstackCollection ( response , http , null , UserCollection )
113113 } else {
@@ -238,7 +238,7 @@ export function Organization (http, data) {
238238}
239239
240240export function OrganizationCollection ( http , data ) {
241- const obj = cloneDeep ( data . organizations )
241+ const obj = cloneDeep ( data . organizations || [ ] )
242242 const organizationCollection = obj . map ( ( userdata ) => {
243243 return new Organization ( http , { organization : userdata } )
244244 } )
Original file line number Diff line number Diff line change @@ -90,7 +90,33 @@ export function ContentType (http, data = {}) {
9090 return new Entry ( http , data )
9191 }
9292 } else {
93- /**
93+ /**
94+ * @description The Create a content type call creates a new content type in a particular stack of your Contentstack account.
95+ * @memberof ContentType
96+ * @func generateUid
97+ * @param {* } name Name for content type you want to create.
98+ * @example
99+ * import * as contentstack from '@contentstack/management'
100+ * const client = contentstack.client()
101+ * const contentType = client.stack().contentType()
102+ * const contentTypeName = 'My New contentType'
103+ * const content_type = {
104+ * name: name,
105+ * uid: contentType.generateUid(name)
106+ * }
107+ * contentType
108+ * .create({ content_type })
109+ * .then((contenttype) => console.log(contenttype))
110+ *
111+ */
112+ this . generateUid = ( name ) => {
113+ if ( ! name ) {
114+ throw new TypeError ( 'Expected parameter name' )
115+ }
116+ return name . replace ( / [ ^ A - Z 0 - 9 ] + / gi, '_' ) . toLowerCase ( )
117+ }
118+
119+ /**
94120 * @description The Create a content type call creates a new content type in a particular stack of your Contentstack account.
95121 * @memberof ContentType
96122 * @func create
You can’t perform that action at this time.
0 commit comments