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

refactor: Api response #345

Merged
merged 6 commits into from
Dec 29, 2023
Merged

refactor: Api response #345

merged 6 commits into from
Dec 29, 2023

Conversation

MoulikaKulkarni
Copy link
Contributor

WHAT

  • Refactored the responses of the APIs in the organization module
  • Replaced the return type of object to specified interfaces.
  • Checked the validation on payload for the APIs in the organization module.
  • Marked the 'orgSlug' parameter as required in 'Get Public Profile of an Organization' API.

WHY

  • Refactored the responses so as to not display any confidential, sensitive or unnecessary information to the user.
  • Designed interfaces to replace the object return type so that the API responses are structured and standardized.
  • Checked edge cases on the payload of the APIs in order to make sure that the error responses are propered as specified.
  • Marked the 'orgSlug' parameter as required in 'Get Public Profile of an Organization' API to remove the 'Unauthorized' error that appeared when orgSlug was not passed.

APIs in the Organization Module:

  • Update an organization
  • Get public Organizations
  • Get Org Roles details
  • Get public profile of an Organization
  • Get organization Dashboard
  • Get invitations by OrgId
  • Create organization invitation
  • Get all organizations
  • Get organization by Id
  • Fetch organization user
  • Create an organization
  • Delete an organization

Signed-off-by: Moulika Kulkarni <moulika.kulkarni@ayanworks.com>
@nishad-ayanworks
Copy link
Contributor

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

6 New issues 0 Security Hotspots No data about Coverage 0.0% Duplication on New Code

See analysis details on SonarCloud

@MoulikaKulkarni Please look into these sonar cloud issues once.

Copy link
Contributor

@nishad-ayanworks nishad-ayanworks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check comment

Signed-off-by: Moulika Kulkarni <moulika.kulkarni@ayanworks.com>
Signed-off-by: Moulika Kulkarni <moulika.kulkarni@ayanworks.com>
@MoulikaKulkarni MoulikaKulkarni linked an issue Dec 14, 2023 that may be closed by this pull request
42 tasks
@MoulikaKulkarni
Copy link
Contributor Author

Please check comment

I have resolved the comment. Kindly check.

@@ -51,12 +56,12 @@ export class OrganizationService extends BaseService {
* @param
* @returns Public organizations list
*/
async getPublicOrganizations(getAllOrgsDto: GetAllOrganizationsDto): Promise<{ response: object }> {
async getPublicOrganizations(getAllOrgsDto: GetAllOrganizationsDto): Promise<{ response: GetOrgs }> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not have an object key "response" outside the interface. This should be a part of Response interface. Please update this at multiple places in this PR.

@@ -195,7 +196,7 @@ export class OrganizationService {
throw new NotFoundException(ResponseMessages.organisation.error.profileNotFound);
}

const credentials = await this.organizationRepository.getCredDefByOrg(organizationDetails['id']);
const credentials = await this.organizationRepository.getCredDefByOrg(organizationDetails.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use meaningful names for variables. In this case, instead of "credentials" it should be "credDefs".

@@ -103,7 +103,7 @@ export class UserController {
* @returns organization users list
*/
@MessagePattern({ cmd: 'fetch-organization-user' })
async getOrganizationUsers(payload: { orgId: string, pageNumber: number, pageSize: number, search: string }): Promise<object> {
async getOrganizationUsers(payload: { orgId: string, pageNumber: number, pageSize: number, search: string }): Promise<OrgUsers> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This payload should be referring to one interface instead of adding an object.

@@ -0,0 +1,9 @@
export interface IOrgRoles {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's maintain naming convention for interfaces across the platform.

Signed-off-by: Moulika Kulkarni <moulika.kulkarni@ayanworks.com>
Signed-off-by: Moulika Kulkarni <moulika.kulkarni@ayanworks.com>
Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@ajile-in ajile-in changed the title refactor:Api response refactor: Api response Dec 29, 2023
@nishad-ayanworks nishad-ayanworks merged commit d1bd078 into develop Dec 29, 2023
2 checks passed
@ankita-p17 ankita-p17 deleted the api-response branch March 11, 2024 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: APIs response refactor
3 participants