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

Add API Functions for User-Created Policy Rooms #6281

Merged
merged 1 commit into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libs/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,19 @@ function UpdatePolicy(parameters) {
return Network.post(commandName, parameters);
}

/**
* @param {Object} parameters
* @param {String} parameters.policyID
* @param {String} parameters.reportName
* @param {String} parameters.visibility
* @return {Promise}
*/
function CreatePolicyRoom(parameters) {
const commandName = 'CreatePolicyRoom';
requireParameters(['policyID', 'reportName', 'visibility'], parameters, commandName);
return Network.post(commandName, parameters);
}

export {
Authenticate,
AuthenticateWithAccountID,
Expand All @@ -1129,6 +1142,7 @@ export {
ChangePassword,
CreateChatReport,
CreateLogin,
CreatePolicyRoom,
DeleteLogin,
DeleteBankAccount,
Get,
Expand Down
26 changes: 26 additions & 0 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,31 @@ function handleInaccessibleReport() {
navigateToConciergeChat();
}

/**
* Creates a policy room and fetches it
* @param {String} policyID
* @param {String} reportName
* @param {String} visibility
* @return {Promise}
*/
function createPolicyRoom(policyID, reportName, visibility) {
return API.CreatePolicyRoom({policyID, reportName, visibility})
.then((response) => {
if (response.jsonCode !== 200) {
Log.hmmm(response.message);
return;
}
return fetchChatReportsByIDs([response.reportID]);
})
.then(([{reportID}]) => {
if (!reportID) {
Log.hmmm('Unable to grab policy room after creation');
return;
}
Navigation.navigate(ROUTES.getReportRoute(reportID));
});
}

export {
fetchAllReports,
fetchActions,
Expand Down Expand Up @@ -1447,4 +1472,5 @@ export {
handleInaccessibleReport,
setReportWithDraft,
fetchActionsWithLoadingState,
createPolicyRoom,
};