Skip to content

Update Organization

Danny Hinshaw edited this page Dec 20, 2018 · 3 revisions

Update Organization

To update an organization you can use the /updateOrganization https endpoint.

Example

// Authenticate as admin
const authRef = firebase.auth();
const userCred: UserCredential = await authRef.signInWithEmailAndPassword("[email protected]", "your-password");
const tokenID: string = await userCred.user.getIdToken();


const updateOrgData = {
  id: "SOME_CUSTOM_ORG_ID", // required - id of org to update
  logoUrl: 'NEW_URL',       // optional.
  name: 'NEW_NAME',         // optional. 
  passcode: 'NEW_PASSCODE'  // optional. 
};


// Example request data
const requestObj = {
  method: 'post',
  body: JSON.stringify(updateOrgData),
  headers: {
    'Authorization': `Bearer ${tokenID}`,
    'Content-Type': 'application/json'
  }
};


// URL For triggering http cloud functions
const apiBaseURL = "https://us-central1-mrg-production-8813d.cloudfunctions.net";


// Call the https endpoint
fetch(apiBaseURL.concat('/updateOrganization'), requestObj)
  .then((response) => console.log(response))
  .catch((err: FirebaseError) => console.log(err));
  // response ex. { id: "SOME_CUSTOM_ORG_ID", logoUrl: 'NEW_URL', name: 'NEW_NAME', passcode: 'NEW_PASSCODE' }