Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOISSUE - Fix remove user from domain #68

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-fireants-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@absmach/magistrala-sdk": patch
---

update documentation
5 changes: 5 additions & 0 deletions .changeset/tall-pandas-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@absmach/magistrala-sdk": patch
---

Update remove user from domain to remove the need for relation
3 changes: 1 addition & 2 deletions examples/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ mySdk.domains.AddUsertoDomain(

mySdk.domains.RemoveUserfromDomain(
'<domainID>',
['<userID>', '<userID>'],
'administrator',
'<userID>',
token
)
.then((response: any) => {
Expand Down
7 changes: 3 additions & 4 deletions src/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,15 @@ export default class Domains {
}
}

public async RemoveUserfromDomain (domainID: string, userIDs: string[], relation: Relation, token: string): Promise<Response> {
public async RemoveUserfromDomain (domainID: string, userID: string, token: string): Promise<Response> {
// RemoveUserfromDomain removes user from domain.
/**
* @method RemoveUserfromDomain - Removes user from domain.
* @param {string} domainID - domain ID.
* @param {array} userIDs - array of user IDs.
* @param {string} relation - user relation to domain such as 'administrator', 'member'.
* @param {string} userID - user ID.
* @returns {object} - returns an object Response that carries the status code and a response message.
*/
const req = { user_ids: userIDs, relation }
const req = { user_id: userID }
const options: RequestInit = {
method: 'POST',
headers: {
Expand Down
2 changes: 1 addition & 1 deletion tests/domains.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('Domains', () => {
}
fetchMock.mockResponseOnce(JSON.stringify(removeUserfromDomainResponse))

const response = await sdk.domains.RemoveUserfromDomain(domainId, userIds, relation, token)
const response = await sdk.domains.RemoveUserfromDomain(domainId, userId, token)
expect(response).toEqual(removeUserfromDomainResponse)
})
})
Loading