storeSensieRequest method

Future<Map<String, dynamic>> storeSensieRequest(
  1. int whipCount,
  2. int flowing,
  3. Agreement agreement
)

Implementation

Future<Map<String, dynamic>> storeSensieRequest(
    int whipCount, int flowing, Agreement agreement) async {
  final path = '/session/${sessionInfo.sessionId}/sensie';

  final body = {
    'accelerometerX': sensorData.accelX,
    'accelerometerY': sensorData.accelY,
    'accelerometerZ': sensorData.accelZ,
    'gyroscopeX': sensorData.gyroX,
    'gyroscopeY': sensorData.gyroY,
    'gyroscopeZ': sensorData.gyroZ,
    'whips': whipCount,
    'flowing': flowing == 1 ? 1 : -1,
    'agreement': agreement.value,
  };

  final header = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'X-api-key': sessionInfo.accessToken,
  };

  final res = await http.post(
    Uri.parse(BASE_URL + path),
    headers: header,
    body: json.encode(body),
  );
  return json.decode(res.body);
}