Skip to content

Commit db410e6

Browse files
committed
Response message change from string to object
1 parent 5aa2978 commit db410e6

21 files changed

Lines changed: 2527 additions & 685 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ contentstackClient = contentstack.client(axios, {})
2929
```
3030

3131
### Authentication
32-
To use this SDK you need to authenticate using the user Authtoken, creadentials, or Management Token (stack-level token).
32+
To use this SDK you need to authenticate using the user Authtoken, credentials, or Management Token (stack-level token).
3333
### Authtoken
3434
An **Authtoken** is a read-write token used to make authorized CMA requests, and it is a **user-specific** token.
3535
```
@@ -40,7 +40,7 @@ contentstackClient = contentstack.client(axios, { authtoken: 'AUTHTOKEN' })
4040
To Login to Contentstack using credentials:
4141
```
4242
contentstackClient.login({ email: 'EMAIL', password: 'PASSWORD'})
43-
..then((response) => {
43+
.then((response) => {
4444
console.log(response.notice)
4545
console.log(response.user)
4646
})
@@ -92,7 +92,7 @@ The following code snippet is use to create Asset into Stack using this SDK:
9292
```
9393
var asset = {
9494
upload: 'path/to/file',
95-
tit;e: 'Asset Title'
95+
title: 'Asset Title'
9696
}
9797
9898
contentstackClient.stack('API_KEY').asset().create({ asset })

