diff --git a/.eslintrc.json b/.eslintrc.json index e7da688..b27d55c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,6 +11,7 @@ "rules": { "@typescript-eslint/no-unsafe-argument": "off", "@typescript-eslint/no-throw-literal": "off", - "no-useless-catch": "off" + "no-useless-catch": "off", + "no-unused-vars": "off" } } diff --git a/examples/domainsExamples.ts b/examples/domainsExamples.ts index 3072232..44f405a 100644 --- a/examples/domainsExamples.ts +++ b/examples/domainsExamples.ts @@ -21,7 +21,7 @@ mySdk.domains mySdk.domains.UpdateDomain( { name: '', id: '' }, '' - ) +) .then((response: any) => { console.log('response: ', response) }) @@ -42,7 +42,7 @@ mySdk.domains.Domain( mySdk.domains.DomainPermissions( '', - 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiJmMjQ4ZDA1Ny0yODNjLTQzZjQtOGJhMS0xM2ZmYzU1MTRjMDciLCJleHAiOjE3MTE0NzE4MDMsImlhdCI6MTcxMTQ2ODIwMywiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiNzA1YmMzYzYtN2Y5My00MWQ2LWJjNGMtMGE4N2Y4NWU0OTczIiwidHlwZSI6MCwidXNlciI6IjcwNWJjM2M2LTdmOTMtNDFkNi1iYzRjLTBhODdmODVlNDk3MyJ9.Gjhos0VCZiDoIYKsTF6iQAxUlU8CKUz2e6l007_ICI_X9_0t2LTG0G15qbQXsqZKzo4gAPgyuW8BYJKD7SlhuA' + '' ) .then((response: any) => { console.log('response: ', response) @@ -53,7 +53,7 @@ mySdk.domains.DomainPermissions( mySdk.domains.Domains( { offset: 0, limit: 10 }, - 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiJmMjQ4ZDA1Ny0yODNjLTQzZjQtOGJhMS0xM2ZmYzU1MTRjMDciLCJleHAiOjE3MTE0NzE4MDMsImlhdCI6MTcxMTQ2ODIwMywiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiNzA1YmMzYzYtN2Y5My00MWQ2LWJjNGMtMGE4N2Y4NWU0OTczIiwidHlwZSI6MCwidXNlciI6IjcwNWJjM2M2LTdmOTMtNDFkNi1iYzRjLTBhODdmODVlNDk3MyJ9.Gjhos0VCZiDoIYKsTF6iQAxUlU8CKUz2e6l007_ICI_X9_0t2LTG0G15qbQXsqZKzo4gAPgyuW8BYJKD7SlhuA' + '' ) .then((response: any) => { console.log('response: ', response) @@ -65,7 +65,7 @@ mySdk.domains.Domains( mySdk.domains.ListUserDomains( '', { offset: 0, limit: 10 }, - 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiJmMjQ4ZDA1Ny0yODNjLTQzZjQtOGJhMS0xM2ZmYzU1MTRjMDciLCJleHAiOjE3MTE0NzE4MDMsImlhdCI6MTcxMTQ2ODIwMywiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiNzA1YmMzYzYtN2Y5My00MWQ2LWJjNGMtMGE4N2Y4NWU0OTczIiwidHlwZSI6MCwidXNlciI6IjcwNWJjM2M2LTdmOTMtNDFkNi1iYzRjLTBhODdmODVlNDk3MyJ9.Gjhos0VCZiDoIYKsTF6iQAxUlU8CKUz2e6l007_ICI_X9_0t2LTG0G15qbQXsqZKzo4gAPgyuW8BYJKD7SlhuA' + '' ) .then((response: any) => { console.log('response: ', response) @@ -76,7 +76,7 @@ mySdk.domains.ListUserDomains( mySdk.domains.EnableDomain( '', - 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiJmMjQ4ZDA1Ny0yODNjLTQzZjQtOGJhMS0xM2ZmYzU1MTRjMDciLCJleHAiOjE3MTE0NzE4MDMsImlhdCI6MTcxMTQ2ODIwMywiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiNzA1YmMzYzYtN2Y5My00MWQ2LWJjNGMtMGE4N2Y4NWU0OTczIiwidHlwZSI6MCwidXNlciI6IjcwNWJjM2M2LTdmOTMtNDFkNi1iYzRjLTBhODdmODVlNDk3MyJ9.Gjhos0VCZiDoIYKsTF6iQAxUlU8CKUz2e6l007_ICI_X9_0t2LTG0G15qbQXsqZKzo4gAPgyuW8BYJKD7SlhuA' + '' ) .then((response: any) => { console.log('response: ', response) @@ -87,7 +87,7 @@ mySdk.domains.EnableDomain( mySdk.domains.DisableDomain( '', - 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiJmMjQ4ZDA1Ny0yODNjLTQzZjQtOGJhMS0xM2ZmYzU1MTRjMDciLCJleHAiOjE3MTE0NzE4MDMsImlhdCI6MTcxMTQ2ODIwMywiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiNzA1YmMzYzYtN2Y5My00MWQ2LWJjNGMtMGE4N2Y4NWU0OTczIiwidHlwZSI6MCwidXNlciI6IjcwNWJjM2M2LTdmOTMtNDFkNi1iYzRjLTBhODdmODVlNDk3MyJ9.Gjhos0VCZiDoIYKsTF6iQAxUlU8CKUz2e6l007_ICI_X9_0t2LTG0G15qbQXsqZKzo4gAPgyuW8BYJKD7SlhuA' + '' ) .then((response: any) => { console.log('response: ', response) @@ -98,8 +98,9 @@ mySdk.domains.DisableDomain( mySdk.domains.AddUsertoDomain( '', - { userIDs: ['', ''], relation: '' }, - 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiJmMjQ4ZDA1Ny0yODNjLTQzZjQtOGJhMS0xM2ZmYzU1MTRjMDciLCJleHAiOjE3MTE0NzE4MDMsImlhdCI6MTcxMTQ2ODIwMywiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiNzA1YmMzYzYtN2Y5My00MWQ2LWJjNGMtMGE4N2Y4NWU0OTczIiwidHlwZSI6MCwidXNlciI6IjcwNWJjM2M2LTdmOTMtNDFkNi1iYzRjLTBhODdmODVlNDk3MyJ9.Gjhos0VCZiDoIYKsTF6iQAxUlU8CKUz2e6l007_ICI_X9_0t2LTG0G15qbQXsqZKzo4gAPgyuW8BYJKD7SlhuA' + ['', ''], + '', + '' ) .then((response: any) => { console.log('response: ', response) @@ -110,7 +111,8 @@ mySdk.domains.AddUsertoDomain( mySdk.domains.RemoveUserfromDomain( '', - { userIDs: ['', ''], relation: '' }, + ['', ''], + '', '' ) .then((response: any) => { diff --git a/examples/usersExamples.ts b/examples/usersExamples.ts index 093457f..ecca4c8 100644 --- a/examples/usersExamples.ts +++ b/examples/usersExamples.ts @@ -6,205 +6,205 @@ const mySdk = new SDK({ usersUrl: defaultUrl + ':9002' }) -mySdk.users - .Create({ - name: '', - credentials: { - identity: 'James@email.com', - secret: '12345678' - } - }) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.User( - '', - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) +// mySdk.users +// .Create({ +// name: '', +// credentials: { +// identity: 'James@email.com', +// secret: '12345678' +// } +// }) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.User( +// '', +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) mySdk.users.UserProfile( - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.CreateToken( - { identity: 'admin@example.com', secret: '12345678' } -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.RefreshToken( - { identity: 'userId' }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.Update( - { id: '', name: '' }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.UpdateUserIdentity( - { id: '', credentials: { identity: '' } }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.UpdateUserTags( - { id: '', tags: ['foo', 'bar'] }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.UpdateUserRole( - { id: '', role: '' }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.Disable( - { id: '' }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.Enable( - { id: '' }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.Users( - { offset: 0, limit: 10 }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.UpdateUserPassword( - '', '', - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.ListUserChannels( - '', - { offset: 0, limit: 10 }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.ListUserThings( - '', - { offset: 0, limit: 10 }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.ListUserGroups( - '', - { offset: 0, limit: 10 }, - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.ResetPasswordRequest( - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) - -mySdk.users.ResetPassword( - '', - '', - '' -) - .then((response: any) => { - console.log('response: ', response) - }) - .catch((error) => { - console.log(error) - }) + 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIzZGQ3YWI0Yy01OTliLTQxYzEtOTIzYi02MDdhZDg3MWIzNGMiLCJleHAiOjE3MTE2Mzc4NTAsImlhdCI6MTcxMTYzNDI1MCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiNzA1YmMzYzYtN2Y5My00MWQ2LWJjNGMtMGE4N2Y4NWU0OTczIiwidHlwZSI6MCwidXNlciI6IjcwNWJjM2M2LTdmOTMtNDFkNi1iYzRjLTBhODdmODVlNDk3MyJ9.IAaKXePzaYefxBY42UPO846T5oC04QzokejI7ZHURgzCcTfdADgPcEk0v71GCF9ciMIphMDOMSzptfdpy0CedQ' +) + .then((response: any) => { + console.log('response: ', response) + }) + .catch((error) => { + console.log(error) + }) + +// mySdk.users.CreateToken( +// { identity: 'admin@example.com', secret: '12345678', domain_id: '3dd7ab4c-599b-41c1-923b-607ad871b34c' } +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.RefreshToken( +// { identity: 'userId' }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.Update( +// { id: '', name: '' }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.UpdateUserIdentity( +// { id: '', credentials: { identity: '' } }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.UpdateUserTags( +// { id: '', tags: ['foo', 'bar'] }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.UpdateUserRole( +// { id: '', role: '' }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.Disable( +// { id: '' }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.Enable( +// { id: '' }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.Users( +// { offset: 0, limit: 10 }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.UpdateUserPassword( +// '', '', +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.ListUserChannels( +// '', +// { offset: 0, limit: 10 }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.ListUserThings( +// '', +// { offset: 0, limit: 10 }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.ListUserGroups( +// '', +// { offset: 0, limit: 10 }, +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.ResetPasswordRequest( +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) + +// mySdk.users.ResetPassword( +// '', +// '', +// '' +// ) +// .then((response: any) => { +// console.log('response: ', response) +// }) +// .catch((error) => { +// console.log(error) +// }) diff --git a/src/domains.ts b/src/domains.ts index e48f8eb..2030505 100644 --- a/src/domains.ts +++ b/src/domains.ts @@ -23,11 +23,6 @@ interface PageRes { limit: number } -interface UserRelationRequest { - userIDs: string[] - relation: string -} - export default class Domains { // Domains API client @@ -43,7 +38,7 @@ export default class Domains { this.domainError = new Errors() } - public async CreateDomain (domain: Domain, token: string): Promise { + public async CreateDomain (domain: Domain, token: string): Promise { // CreateDomain creates a new domain. const options: RequestInit = { method: 'POST', @@ -70,7 +65,7 @@ export default class Domains { } } - public async UpdateDomain (domain: Domain, token: string): Promise { + public async UpdateDomain (domain: Domain, token: string): Promise { // UpdateDomain updates an existing domain. const options: RequestInit = { method: 'PATCH', @@ -97,7 +92,7 @@ export default class Domains { } } - public async Domain (domainID: string, token: string): Promise { + public async Domain (domainID: string, token: string): Promise { // Domain retrieves domain with provided ID. const options: RequestInit = { method: 'GET', @@ -123,7 +118,7 @@ export default class Domains { } } - public async DomainPermissions (domainID: string, token: string): Promise { + public async DomainPermissions (domainID: string, token: string): Promise { // DomainPermissions retrieves domain permissions with provided ID. /** * @method DomainPermissions - retrieves domain permissions with provided ID. @@ -158,11 +153,11 @@ export default class Domains { } } - public async Domains (query_params: QueryParams, token: string): Promise { + public async Domains (queryParams: QueryParams, token: string): Promise { // Domains retrieves all domains. const stringParams: Record = Object.fromEntries( - Object.entries(query_params).map(([key, value]) => [key, String(value)]) + Object.entries(queryParams).map(([key, value]) => [key, String(value)]) ) const options: RequestInit = { method: 'GET', @@ -188,11 +183,11 @@ export default class Domains { } } - public async ListUserDomains (userID: string, query_params: QueryParams, token: string): Promise { + public async ListUserDomains (userID: string, queryParams: QueryParams, token: string): Promise { // ListUserDomains retrieves all domains for a user. const stringParams: Record = Object.fromEntries( - Object.entries(query_params).map(([key, value]) => [key, String(value)]) + Object.entries(queryParams).map(([key, value]) => [key, String(value)]) ) const options: RequestInit = { method: 'GET', @@ -268,8 +263,9 @@ export default class Domains { } } - public async AddUsertoDomain (domainID: string, req: UserRelationRequest, token: string): Promise { + public async AddUsertoDomain (domainID: string, userIDs: string[], relation: string, token: string): Promise { // AddUsertoDomain adds user to domain. + const req = { user_ids: userIDs, relation } const options: RequestInit = { method: 'POST', headers: { @@ -294,8 +290,9 @@ export default class Domains { } } - public async RemoveUserfromDomain (domainID: string, req: UserRelationRequest, token: string): Promise { + public async RemoveUserfromDomain (domainID: string, userIDs: string[], relation: string, token: string): Promise { // RemoveUserfromDomain removes user from domain. + const req = { user_ids: userIDs, relation } const options: RequestInit = { method: 'POST', headers: {