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

New endpoints partner access endpoints #306

Closed
wants to merge 11 commits into from

Conversation

Zahra-8d
Copy link
Contributor

@Zahra-8d Zahra-8d commented Sep 7, 2023

  1. Pull users with access codes that have therapy enabled
  2. Update number of therapy sessions for access codes

Service tests are in-progress. They are currently not working and incomplete.

src/partner-access/partner-access.service.ts Outdated Show resolved Hide resolved
])
.where('partnerAccess.featureTherapy=true') //only get access codes with feature therapy turned on
.groupBy('partnerAccess.userId') //group by user as we can have users with multiple access codes
.getRawMany(); //use instead of getMany as the columns are derived
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally the response would be serialised into camel case. We send our JSON data with camel cases.

src/partner-access/partner-access.service.ts Show resolved Hide resolved
src/partner-access/partner-access.service.ts Show resolved Hide resolved
description: 'Updates number of therapy sessions available to an access code',
})
@Put('users')
@UseGuards(SuperAdminAuthGuard)
Copy link
Contributor

Choose a reason for hiding this comment

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

Have a look at @APIBody() from nestjs. It automatically sends a Bad request if the JSON data isn't sent in the right format. A DTO should also be created to cover this.

Copy link
Contributor

Choose a reason for hiding this comment

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

In terms of this request - sorry again for being picky. I think this just needs to be PATCH as its a partial update and it doesn't need the /users. I would probably expect the endpoint to be PATCH /partner-access/:id with a JSON body like so:

{
   therapySessionsRemaining: new value
}

I think there might be a slight issue with this implementation as you are sending an aggregate to the frontend and then sending the updated aggregate to the backend to update the access code. If a user had 2 access codes, they could get extra therapy sessions

@eleanorreem eleanorreem closed this Oct 3, 2023
@annarhughes annarhughes deleted the partner-access-update-endpoints branch July 30, 2024 09:04
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.

2 participants