Skip to content

Commit 11b054e

Browse files
refactor: ♻️ changes users in teams to teamUsers
1 parent 4fecf6f commit 11b054e

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

lib/organization/teams/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ export function Teams (http, data) {
8686
* @example
8787
* import * as contentstack from '@contentstack/management'
8888
* const client = contentstack.client()
89-
* client.organization('organizationUid').teams('teamUid').users().fetchAll()
89+
* client.organization('organizationUid').teams('teamUid').teamUsers().fetchAll()
9090
* .then((response) => console.log(response))
9191
*
9292
*/
93-
this.users = (userId = null) => {
93+
this.teamUsers = (userId = null) => {
9494
data.organizationUid = this.organizationUid
9595
data.teamUid = this.uid
9696
if (userId) {

lib/organization/teams/teamUsers/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function TeamUsers (http, data) {
2121
* import * as contentstack from '@contentstack/management'
2222
* const client = contentstack.client()
2323
*
24-
* client.organization('organizationUid').teams('teamUid').users('userId').remove()
24+
* client.organization('organizationUid').teams('teamUid').teamUsers('userId').remove()
2525
* .then((response) => console.log(response))
2626
*
2727
*/
@@ -40,7 +40,7 @@ export function TeamUsers (http, data) {
4040
* const usersMail = {
4141
* emails: ['emailId1','emailId2' ]
4242
* }
43-
* client.organization('organizationUid').teams('teamUid').users('userId').add(usersMail)
43+
* client.organization('organizationUid').teams('teamUid').teamUsers('userId').add(usersMail)
4444
* .then((response) => console.log(response))
4545
*
4646
*/
@@ -56,15 +56,15 @@ export function TeamUsers (http, data) {
5656
* const client = contentstack.client()
5757
* const usersMail = {
5858
* emails: ['emailId1','emailId2' ]}
59-
* client.organization('organizationUid').teams('teamUid').users('userId').query().find()
59+
* client.organization('organizationUid').teams('teamUid').teamUsers('userId').query().find()
6060
* .then((response) => console.log(response))
6161
*
6262
*/
6363
this.fetchAll = fetchAll(http, UsersCollection)
6464
}
6565
}
6666
export function UsersCollection (http, data) {
67-
const obj = cloneDeep(data.users) || []
67+
const obj = cloneDeep(data.teamUsers) || []
6868
const usersCollection = obj.map((user) => {
6969
return new TeamUsers(http, { userId: user })
7070
})

test/api/team-users-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ describe('Teams Users API Test', () => {
4343
})
4444

4545
function makeUsers (organizationUid, teamUid, userId = null) {
46-
return client.organization(organizationUid).teams(teamUid).users(userId)
46+
return client.organization(organizationUid).teams(teamUid).teamUsers(userId)
4747
}

test/typescript/teamUsers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ export function testTeamUsers (organization: Organization) {
88
const usersMail = {
99
emails: ['email@email.com']
1010
}
11-
organization.teams(teamUid).users().add(usersMail).then((response) => {
11+
organization.teams(teamUid).teamUsers().add(usersMail).then((response) => {
1212
expect(response.status).to.be.eql(201)
1313
done()
1414
})
1515
.catch(done)
1616
})
1717
test('should remove the user when uid is passed', done => {
1818
const user_id = 'user_id'
19-
organization.teams(teamUid).users(user_id).remove().then((response) => {
19+
organization.teams(teamUid).teamUsers(user_id).remove().then((response) => {
2020
expect(response.status).to.be.equal(204)
2121
done()
2222
})
2323
.catch(done)
2424
})
2525
test('should fetch all users', done => {
26-
organization.teams(teamUid).users()
26+
organization.teams(teamUid).teamUsers()
2727
.fetchAll()
2828
.then((response) => {
2929
expect(response.items[0]).not.to.be.equal(undefined)

test/unit/team-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('Contentstack Team test', () => {
7676
it('should fetch all users', done => {
7777
var mock = new MockAdapter(Axios)
7878
mock.onGet(`/organizations/organization_uid/teams/UID/users`).reply(200, teamUsersMock)
79-
makeTeams({ ...systemUidMock }).users().fetchAll()
79+
makeTeams({ ...systemUidMock }).teamUsers().fetchAll()
8080
.then((users) => {
8181
users.items.forEach((user) => {
8282
expect(user.uidId).to.be.not.equal(null)

types/teams/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { StackRoleMapping, StackRoleMappings, StackRoleMappingData } from "./sta
66

77
export interface Team extends TeamData {
88
update(data: TeamData, param?: { includeUserDetails?: boolean}): Promise<AnyProperty>
9-
users(): TeamUsers
10-
users(uid: string): TeamUser
9+
teamUsers(): TeamUsers
10+
teamUsers(uid: string): TeamUser
1111
stackRoleMappings(): StackRoleMappings
1212
stackRoleMappings(stackApiKey: string): StackRoleMapping
1313
fetch(): Promise<Team>

0 commit comments

Comments
 (0)