An ACSP is an organisation that can file on behalf of their clients. The acsp-manage-users-api is a service for managing the memberships of users with ACSPs. This Microservice exposes endpoints for creating memberships, changing a user's membership type, removing memberships, and retrieving data about memberships.
This Microservice has the following dependencies:
This section explains how the endpoints in this Microservice can be executed in Tilt. In particular, Section 3.1 describes the steps that can be taken to run the Microservice in Tilt, Section 3.2 explains how the database can be populated with test data, and Section 3.3 describes the endpoints that can be executed based on this test data.
To run this Microservice in Tilt, the platform
and acsp-manage-users
modules and accounts-user-api
modules must be enabled.
These modules and services can be enabled by running the following commands in the docker-chs-development
directory:
./bin/chs-dev modules enable platform
./bin/chs-dev modules enable acsp-manage-users
./bin/chs-dev services enable accounts-user-api
To run this Microservice in development mode, the following command can also be executed in the docker-chs-development
directory:
./bin/chs-dev development enable acsp-manage-users-api
After all of the services are enabled, use the tilt up
command.
To enable debugging, create a new Remove JVM Debug
configuration, and set the port to 9095
.
This Microservice draws on four MongoDB collections:
account.users
: This collection contains data relating to users. The pertinent data in a given document in this collection includes_id
,email
, anddisplay_name
. The Microservice uses_id
to uniquely identify a user, andemail
anddisplay_name
are items of data that are returned by some of the endpoints.account.oauth2_authorisations
: This collection contains data relating to user sessions. The pertinent data in this collection includestoken
anduser_details.user_id
, which are used to uniquely identify the session and user respectively. After upstream dependencies have been satisfied and this Microservice has been updated,token_permissions
will also be important, because it will contain information about the actions that the user is permitted to perform in this Microservice.acsp_members.acsp_data
: This collection contains data relating to ACSPs. The pertinent data in a given document in this collection is_id
,acsp_name
, andacsp_status
._id
uniquely identifies the ACSP, andacsp_name
andacsp_status
are data that returned by some of the endpoints. This is a temporary MongoDB collection, and will be replaced by calls to theacsp-profile-api
, after it has been built.acsp_members.acsp_members
: This collection contains data relating to memberships. A given document defines the association between a user and an ACSP. The most pertinent data in this collection include_id
,user_id
,acsp_number
, which are used to uniquely identify the membership, user, and ACSP respectively.user_role
andstatus
are also important.user_role
denotes the users membership type, which can beowner
,admin
orstandard
, and determines actions that the user is permitted to perform.status
can beactive
andremoved
, which communicates whether the membership is currently active or not.
There is a Confluence page with MongoDB scripts that can be executed in MONGOSH
, to populate the account.users
, acsp_members.acsp_data
, and acsp_members.acsp_members
tables with test data. One could copy the MongoDB document from the account.oauth2_authorisations
table in the Phoenix1 environment, where the token=wEusf3QyFlp2ckUTPxIJLloWaLGRFq7H5PO1iynU465s9NmU0lngu5sCWbWjZxeBmv0WmVs6oQg
to their local account.oauth2_authorisations
table; doing so will enable one to make calls as the demo user, which is one of the users in the test dataset.
The Confluence page can be found at: Inugami Test Data
The Microservice is hosted at http://api.chs.local:4001
, so all of the endpoints can be called by appending the appropriate path to the end of this url.
All of the endpoints in this Microservice can either be run using OAuth 2.0
or API Key
authorisation headers. Eric can use these headers to enrich the request with additional headers.
- If the endpoint is being called with
OAuth 2.0
, then in Postman,Auth Type
must be set toOAuth 2.0
andtoken
must be set to atoken
fromaccount.oauth2_authorisations
. - Otherwise, if the endpoint is being called with
API Key
, then in Postman,Auth Type
must be set toNo Auth
, and anAuthorization
header needs to be added with a valid key e.g.x9yZIA81Zo9J46Kzp3JPbfld6kOqxR47EAYqXbRX
The High Level Design for the Microservice is available at: HLD
The remainder of this section lists the endpoints that are available in this Microservice, and provides links to detailed documentation about these endpoints e.g. required headers, path variables, query params, request bodies, and their behaviour.
Method | Path | Description | Documentation |
---|---|---|---|
GET | /acsps/{acsp_number}/memberships | This endpoint can be used to retrieve users that are associated with a given ACSP. | LLD - getMembersForAcsp |
POST | /acsps/{acsp_number}/memberships | This endpoint can be used to form an association between a user and an ACSP. | LLD - addMemberForAcsp |
GET | /acsps/memberships/{membership_id} | This endpoint can be used to retrieve an association based on it’s id. | LLD - getAcspMembershipForAcspAndId |
PATCH | /acsps/memberships/{membership_id} | This endpoint can be used to update an association between a given user and ACSP. The endpoint currently supports changing the associations status and role. | LLD - updateAcspMembershipForAcspAndId |
GET | /user/acsps/memberships | This endpoint can be used to retrieve ACSPs that are associated with the user in session. | LLD - getAcspMembershipsForUserId |
POST | /acsps/{acsp_number}/memberships/lookup | This endpoint can be used to fetch associations for a given user and ACSP. | LLD - findMembershipsForUserAndAcsp |