@@ -10,7 +10,7 @@ import error from './core/contentstackError'
1010export default function contentstackClient ( { http } ) {
1111 /**
1212 * @description The Log in to your account request is used to sign in to your Contentstack account and obtain the authtoken.
13- * @memberof ContentstackClientAPI
13+ * @memberof ContentstackClient
1414 * @func login
1515 * @param {Object } parameters - login parameters
1616 * @prop {string } paramters.email - email id for user to login
@@ -39,7 +39,7 @@ export default function contentstackClient ({ http }) {
3939 /**
4040 * @description The Get user call returns comprehensive information of an existing user account.
4141 * The information returned includes details of the stacks owned by and shared with the specified user account.
42- * @memberof ContentstackClientAPI
42+ * @memberof ContentstackClient
4343 * @func getUser
4444 * @returns {Promise }
4545 * @example
@@ -58,7 +58,7 @@ export default function contentstackClient ({ http }) {
5858 }
5959 /**
6060 * @description Get Stack instance. A stack is a space that stores the content of a project.
61- * @memberof ContentstackClientAPI
61+ * @memberof ContentstackClient
6262 * @func stack
6363 * @param {String } api_key - Stack API Key
6464 * @returns {Stack } Instance of Stack
@@ -97,8 +97,8 @@ export default function contentstackClient ({ http }) {
9797 }
9898
9999 /**
100- * @description Get Stack instance. A stack is a space that stores the content of a project .
101- * @memberof ContentstackClientAPI
100+ * @description Organization is the top-level entity in the hierarchy of Contentstack, consisting of stacks and stack resources, and users .
101+ * @memberof ContentstackClient
102102 * @func organization
103103 * @param {String } uid - Organization UID.
104104 * @returns {Organization } Instance of Organization.
@@ -122,8 +122,35 @@ export default function contentstackClient ({ http }) {
122122 return new Organization ( http , uid !== null ? { organization : { uid : uid } } : null )
123123 }
124124
125+ /**
126+ * @description The Log out of your account call is used to sign out the user of Contentstack account.
127+ * @memberof ContentstackClient
128+ * @func organization
129+ * @param {String } uid - Organization UID.
130+ * @returns {String } Success message.
131+ *
132+ * @example
133+ * import * as contentstack from 'contentstack'
134+ * const client = contentstack.client({})
135+ * const notice = client.logout()
136+ *
137+ */
138+ function logout ( ) {
139+ return http . delete ( '/user-session' )
140+ . then ( ( response ) => {
141+ if ( http . defaults . headers . common ) {
142+ delete http . defaults . headers . common . authtoken
143+ }
144+ delete http . defaults . headers . authtoken
145+ delete http . httpClientParams . authtoken
146+ delete http . httpClientParams . headers . authtoken
147+ return response . data
148+ } , error )
149+ }
150+
125151 return {
126152 login : login ,
153+ logout : logout ,
127154 getUser : getUser ,
128155 stack : stack ,
129156 organization : organization
0 commit comments