-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import "dotenv/config"; | ||
import config from "../config"; | ||
import { getAllCollegeGroups } from "../qualtrics/college-group-service"; | ||
import { app } from "@azure/functions"; | ||
import axios from "axios"; | ||
const urls = require("./urls"); | ||
|
||
app.http("re-activate-college", { | ||
methods: ["GET", "POST"], | ||
authLevel: "function", | ||
handler: async (request, context) => { | ||
const timeElapsed = Date.now(); | ||
const currentDate = new Date(timeElapsed); | ||
|
||
let activeCollegeGroups = (await getAllCollegeGroups()).filter( | ||
(collegeGroup) => | ||
collegeGroup.embeddedData?.groupStatus == "Active" | ||
&& collegeGroup?.unsubscribed | ||
); | ||
|
||
for (let x = 0; x < activeCollegeGroups.length; x++) { | ||
reSubscribeCollege(activeCollegeGroups[x].contactId); | ||
} | ||
return { | ||
body: JSON.stringify({ | ||
result: "success" | ||
}), | ||
}; | ||
}, | ||
|
||
}); | ||
|
||
async function reSubscribeCollege( | ||
contactId: string) { | ||
let collegeGroup = { | ||
unsubscribed: false | ||
}; | ||
const update_college_URL = | ||
urls.updateCollegeGroup() + "/" + contactId; | ||
await axios.put(update_college_URL, collegeGroup, { | ||
headers: urls.qualtricsHeader(), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters