Skip to content

Commit 83872e5

Browse files
SIV-461 A new function for retrieving a single association by user email added
1 parent 712108e commit 83872e5

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/services/associations/service.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,27 @@ export default class AssociationsService {
5959
}
6060

6161
/**
62-
* Initiates an HTTP GET request to retrieve the associations searched based on association status.
63-
* @param associationStatus - an association status used to filter associations. This parameter is required. Available values: confirmed, awaiting-approval, removed. Default value: confirmed.
64-
* @param pageIndex - a page to be returned. Default value: 0.
65-
* @param itemsPerPage - a number of items returned per page. Default value: 15.
66-
* @param companyNumber - a filter based on company number.
67-
* @returns a promise that resolves to the HTTP response from the server that includes the associations or errors object.
62+
* Initiates an HTTP GET request to retrieve the association for a company for the provided user email.
63+
* @param companyNumber - a company number of the company for which the associations should be retrieved.
64+
* @param userEmail - an email address of a user to check if associated with the company.
65+
* @returns a promise that resolves to the HTTP response from the server that includes the association or errors object.
6866
*/
67+
public async getCompanyAssociationByUserEmail (companyNumber: string, userEmail: string): Promise<Resource<Association | Errors>> {
68+
const url = `/associations/companies/${companyNumber}`;
69+
const body = { user_email: userEmail }
70+
const response = await this.client.httpPost(url, body);
71+
72+
return this.getResource(response) as Resource<Association | Errors>;
73+
}
74+
75+
/**
76+
* Initiates an HTTP GET request to retrieve the associations searched based on association status.
77+
* @param associationStatus - an association status used to filter associations. This parameter is required. Available values: confirmed, awaiting-approval, removed. Default value: confirmed.
78+
* @param pageIndex - a page to be returned. Default value: 0.
79+
* @param itemsPerPage - a number of items returned per page. Default value: 15.
80+
* @param companyNumber - a filter based on company number.
81+
* @returns a promise that resolves to the HTTP response from the server that includes the associations or errors object.
82+
*/
6983
public async searchAssociations (
7084
associationStatus: AssociationStatus[],
7185
pageIndex?: number,

0 commit comments

Comments
 (0)