Log Daily Symptoms, Log Multiple Symptoms API - uoftblueprint/the-period-purse-ios GitHub Wiki
- Retrieves the user's symptom data for the given date.
- Calls
getItem()
onyear
as the key value, then withgetItem()
onmonth
, then navigate to the desired day to get data.
GETsymptomsForDate(<day: int>, <month: int>, <year: int>): Promise<symptoms object>
- Returns promise resolving when the set operation is completed. Promise contains a dictionary of the day's symptoms {"Flow": "light", "Mood": "sad", ...} if it previously existed, otherwise the promise contains a default version of the symptoms.
- If promise rejects (due to
getItem()
failing, theyear
ormonth
not existing, or some other reason), return a default version of the symptoms
- Posts the user's symptom data into the local storage for the given date.
- Calls
getItem()
with the year as the key value. This is to retrieve the month array for the mergerItem call. - Calls
mergeItem()
with the year as the key value, and the JSONified symptom data as the value,{month: [...,{symptoms},...]}
.- This means that if the element representing that day is empty, a new symptom object will be recorded. If there already is data there,
POSTsymptomsForDate
will rewrite over any existing data for that date.
- This means that if the element representing that day is empty, a new symptom object will be recorded. If there already is data there,
- async means that we can
await
for this function
async POSTsymptomsForDate(<day: int>, <month: int>, <year: int>, Object(flow: str, mood: str, cramps: str, sleep: float, exercise: array of str)): Promise<void>
- Returns promise resolving when the set operation is completed. If rejected, communicate to the frontend that an error occurred (which will prompt the user to try again).
-
Given an array of dates, for each date:
- Check if a year/month combo exists, if not create that year/month and add this entry into it.
- If index is empty (no data): add object with flow symptom = “MEDIUM”
- Else (data already there): Flip the flow value (no flow -> medium flow, any other flow -> no flow)
- Check if a year/month combo exists, if not create that year/month and add this entry into it.
-
Call
POSTsymptomsForDate
on each date in the array, passing in the date and JSONified symptom data as the value,{month: [...,{symptoms},...]
.
LogMultiDayPeriod(array of dates): Promise<void>
- Returns promise resolving when the set operation is completed. If rejected, communicate to the frontend that an error occurred (which will prompt the user to try again).