lib/contentstackClient.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @namespace ContentstackClientAPI
2+
* @namespace ContentstackClient
33
*/
44
import { Stack } from './stack/index.js'
55
import { Organization } from './organization/index'
@@ -125,17 +125,27 @@ export default function contentstackClient ({ http }) {
125125
/**
126126
* @description The Log out of your account call is used to sign out the user of Contentstack account.
127127
* @memberof ContentstackClient
128-
* @func organization
129-
* @param {String} uid - Organization UID.
130-
* @returns {String} Success message.
128+
* @param {String} authtoken - Authtoken to logout from.
129+
* @func logout
130+
* @returns {Object} Response object.
131131
*
132132
* @example
133133
* import * as contentstack from 'contentstack'
134134
* const client = contentstack.client({})
135135
* const notice = client.logout()
136136
*
137137
*/
138-
function logout () {
138+
function logout (authtoken) {
139+
if (authtoken !== undefined) {
140+
return http.delete('/user-session', {
141+
headers: {
142+
authtoken: authtoken
143+
}
144+
})
145+
.then((response) => {
146+
return response.data
147+
}, error)
148+
}
139149
return http.delete('/user-session')
140150
.then((response) => {
141151
if (http.defaults.headers.common) {

lib/entity.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const publishUnpublish = async (http, url, httpBody, headers, locale = nu
4343
try {
4444
const response = await http.post(url, httpBody, headers)
4545
if (response.data) {
46-
return response.data.notice
46+
return response.data
4747
} else {
4848
throw error(response)
4949
}
@@ -160,7 +160,7 @@ export const deleteEntity = (http) => {
160160

161161
const response = await http.delete(this.urlPath, headers)
162162
if (response.data) {
163-
return response.data.notice
163+
return response.data
164164
} else {
165165
throw error(response)
166166
}

lib/organization/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function Organization (http, data) {
7070
* @memberof Organization
7171
* @func transferOwnership
7272
* @param {String} email The email address of the user to whom you wish to transfer the ownership of the organization.
73-
* @returns {String} Success message of transfer ownership.
73+
* @returns {Object} Response Object.
7474
* @example
7575
* import * as contentstack from 'contentstack'
7676
* const client = contentstack.client({})
@@ -83,7 +83,7 @@ export function Organization (http, data) {
8383
try {
8484
const response = await http.post(`${this.urlPath}/transfer_ownership`, { transfer_to: email })
8585
if (response.data) {
86-
return response.data.notice
86+
return response.data
8787
} else {
8888
return error(response)
8989
}
@@ -121,13 +121,13 @@ export function Organization (http, data) {
121121
/**
122122
* @description The Get all organization invitations call gives you a list of all the Organization invitations.
123123
* @memberof Organization
124-
* @func resendInvitition
124+
* @func getInvitations
125125
* @returns {String} Success message of invitation send.
126126
* @example
127127
* import * as contentstack from 'contentstack'
128128
* const client = contentstack.client({})
129129
*
130-
* client.organization('organization_uid).resendInvitition('invitition_uid')
130+
* client.organization('organization_uid).getInvitations()
131131
* .then((notice) => console.log(notice))
132132
*
133133
*/
@@ -148,7 +148,7 @@ export function Organization (http, data) {
148148
* @description The Resend pending organization invitation call allows you to resend Organization invitations to users who have not yet accepted the earlier invitation.
149149
* @memberof Organization
150150
* @func resendInvitition
151-
* @returns {String} Success message of invitation send.
151+
* @returns {Object} Response Object.
152152
* @example
153153
* import * as contentstack from 'contentstack'
154154
* const client = contentstack.client({})
@@ -161,7 +161,7 @@ export function Organization (http, data) {
161161
try {
162162
const response = await http.get(`${this.urlPath}/${invitationUid}/resend_invitation`)
163163
if (response.data) {
164-
return response.data.notice
164+
return response.data
165165
} else {
166166
return error(response)
167167
}

lib/stack/asset/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function Asset (http, data = {}) {
5151
* @description The Delete asset call will delete an existing asset from the stack.
5252
* @memberof Asset
5353
* @func delete
54-
* @returns {String} Success message.
54+
* @returns {Object} Response Object.
5555
* @example
5656
* import * as contentstack from 'contentstack'
5757
* const client = contentstack.client({})
@@ -109,7 +109,7 @@ export function Asset (http, data = {}) {
109109
* @description The Publish an asset call is used to publish a specific version of an asset on the desired environment either immediately or at a later date/time.
110110
* @memberof Asset
111111
* @func publish
112-
* @returns {Promise<String>} Notice for success message.
112+
* @returns {Promise<Object>} Response Object.
113113
* @example
114114
* import * as contentstack from 'contentstack'
115115
* const client = contentstack.client({})
@@ -133,7 +133,7 @@ export function Asset (http, data = {}) {
133133
* @description The Replace asset call will replace an existing asset with another file on the stack.
134134
* @memberof Asset
135135
* @func unpublish
136-
* @returns {Promise<String>} Notice for success message.
136+
* @returns {Promise<Object>} Response Object.
137137
* @example
138138
* import * as contentstack from 'contentstack'
139139
* const client = contentstack.client({})

lib/stack/bulkOperation/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function BulkOperation (http, data = {}) {
1212
* The Publish entries and assets in bulk request allows you to publish multiple entries and assets at the same time.
1313
* @memberof BulkOperation
1414
* @func publish
15-
* @returns {Promise<String>} Success message
15+
* @returns {Promise<Object>} Response Object.
1616
* @param {Boolean} params.details - Set this with details containing 'entries', 'assets', 'locales', and 'environments' to which you want to publish the entries or assets.
1717
* @param {Boolean} params.skip_workflow_stage_check Set this to 'true' to publish the entries that are at a workflow stage where they satisfy the applied publish rules.
1818
* @param {Boolean} params.approvals Set this to 'true' to publish the entries that do not require an approval to be published.
@@ -66,7 +66,7 @@ export function BulkOperation (http, data = {}) {
6666
* The Unpublish entries and assets in bulk request allows you to unpublish multiple entries and assets at the same time.
6767
* @memberof BulkOperation
6868
* @func unpublish
69-
* @returns {Promise<String>} Success message
69+
* @returns {Promise<Object>} Response Object.
7070
* @param {Boolean} params.details - Set this with details containing 'entries', 'assets', 'locales', and 'environments' to which you want to unpublish the entries or assets. If you do not specify a source locale, the entries or assets will be unpublished in the master locale automatically.
7171
* @param {Boolean} params.skip_workflow_stage_check Set this to 'true' to publish the entries that are at a workflow stage where they satisfy the applied publish rules.
7272
* @param {Boolean} params.approvals Set this to 'true' to publish the entries that do not require an approval to be published.

lib/stack/contentType/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function ContentType (http, data = {}) {
4444
* @description The Delete ContentType call is used to delete an existing ContentType permanently from your Stack.
4545
* @memberof ContentType
4646
* @func delete
47-
* @returns {String} Success message.
47+
* @returns {Object} Response Object.
4848
* @example
4949
* import * as contentstack from 'contentstack'
5050
* const client = contentstack.client({})

lib/stack/deliveryToken/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function DeliveryToken (http, data = {}) {
3333
* @description The Delete DeliveryToken call is used to delete an existing DeliveryToken permanently from your Stack.
3434
* @memberof DeliveryToken
3535
* @func delete
36-
* @returns {String} Success message.
36+
* @returns {Object} Response Object.
3737
* @example
3838
* import * as contentstack from 'contentstack'
3939
* const client = contentstack.client({})

lib/stack/environment/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function Environment (http, data = {}) {
3131
* @description The Delete Environment call is used to delete an existing Environment permanently from your Stack.
3232
* @memberof Environment
3333
* @func delete
34-
* @returns {String} Success message.
34+
* @returns {Object} Response Object.
3535
* @example
3636
* import * as contentstack from 'contentstack'
3737
* const client = contentstack.client({})

lib/stack/extension/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function Extension (http, data) {
3737
* @description The Delete Extension call is used to delete an existing Extension permanently from your Stack.
3838
* @memberof Extension
3939
* @func delete
40-
* @returns {String} Success message.
40+
* @returns {Object} Response Object.
4141
* @example
4242
* import * as contentstack from 'contentstack'
4343
* const client = contentstack.client({})

0 commit comments

Comments
 (0)