Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Musilah <[email protected]>
  • Loading branch information
Musilah committed Mar 28, 2024
1 parent 6d4fbd0 commit db304e7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 69 deletions.
6 changes: 3 additions & 3 deletions examples/usersExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mySdk.users.Update(
})

mySdk.users.UpdateUserIdentity(
{ credentials: { identity: '<userIdentity>' } },
{ id: '<userId>', credentials: { identity: '<userIdentity>' } },
'<token>'
)
.then((response: any) => {
Expand All @@ -86,7 +86,7 @@ mySdk.users.UpdateUserIdentity(
})

mySdk.users.UpdateUserTags(
{ tags: ['foo', 'bar'] },
{ id: '<userId>', tags: ['foo', 'bar'] },
'<token>'
)
.then((response: any) => {
Expand All @@ -97,7 +97,7 @@ mySdk.users.UpdateUserTags(
})

mySdk.users.UpdateUserRole(
{ role: '<user_role>' },
{ id: '<userId>', role: '<user_role>' },
'<token>'
)
.then((response: any) => {
Expand Down
107 changes: 41 additions & 66 deletions src/users.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-throw-literal */
/* eslint-disable no-useless-catch */
import Errors from './errors'

export interface User {
Expand Down Expand Up @@ -145,9 +142,8 @@ export default class Users {
* }
*/

const options = {
method: 'post',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'POST',
headers: {
'Content-Type': this.contentType
},
Expand Down Expand Up @@ -187,9 +183,8 @@ export default class Users {
*
*/

const options = {
method: 'post',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'POST',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${refreshToken}`
Expand Down Expand Up @@ -232,9 +227,8 @@ export default class Users {
*
*/

const options = {
method: 'patch',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'PATCH',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -280,9 +274,8 @@ export default class Users {
* }
*/

const options = {
method: 'patch',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'PATCH',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -332,9 +325,8 @@ export default class Users {
*
*/

const options = {
method: 'patch',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'PATCH',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -378,16 +370,16 @@ export default class Users {
*
*/

const secret = { oldSecret, newSecret }
const options = {
method: 'patch',
maxBodyLength: 2000,
const secret = { old_secret: oldSecret, new_secret: newSecret }
const options: RequestInit = {
method: 'PATCH',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
},
body: JSON.stringify(secret)
}
console.log('body', options.body)

try {
const response = await fetch(
Expand Down Expand Up @@ -420,13 +412,8 @@ export default class Users {
*
*/

const options = {
method: 'patch',
url: new URL(
`${this.usersEndpoint}/${user.id}/role`,
this.usersUrl
).toString(),
maxBodyLength: 2000,
const options: RequestInit = {
method: 'PATCH',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -467,9 +454,8 @@ export default class Users {
*
*/

const options = {
method: 'get',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'GET',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -509,9 +495,8 @@ export default class Users {
*
*/

const options = {
method: 'get',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'GET',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -559,9 +544,8 @@ export default class Users {
Object.entries(queryParams).map(([key, value]) => [key, String(value)])
)

const options = {
method: 'get',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'GET',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand All @@ -587,7 +571,7 @@ export default class Users {
}
}

public async Disable (user: User, token: string): Promise<User> {
public async Disable (user: User, token: string): Promise<string> {
// Disable a user
/**
* Disables a user with provided ID and valid token.
Expand All @@ -602,9 +586,8 @@ export default class Users {
* }
*/

const options = {
method: 'post',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'POST',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand All @@ -624,14 +607,13 @@ export default class Users {
const errorRes = await response.json()
throw this.userError.HandleError(errorRes.error, response.status)
}
const userData = await response.json()
return userData
return 'User Disabled'
} catch (error) {
throw error
}
}

public async Enable (user: User, token: string): Promise<User> {
public async Enable (user: User, token: string): Promise<string> {
// Enable a user.
/**
* Enables a previously disabled user when provided with token and valid ID.
Expand All @@ -647,9 +629,8 @@ export default class Users {
*
*/

const options = {
method: 'post',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'POST',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand All @@ -668,8 +649,7 @@ export default class Users {
const errorRes = await response.json()
throw this.userError.HandleError(errorRes.error, response.status)
}
const userData = await response.json()
return userData
return 'User Enabled'
} catch (error) {
throw error
}
Expand All @@ -694,9 +674,8 @@ export default class Users {
Object.entries(queryParams).map(([key, value]) => [key, String(value)])
)

const options = {
method: 'get',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'GET',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -739,9 +718,8 @@ export default class Users {
Object.entries(queryParams).map(([key, value]) => [key, String(value)])
)

const options = {
method: 'get',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'GET',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -785,9 +763,8 @@ export default class Users {
Object.entries(queryParams).map(([key, value]) => [key, String(value)])
)

const options = {
method: 'get',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'GET',
headers: {
'Content-Type': this.contentType,
Authorization: `Bearer ${token}`
Expand Down Expand Up @@ -827,9 +804,8 @@ export default class Users {
* }
*/

const options = {
method: 'post',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'POST',
headers: {
'Content-Type': this.contentType
},
Expand Down Expand Up @@ -874,13 +850,12 @@ export default class Users {

const rpr = { password, confPass, token }

const options = {
method: 'put',
maxBodyLength: 2000,
const options: RequestInit = {
method: 'PUT',
headers: {
'Content-Type': this.contentType
},
data: rpr
body: JSON.stringify(rpr)
}
try {
const response = await fetch(
Expand Down

0 comments on commit db304e7

Please sign in to comment.