Hi all, I would like to ask a question about the implementation of Profile.js generated by FitGen.
In the object types of Profile.js key/values are described like below:
gender: {
0: "female",
1: "male",
},
I generally use the structure types to making comparisons.
This is an example of an userProfile parsed:
"userProfile": {
"friendlyName":"Example",
"gender": 1,
"age": 34,
"height": 1.8,
"weight": 75,
"language": 0,
"elevSetting": 0,
"weightSetting": 0,
"restingHeartRate": 0,
"defaultMaxBikingHeartRate": 0,
"defaultMaxHeartRate": 0,
"speedSetting": 0,
"distSetting": 0,
"powerSetting": 0,
"temperatureSetting": 0,
"localId": 0,
"globalId": [0, 0, 0, 0, 0, 0],
"heightSetting": 0,
"positionSetting": 2
},
My question would be: Which is the best approach to compare the gender in userProfile?
I would expect something like:
import { Profile } from '@garmin/fitsdk';
...
const decoder = new Decoder(stream);
const { messages, errors } = decoder.read();
...
// isFemale check
messages?.userProfile?.gender === Profile.types.gender.female
But I couldn't access the object gender like that, only by numerical value.
The only way, I found is:
const genderName = Profile.types.gender[messages?.userProfile?.gender] // isFemale check genderName === Profile.types.gender[0]
Would not be better to organise the objects in types, like this?
gender: {
female: 0,
male: 1,
},
Am I missing something?
Thanks so much for the help, as always