Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
Signed-off-by: ianmuchyri <[email protected]>
  • Loading branch information
ianmuchyri committed Nov 19, 2024
1 parent cdea55e commit 75f150d
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 58 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 56 additions & 56 deletions src/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class Roles {
try {
const response = await fetch(
new URL(`${endpoint}/roles/available-actions`, url).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
Expand All @@ -46,7 +46,7 @@ export default class Roles {
roleName: string,
token: string,
optionalActions?: string[],
optionalMembers?: string[]
optionalMembers?: string[],
) {
const options: RequestInit = {
method: "POST",
Expand All @@ -63,7 +63,7 @@ export default class Roles {
try {
const response = await fetch(
new URL(`${endpoint}/${entityId}/roles`, url).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
Expand All @@ -81,10 +81,10 @@ export default class Roles {
endpoint: string,
entityId: string,
queryParams: PageMetadata,
token: string
token: string,
) {
const stringParams: Record<string, string> = Object.fromEntries(
Object.entries(queryParams).map(([key, value]) => [key, String(value)])
Object.entries(queryParams).map(([key, value]) => [key, String(value)]),
);
const options: RequestInit = {
method: "GET",
Expand All @@ -97,11 +97,11 @@ export default class Roles {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles?${new URLSearchParams(
stringParams
stringParams,
).toString()}`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
Expand All @@ -119,7 +119,7 @@ export default class Roles {
endpoint: string,
entityId: string,
roleName: string,
token: string
token: string,
) {
const options: RequestInit = {
method: "GET",
Expand All @@ -132,7 +132,7 @@ export default class Roles {
try {
const response = await fetch(
new URL(`${endpoint}/${entityId}/roles/${roleName}`, url).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
Expand All @@ -151,7 +151,7 @@ export default class Roles {
entityId: string,
roleName: string,
role: Role,
token: string
token: string,
) {
const options: RequestInit = {
method: "PUT",
Expand All @@ -165,7 +165,7 @@ export default class Roles {
try {
const response = await fetch(
new URL(`${endpoint}/${entityId}/roles/${roleName}`, url).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
Expand All @@ -183,7 +183,7 @@ export default class Roles {
endpoint: string,
entityId: string,
roleName: string,
token: string
token: string,
) {
const options: RequestInit = {
method: "DELETE",
Expand All @@ -196,7 +196,7 @@ export default class Roles {
try {
const response = await fetch(
new URL(`${endpoint}/${entityId}/roles/${roleName}`, url).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
Expand All @@ -218,31 +218,31 @@ export default class Roles {
entityId: string,
roleName: string,
actions: string[],
token: string
token: string,
) {
const options: RequestInit = {
method: "POST",
headers: {
"Content-Type": this.contentType,
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ actions: actions }),
body: JSON.stringify({ actions }),
};

try {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles/${roleName}/actions`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
throw this.roleError.HandleError(errorRes.message, response.status);
throw Errors.HandleError(errorRes.message, response.status);
}
const actions: string[] = await response.json();
return actions;
const addedActions: string[] = await response.json();
return addedActions;
} catch (error) {
throw error;
}
Expand All @@ -253,7 +253,7 @@ export default class Roles {
endpoint: string,
entityId: string,
roleName: string,
token: string
token: string,
) {
const options: RequestInit = {
method: "GET",
Expand All @@ -267,13 +267,13 @@ export default class Roles {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles/${roleName}/actions`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
throw this.roleError.HandleError(errorRes.message, response.status);
throw Errors.HandleError(errorRes.message, response.status);
}
const actions: string[] = await response.json();
return actions;
Expand All @@ -288,28 +288,28 @@ export default class Roles {
entityId: string,
roleName: string,
actions: string[],
token: string
token: string,
) {
const options: RequestInit = {
method: "POST",
headers: {
"Content-Type": this.contentType,
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ actions: actions }),
body: JSON.stringify({ actions }),
};

try {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles/${roleName}/actions/delete`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
throw this.roleError.HandleError(errorRes.message, response.status);
throw Errors.HandleError(errorRes.message, response.status);
}
const deleteResponse: Response = {
status: response.status,
Expand All @@ -326,7 +326,7 @@ export default class Roles {
endpoint: string,
entityId: string,
roleName: string,
token: string
token: string,
) {
const options: RequestInit = {
method: "POST",
Expand All @@ -340,13 +340,13 @@ export default class Roles {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles/${roleName}/actions/delete-all`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
throw this.roleError.HandleError(errorRes.message, response.status);
throw Errors.HandleError(errorRes.message, response.status);
}
const deleteResponse: Response = {
status: response.status,
Expand All @@ -364,31 +364,31 @@ export default class Roles {
entityId: string,
roleName: string,
members: string[],
token: string
token: string,
) {
const options: RequestInit = {
method: "POST",
headers: {
"Content-Type": this.contentType,
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ members: members }),
body: JSON.stringify({ members }),
};

try {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles/${roleName}/members`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
throw this.roleError.HandleError(errorRes.message, response.status);
throw Errors.HandleError(errorRes.message, response.status);
}
const members: string[] = await response.json();
return members;
const addedMembers: string[] = await response.json();
return addedMembers;
} catch (error) {
throw error;
}
Expand All @@ -400,7 +400,7 @@ export default class Roles {
entityId: string,
roleName: string,
queryParams: BasicPageMeta,
token: string
token: string,
) {
const options: RequestInit = {
method: "GET",
Expand All @@ -411,22 +411,22 @@ export default class Roles {
};

const stringParams: Record<string, string> = Object.fromEntries(
Object.entries(queryParams).map(([key, value]) => [key, String(value)])
Object.entries(queryParams).map(([key, value]) => [key, String(value)]),
);

try {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles/${roleName}/members?${new URLSearchParams(
stringParams
stringParams,
).toString()}`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
throw this.roleError.HandleError(errorRes.message, response.status);
throw Errors.HandleError(errorRes.message, response.status);
}
const members: string[] = await response.json();
return members;
Expand All @@ -441,28 +441,28 @@ export default class Roles {
entityId: string,
roleName: string,
members: string[],
token: string
token: string,
) {
const options: RequestInit = {
method: "POST",
headers: {
"Content-Type": this.contentType,
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ members: members }),
body: JSON.stringify({ members }),
};

try {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles/${roleName}/members/delete`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
throw this.roleError.HandleError(errorRes.message, response.status);
throw Errors.HandleError(errorRes.message, response.status);
}
const deleteResponse: Response = {
status: response.status,
Expand All @@ -479,7 +479,7 @@ export default class Roles {
endpoint: string,
entityId: string,
roleName: string,
token: string
token: string,
) {
const options: RequestInit = {
method: "POST",
Expand All @@ -493,13 +493,13 @@ export default class Roles {
const response = await fetch(
new URL(
`${endpoint}/${entityId}/roles/${roleName}/members/delete-all`,
url
url,
).toString(),
options
options,
);
if (!response.ok) {
const errorRes = await response.json();
throw this.roleError.HandleError(errorRes.message, response.status);
throw Errors.HandleError(errorRes.message, response.status);
}
const deleteResponse: Response = {
status: response.status,
Expand Down
Loading

0 comments on commit 75f150d

Please sign in to comment.